I wanted an MDI window with a toolbar; if I put a toolbar in the
MDIParent, then the children overwrite it.
If someone can show me how to keep the child from destroying the
toolbar, that would be optimal. LayoutMDIFrame() would have to
recognize the toolbar, just as it does the menubar.
Dev env: WinXP, py2.6, wx2.8ansi, Boa from CVS
test code below:
···
________________________________________________
#!/usr/bin/env python
#Boa:App:BoaApp
import wx
import MDIParentFrame1
modules ={'MDIParentFrame1': [0, 'Main frame of Application',
u'MDIParentFrame1.py']}
class BoaApp(wx.App):
def OnInit(self):
self.main = MDIParentFrame1.create(None)
self.main.Show()
self.SetTopWindow(self.main)
return True
def main():
application = BoaApp(0)
application.MainLoop()
if __name__ == '__main__':
main()
____________________________________
#Boa:MDIParent:MDIParentFrame1
import wx
from wx.lib.anchors import LayoutAnchors
import MDIChildFrame2
def create(parent):
return MDIParentFrame1(parent)
[wxID_MDIPARENTFRAME1, wxID_MDIPARENTFRAME1BUTTON1,
wxID_MDIPARENTFRAME1TOOLBAR1,
] = [wx.NewId() for _init_ctrls in range(3)]
[wxID_MDIPARENTFRAME1MENU1ITEMS0] = [wx.NewId() for
_init_coll_menu1_Items in range(1)]
class MDIParentFrame1(wx.MDIParentFrame):
def _init_coll_menuBar1_Menus(self, parent):
# generated method, don't edit
parent.Append(menu=self.menu1, title='Menus0')
def _init_coll_menu1_Items(self, parent):
# generated method, don't edit
parent.Append(help='', id=wxID_MDIPARENTFRAME1MENU1ITEMS0,
kind=wx.ITEM_NORMAL, text='New Window')
self.Bind(wx.EVT_MENU, self.OnMenu1Items0Menu,
id=wxID_MDIPARENTFRAME1MENU1ITEMS0)
def _init_coll_toolBar1_Tools(self, parent):
# generated method, don't edit
parent.AddControl(control=self.button1)
parent.Realize()
def _init_utils(self):
# generated method, don't edit
self.menuBar1 = wx.MenuBar()
self.menu1 = wx.Menu(title='')
self._init_coll_menuBar1_Menus(self.menuBar1)
self._init_coll_menu1_Items(self.menu1)
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.MDIParentFrame.__init__(self, id=wxID_MDIPARENTFRAME1,
name='',
parent=prnt, pos=wx.Point(192, 161), size=wx.Size(586,
432),
style=wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL,
title='MDIParentFrame1')
self._init_utils()
self.SetClientSize(wx.Size(578, 405))
self.SetMenuBar(self.menuBar1)
self.toolBar1 = wx.ToolBar(id=wxID_MDIPARENTFRAME1TOOLBAR1,
name='toolBar1', parent=self, pos=wx.Point(0, 0),
size=wx.Size(578, 27),
style=wx.CLIP_CHILDREN | wx.ALWAYS_SHOW_SB |
wx.TB_HORIZONTAL | wx.NO_BORDER)
self.button1 = wx.Button(id=wxID_MDIPARENTFRAME1BUTTON1,
label='button1', name='button1', parent=self.toolBar1,
pos=wx.Point(0, 1), size=wx.Size(75, 19), style=0)
self._init_coll_toolBar1_Tools(self.toolBar1)
def __init__(self, parent):
self._init_ctrls(parent)
self.Bind(wx.EVT_SIZE, self.OnSize)
def OnSize(self, event):
wx.LayoutAlgorithm().LayoutMDIFrame(self)
def OnMenu1Items0Menu(self, event):
win = wx.MDIChildFrame(self, -1, "Child Window" )
win.Show(True)