[wxPython-users] Removing components from a gridbagsizer
Robin Dunn
robin at alldunn.com
Thu Jun 1 10:28:25 PDT 2006
Peter Decker wrote:
> On 6/1/06, Julian Swartz <swartzjp at gmail.com> wrote:
>> That doesn't work. Consider the test program below. I have a GridBagSizer
>> managing a 2x2 grid containing 2 buttons and 2 StaticText labels. I
>> want to
>> be able to make button 2 disappear by clicking button 1, but when I
>> use the
>> Detach method, nothing happens. If I add the line self.sizer.Layout()
>> to the
>> end of the button_clicked() method, button 2 is still visible and the
>> items
>> merely get realigned in the grid.
>
> Oh, you want to get rid of the items. I thought you only wanted to
> remove them from the grid. Can't you just call button.Show(False),
> followed by grid.Layout()?
>
And if you never need to show the button again (or don't mind recreating
it) then you can call button.Destroy(), which will automatically remove
it from the sizer as well. You'll still need to call Layout though.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list