[wxPython-users] Bug? Notebook + Sizer
Robin Dunn
robin at alldunn.com
Tue Jan 2 12:43:46 PST 2007
BTW, your CC address is still incorrect. You are using the subscription
address for wx-users, not the list address, so your messages are not
getting to wx-users.
Edward K. Ream wrote:
> Here is a simpler example than provided in the posting 'Sizing Notebook
> pages in a splitter window'. The following code does not work as
> expected on
> XP. Perhaps something is hiding in plain sight.
>
> In the wxPython demo, modify the Notebook demo as follows:
It's much easier if you send fully runnable sample apps to demonstrate
problems, or at least a patch file for one of the samples in the demo.
Having to edit something by hand can be too time consuming and/or error
prone to make it worth it for somebody to help you. Also, if you make
the effort to make a standalone sample it's been my experience that 9
times out of 10 you'll solve the problem yourself and will have learned
more in the process.
>
> 1. In TestNB.__init__ find the following lines:
>
> win = ScrolledWindow.MyCanvas(self)
> self.AddPage(win, 'ScrolledWindow')
>
> 2. After these lines, add these lines:
>
> win = self.makeColorPanel(wx.RED)
> w1 = wx.TextCtrl(win)
> w2 = wx.StaticText(win,label='Find Text')
> sizer = wx.BoxSizer(wx.HORIZONTAL)
> sizer.Add(w1,0,wx.EXPAND)
> sizer.Add(w2,0,wx.EXPAND)
> win.SetSizerAndFit(sizer)
> self.AddPage(win,"EKR")
>
> Run the modified demo. Select the EKR tab. Observe that the widgets are
> not aligned properly. In particular, on XP the TextCtrl overlaps the
> StaticText, and the StaticText is not placed to the right as expected.
Take a look at what makeColorPanel does. It makes a window that has a
handler for the wx.EVT_SIZE event to size and position the colored child
panel such that it fills the first panel. (I'm not real sure why there
are two panels for this sample, it may be because of an old bug in
wxGTK...) But since the default EVT_SIZE handler is where the sizer
layout is performed it is effectively cutting itself off from auto
layout. Try something like this instead:
win = wx.Panel(self)
w1 = wx.TextCtrl(win)
w2 = wx.StaticText(win,label='Find Text')
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(w1,0,wx.EXPAND)
sizer.Add(w2,0,wx.EXPAND)
win.SetSizer(sizer)
self.AddPage(win,"EKR")
Or even this:
class FindTextPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.w1 = wx.TextCtrl(self)
self.w2 = wx.StaticText(self,label='Find Text')
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(self.w1,0,wx.EXPAND)
sizer.Add(self.w2,0,wx.EXPAND)
self.SetSizer(sizer)
...
win = FindTextPanel(self)
self.AddPage(win,"EKR")
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list