Hi,
I am trying to create multiple frames with wxPython which each contain
a Listbook organizer panel of the same widths. I am using wxPython
version 2.8.11.0 (gtk2-unicode) with Python 2.7.2 in Ubuntu 11.10.
When I create multiple frames, each panel width is currently set by
the width of the text in that panel. I would like to be able to have
all frames use the same (fixed) panel width. A short code that
illustrates what I am trying to do is included below.
I have tried passing the "size" argument to the Listbook constructor
and using SetSize and SetMinSize on the Listbook and its children to
no avail. Any help would be greatly appreciated!
Thanks,
Tyler
# Based on the example from http://wiki.wxpython.org/Listbook
import wx
import wx.lib.inspection
···
#-----------------------------------------------------
class MyListBook(wx.Listbook):
def __init__(self, parent, labelText):
wx.Listbook.__init__(self, parent, wx.ID_ANY,
style=wx.BK_DEFAULT,
size=(300,-1))
pages = [(wx.Panel(self), labelText),
(wx.Panel(self), "Normal Label"),
(wx.Panel(self), "Normal Label")]
for page, label in pages:
self.AddPage(page, label)
#-----------------------------------------------------
class DemoFrame(wx.Frame):
def __init__(self, labelText):
wx.Frame.__init__(self, None, wx.ID_ANY,
"Listbook Example",
size=(400,400))
panel = wx.Panel(self)
notebook = MyListBook(panel, labelText)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(notebook, 1, wx.ALL|wx.EXPAND, 10)
panel.SetSizer(sizer)
self.Layout()
self.Show()
#-----------------------------------------------------
# I want both frames to have Listbook panels that are the same width
# but in this example, the wide label frame has a wider panel
app = wx.PySimpleApp()
frame1 = DemoFrame("Normal Label")
frame2 = DemoFrame("Really Really Wide Label")
wx.lib.inspection.InspectionTool().Show()
app.MainLoop()