GridBagSizer: Items not in the correct positions

Robin Dunn robin at alldunn.com
Sun Apr 6 16:31:10 PDT 2008


Egon Frerich wrote:
> I have a little class which combines two widgets (Button and TextCtrl):
> 
>> import wx
>>
>> class Taganzeige(wx.Window):

You should derive from wx.Panel so the autolayout with the sizers will 
work correctly.


>>     def __init__(self, parent, *args, **kwds):
>>         self.parent = parent
>>         self.text = kwds.pop('text')
>>         super(Taganzeige, self).__init__(parent,             *args, 
>> **kwds)
>>         self.panel_1 = wx.Panel(self.parent, -1)

But this is the real problem.  You are treating this panel as if it was 
a child of this class, but are creating it as a child of the parent 
window instead.  That's why the layout isn't working, because they are 
on the wrong window.  Looking at the rest of the code I'd say that you 
don't really need this panel anyway.  Just put the widgets on self.


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



More information about the wx-users mailing list