Hello all,
I am creating an MDI application. I am trying to use XRC to do most of the
user interface layout.
I am having problems with MDI child frames created from XRC showing outside
the MDI parent frame. When using normal two stage creation, the MDI children
show inside the parent.
Consider the following application:
import wx
from wx.xrc import *
class MyApp(wx.App):
def OnInit(self):
XmlResource.Get().Load('mdi.xrc')
MyParentFrame(None).Show()
return True
class MyParentFrame(wx.MDIParentFrame):
def __init__(self, parent):
pre = wx.PreMDIParentFrame()
XmlResource.Get().LoadOnFrame(pre, parent, 'MyParentFrame')
self.PostCreate(pre)
self.Bind(wx.EVT_MENU, self.OnChild, id=XRCID("ChildMenuItem"))
def OnChild(self, evt):
MyChildFrame(self).Show()
class MyChildFrame(wx.MDIChildFrame):
def __init__(self, parent):
pre = wx.PreMDIChildFrame()
ChildFromXrc = True ### CHANGE THIS TO FALSE TO MAKE IT WORK
if ChildFromXrc:
XmlResource.Get().LoadOnFrame(pre, parent, 'MyChildFrame')
else:
pre.Create(parent, -1, 'Child Frame')
self.PostCreate(pre)
if __name__ == '__main__':
MyApp(False).MainLoop()
The mdi.xrc file contains the following:
<?xml version="1.0" encoding="ISO-8859-1"?>
<resource version="2.3.0.1" xmlns="http://www.wxwidgets.org/wxxrc">
<object class="wxFrame" name="MyParentFrame"
subclass="wxMDIParentFrame">
<style>wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX
wxCLOSE_BOX</style>
<size>640,480</size>
<title>Parent Frame</title>
<object class="wxMenuBar" name="MainMenuBar">
<object class="wxMenu">
<label>&File</label>
<object class="wxMenuItem" name="ChildMenuItem">
<label>Child Frame</label>
</object>
</object>
</object>
</object>
<object class="wxFrame" name="MyChildFrame" subclass="wxMDIChildFrame">
<style>wxCAPTION|wxRESIZE_BORDER|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX</
<size>400,300</size>
<title>Child Frame</title>
</object>
</resource>
I specify wxMDIParentFrame and wxMDIChildFrame as subclasses because I think
that wxWindows has bug with regards to directly specifying the MDI frames as
classes.
With ChildFromXrc true, the MDI child window shows outside the MDI parent
window. With the variable false, everything works fine. Am I doing something
wrong? Is this a bug?
I am using wxPython 2.5.3.1 on Windows Server 2003.
Thanks
Albert Strasheim