[wxPython-users] RE: SpinCtrl and forward tab-cycle

Robin Dunn robin at alldunn.com
Fri Jan 4 16:08:07 PST 2008


mawe wrote:
> Thanks to you two. Mike, your "workaround" works somehow. But it 
> destroys my layout, since it seems to depend on SetAutoLayout(True). 
> Furthermore, the tab-cycle in my actual app seems to be broken somehow, 
> again.
> 
> I've attached my complete code, with my orignal attempts commented out 
> and Mikes suggestions just below.
> Please bear with me and the code, they're my first steps in wxPython.

[...]
>         self.topText = wx.StaticText(self, -1, "Top", (20, 10))
>         self.middleText = wx.StaticText(self, -1, "Middle", (20, 10))
>         self.bottomText = wx.StaticText(self, -1, "Bottom", (20, 10))
> 
[...]
>         # All the commented below is my old code
>         #self.SetSizer(self.mainSizer)        
>         #self.SetAutoLayout(True)
>         #self.mainSizer.Fit(self)
>         #self.Show(1)
>         
>         # And these are the suggestions by Mike Driscoll
>         panel = wx.Panel(self,-1)
>         panel.SetSizer(self.mainSizer)
>         panel.Layout()
>         self.Show()

You missed the point.  You should not only put the panel in the frame, 
but you should make all your widgets be children of the panel instead of 
the frame.  The panel is what manages the tab-traversal of it's 
children, but in your sample it has no children at all so it can't do 
anything.  Move the creation of the panel to the top of the __init__ 
method, and change all the other widgets to use the panel as the parent 
instead of self.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!




More information about the wxpython-users mailing list