[wxPython-users] 2 panels in a NotebookPage
Mike Driscoll
mdriscoll at co.marshall.ia.us
Wed Oct 24 08:48:23 PDT 2007
> -----Original Message-----
> From: Matthieu Brucher [mailto:matthieu.brucher at gmail.com]
> Sent: Wednesday, October 24, 2007 9:54 AM
> To: wxPython-users at lists.wxwidgets.org
> Subject: Re: [wxPython-users] 2 panels in a NotebookPage
>
> Thank you, this seems to work on Linux, I have to check if it
> works with Windows this evening. *I tried something like this
> before, but it was obviously not correct.
> In fact, the only change is that you use the panel on the
> whole notebook page. This should work without it, shouldn't
> it ? Or is the NotebookPage the whole page with the tab ?
Maybe I'm mis-understanding, but for each page in a notebook, you
typically use a separate panel object. Something like this:
notebook = wx.Notebook(panel, -1, size=(750, 580))
page1 = wx.Panel(notebook)
page2 = wx.Panel(notebook)
notebook.AddPage(page1, 'Title')
notebook.AddPage(page2, 'Title')
However, maybe this isn't the paradigm used for wx.NotebookPage.
Admittedly, I've never used this specific version of the notebook control.
Mike
>
> Matthieu
>
>
> 2007/10/24, Rickey, Kyle W <Kyle.Rickey at bakerhughes.com>:
>
> I guess I don't understand why you need 2 panels. Why
> not add everything to 1 panel and use multiple sizers to get
> the layout you want? I've modified your demo below. Perhaps
> you could post some sample code for the matplotlib and
> checkboxes scenario and we could look for the problem.
>
> Kyle Rickey
>
>
> #!/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 )
>
> self.panel = wx.Panel(self)
>
> sizer.Add(self.createBoxes(), 0, 0)
> sizer.Add(self.createBoxes (), 0, wx.TOP, 30)
>
> self.panel.SetSizer(sizer)
> self.panel.Fit()
>
> def createBoxes(self):
> """
> Create a set of checkboxes. Here a specific sizer is used
> """
> sizer = wx.GridSizer(4, 7)
> for x in range(0, 4):
> for y in range(0, 7):
> box = wx.CheckBox(self.panel, -1, '%d-%d' %(x, y))
> sizer.Add(box)
> return sizer
>
> 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()
>
> -----Original Message-----
> From: Matthieu Brucher [mailto:matthieu.brucher at gmail.com ]
> Sent: Wednesday, October 24, 2007 12:33 AM
> To: wxPython-users at lists.wxwidgets.org
> Subject: Re: [wxPython-users] 2 panels in a NotebookPage
>
> No, in fact I want to have a group of checkboxes with a
> Matplotlib figure, but the same bug occurs, so for the sake
> of simplicity, I use twice the same panel.
> 2007/10/23, Rickey, Kyle W < Kyle.Rickey at bakerhughes.com>:
> 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 at gmail.com]
> Sent: Tuesday, October 23, 2007 4:18 PM
> To: wxPython-users at lists.wxwidgets.org
> <mailto:wxPython-users at 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail:
> wxPython-users-help at lists.wxwidgets.org
> <mailto:wxPython-users-help at lists.wxwidgets.org>
>
>
>
>
>
More information about the wxpython-users
mailing list