2 panels in a NotebookPage

Hi,

I’m trying to get two simple panels with somecheckboxes appear on a classic NotebookPage. The problem is that they do not display themselves correctly :

#!/usr/bin/env python

import wx

class MyPage(
wx.NotebookPage):
def init(self, parent):
wx.NotebookPage.init(self, parent, -1)
sizer = wx.BoxSizer(wx.VERTICAL)

sizer.Add(self.createBoxes(), 0, 0)
sizer.Add(self.createBoxes

(), 0, 0)

self.SetSizer(sizer)
self.Fit()

def createBoxes(self):
“”"
Create a set of checkboxes. Here a specific sizer is used
“”"
panel = wx.Panel(self)
sizer = wx.GridSizer(4, 7)
for x in range(0, 4):
for y in range(0, 7):
box = wx.CheckBox(panel, -1, ‘%d-%d’ %(x, y))
sizer.Add(box)
panel.SetSizer
(sizer)
panel.Fit()
return panel

class MainFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, -1)
self.notebook = wx.Notebook(self)
self.notebook.AddPage(MyPage(
self.notebook), “test”)

class App(wx.App):
def OnInit(self):
‘Create the main window and insert the custom frame’
frame = MainFrame()
frame.Show(True)

return True

app = App(0)
app.MainLoop()

With this sample, two panels are created with createBoxes(), but only one is displayed and usable.
Is there an obvious mistake in what I’m doing ?

Matthieu

Are you trying to separate the checkboxes
into groups? You can do so with a staticbox. Check out the demo, it’s got
a good example for staticboxes.

···

-----Original Message-----
From: Matthieu Brucher
[mailto:matthieu.brucher@gmail.com]
Sent: Tuesday, October 23, 2007
4:18 PM
To:
wxPython-users@lists.wxwidgets.org
Subject: [wxPython-users] 2 panels
in a NotebookPage

Hi,

I’m trying to get two simple panels with somecheckboxes appear on a classic
NotebookPage. The problem is that they do not display themselves correctly :

#!/usr/bin/env python

import wx

class MyPage( wx.NotebookPage):

def init(self, parent):

wx.NotebookPage.__init__(self, parent, -1)

sizer = wx.BoxSizer(wx.VERTICAL)

sizer.Add(self.createBoxes(), 0, 0)

sizer.Add(self.createBoxes (), 0, 0)

self.SetSizer(sizer)

self.Fit()

def createBoxes(self):

"""

Create a set of checkboxes. Here a specific sizer is used

"""

panel = wx.Panel(self)

sizer = wx.GridSizer(4, 7)

for x in range(0, 4):

  for y in range(0, 7):

    box = wx.CheckBox(panel, -1, '%d-%d'

%(x, y))

    sizer.Add(box)

panel.SetSizer (sizer)

panel.Fit()

return panel

class MainFrame(wx.Frame):

def init(self):

wx.Frame.__init__(self, None, -1)

self.notebook = wx.Notebook(self)

self.notebook.AddPage(MyPage( self.notebook),

“test”)

class App(wx.App):

def OnInit(self):

'Create the main window and insert the custom frame'

frame = MainFrame()

frame.Show(True)

return True

app = App(0)

app.MainLoop()

With this sample, two panels are created with createBoxes(), but only one is
displayed and usable.

Is there an obvious mistake in what I’m doing ?

Matthieu