MDIChildFrames and sizers - help

Hello,

I need some help with MDIChildFrame and sizers. Basically what I am trying to do is to have 6 MDIChildFrames within the MDIParentFrame, and these 6 Frames should be tiled according to the sizer. For some reason it seems that the children windows are not placed in the sizer, but are displayed in cascade as if the sizer wasn’t there.

Am I doing something wrong? Can anyone help?

Thanks.

here’s the code:

import wx

class MyParentFrame(wx.MDIParentFrame):
def init(self):
wx.MDIParentFrame.init(self, None, -1, “MDI Parent”, size=(800,800))

self.winCount = 0
menu = wx.Menu()
menu.Append(wx.ID_NEW, “&New Window”)
menu.AppendSeparator()
menu.Append(wx.ID_EXIT, “E&xit”)

menubar = wx.MenuBar()
menubar.Append(menu, “&File”)
self.SetMenuBar(menubar)

self.CreateStatusBar()

self.Bind(wx.EVT_MENU, self.OnNewWindow, id=wx.ID_NEW)
self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)

    win1 = wx.MDIChildFrame(self, -1, "Child Window 1")

    win2 = wx.MDIChildFrame(self, -1, "Child Window 2")
    win3 = wx.MDIChildFrame(self, -1, "Child Window 3")

win4 = wx.MDIChildFrame(self, -1, “Child Window 4”)

win5 = wx.MDIChildFrame(self, -1, “Child Window 5”)

win6 = wx.MDIChildFrame(self, -1, “Child Window 6”)

    sizer = self.sizer = wx.GridBagSizer(5, 5)

    sizer.Add(win1, (0,0), flag = wx.EXPAND)
    sizer.Add(win2, (1,0), flag = wx.EXPAND)
    sizer.Add(win3, (2,0), flag = wx.EXPAND)

sizer.Add(win4, (0,1), flag = wx.EXPAND)
sizer.Add(win5, (1,1), flag = wx.EXPAND)
sizer.Add(win6, (2,1), flag = wx.EXPAND)

    sizer.AddGrowableRow(0)

sizer.AddGrowableRow(1)

sizer.AddGrowableRow(2)

sizer.AddGrowableCol(0)

sizer.AddGrowableCol(1)

self.SetSizerAndFit(sizer)
self.SetSize((800, 800))

def OnExit(self, evt):
self.Close(True)

def OnNewWindow(self, evt):
    self.winCount = self.winCount + 1
    win = wx.MDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
    win.Show(True)

if name==“main”:
app = wx.PySimpleApp()
win = MyParentFrame()
win.Show(True)
app.MainLoop()

Sunday, May 6, 2007, 12:22:44 PM, Bogdan C wrote:

I need some help with MDIChildFrame and sizers. Basically what I am
trying to do is to have 6 MDIChildFrames within the MDIParentFrame,
and these 6 Frames should be tiled according to the sizer.

It's not possible to do that. Sizers help to put controls inside
frames, not to distribute frames (MDIChildFrames) over frames
(MDIParentFrame). Maybe wx.aui is what you're looking for?

-- tacao

No bits were harmed during the making of this e-mail.