I'd like to have some widgets that have alternates (a combo vs. a
calendar, etc) depending on user choice. On subbing in the chosen
widget, I want it to seamlessly take the place of the previously shown
widget in the sizer's layout.
What's the right way to go about that?
I'm using sizer.Insert() to insert the alternate widgets into the
flexGridSizer, and then hiding them. But the space for each is still
reserved, which messes up the whole flexGridSizer's layout. I am also
calling parent.Layout() or sizer.Layout() and it is not helping. And
whether I hide the widgets via widget.Hide() or sizer.Hide(widget),
the space is still reserved.
I thought that a sizer ignores a hidden widget? What am I doing
wrong? Need I use sizer.Replace() on each sub-in/sub-out?
What wound up working was, in addition to using .Hide(replaced_widget)
and.Show(new_widget) appropriately, to also call
sizer.Detach(replaced_widget) and sizer.Insert(new_widget) on each
substitution.
For some reason I was under the impression that a hidden widget was
treated by a sizer as if it weren't there at all so that only Hide()
and Show() were needed. Guess not?
Che
···
On Thu, Sep 16, 2010 at 3:33 PM, C M <cmpython@gmail.com> wrote:
I'd like to have some widgets that have alternates (a combo vs. a
calendar, etc) depending on user choice. On subbing in the chosen
widget, I want it to seamlessly take the place of the previously shown
widget in the sizer's layout.
What's the right way to go about that?
I'm using sizer.Insert() to insert the alternate widgets into the
flexGridSizer, and then hiding them. But the space for each is still
reserved, which messes up the whole flexGridSizer's layout. I am also
calling parent.Layout() or sizer.Layout() and it is not helping. And
whether I hide the widgets via widget.Hide() or sizer.Hide(widget),
the space is still reserved.
I thought that a sizer ignores a hidden widget? What am I doing
wrong? Need I use sizer.Replace() on each sub-in/sub-out?
The sizer will ignore the size of the hidden widget, but for the grid sizers that position in the grid is still reserved for that item.
···
On 9/16/10 7:30 PM, C M wrote:
For some reason I was under the impression that a hidden widget was
treated by a sizer as if it weren't there at all so that only Hide()
and Show() were needed. Guess not?
For some reason I was under the impression that a hidden widget was
treated by a sizer as if it weren't there at all so that only Hide()
and Show() were needed. Guess not?
The sizer will ignore the size of the hidden widget, but for the grid sizers
that position in the grid is still reserved for that item.