The widget is in one of many sizers I make, but how to get sizer of one of these widgets, for example in wx.StaticText
. First, I though wx.StaticText have a method GetSizer()
because it derived from wx.Window
, but it always return None
, is there a way?
Sorry for my poor language.
EDIT (08/23/2012) Solution from Mike Driscoll:
Using self.sizer.GetChildren()
to get SizerItemList
from some sizer, then using GetWindow()
to get actual widget from the list
If the sizer has children, then GetChildren does return a list of widgets. I've done it many times with wxPython 2.8. I don't remember anyone mentioning it was different in 2.9 or Phoenix, so I'm guessing it's not. Can you tell us which OS and wxPython version you're using?
If you want to know how to get an arbitrary sizer, you might try GetContainingSizer or use the Widget Inspection Tool
EDIT (08/22/2012): Here's a working example: