hidden controls in gridsizer

Hello list,

I am using a wx.GridSizer with many controls
(drawn in xrced).

Based on the selected value in a wx.Choice,
I hide some controls inside the GridSizer,
then I call the Layout() method
of the panel containing the GridSizer.
The hidden controls indeed become visible, but
they still occupy space.

Is there any way to let hidden controls not take
up any space without clearing the sizer and rebuilding
it from scratch ?

If no, what would be the proper way to go about this knowing
that the controls in the GridSizer are quite complex (i.e. wxpanels
with all kinds of stuff on them).

Many thanks for your insights,
Stefaan.

I use the put-hidable-stuff-on-panels-and-hide-the-panels method. It works great for me.

Gre7g

···

On 8/12/08, Stefaan Himpe stefaan.himpe@gmail.com wrote:

Hello list,

I am using a wx.GridSizer with many controls
(drawn in xrced).

Based on the selected value in a wx.Choice,

I hide some controls inside the GridSizer,
then I call the Layout() method
of the panel containing the GridSizer.
The hidden controls indeed become visible, but
they still occupy space.

Stefaan Himpe wrote:

Hello list,

I am using a wx.GridSizer with many controls
(drawn in xrced).

Based on the selected value in a wx.Choice,
I hide some controls inside the GridSizer,
then I call the Layout() method
of the panel containing the GridSizer.
The hidden controls indeed become visible, but
they still occupy space.

Is there any way to let hidden controls not take
up any space without clearing the sizer and rebuilding
it from scratch ?

If no, what would be the proper way to go about this knowing
that the controls in the GridSizer are quite complex (i.e. wxpanels
with all kinds of stuff on them).

In a wx.GridSizer the sizer always expands to fit the window it belongs to, and the space allocated to the items are always at least as big as the biggest item. If you use a wx.FlexGridSizer or wx.GridBagSizer instead then it will probably act the way you want it to.

···

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

Hello Robin,

Thanks for your swift reply,

If you use a wx.FlexGridSizer or wx.GridBagSizer instead then it will probably act the way you want it to.

While my interface certainly looks better after changing from GridSizer to FlexGridSizer, invisible controls are still taking space, causing
"gaps" to appear in the grid.

Best regards,
Stefaan.

Stefaan Himpe wrote:

Hello Robin,

Thanks for your swift reply,

If you use a wx.FlexGridSizer or wx.GridBagSizer instead then it will probably act the way you want it to.

While my interface certainly looks better after changing from GridSizer to FlexGridSizer, invisible controls are still taking space, causing
"gaps" to appear in the grid.

Are you wanting the items after the hidden one to move up to the "cell" occupied by the hidden item? If so then the sizers won't do that, they only ignore the hidden item for the purposes of minimal size and layout calculations but its slot in the layout will remain occupied.

···

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

Hello Robin,

Are you wanting the items after the hidden one to move up to the "cell" occupied by the hidden item?

Yes, that's what I was hoping for... I had misunderstood that one would use spacers instead of hidden controls to create gaps in UIs. As I understand it now, spacers add space in between controls, but do not fill a cell - i.e. they are not a control themselves.

Anyway I'll fiddle a bit with the following ideas:

1. add some methods in my program to clear and refill the sizer based on which controls are visible, or perhaps:
2. write a customized sizer (based on wx.FlexGridSizer) that automatically removes hidden controls which are hidden

Best regards,
Stefaan.

Stefaan Himpe wrote:
2.write a customized sizer (based on wx.FlexGridSizer) that automatically removes hidden controls which are hidden

May I suggest that your customized sizer, after removing (NOT destroying) the hidden controls, uses control.Move((-1000, -1000)) to set them out of the visible frame?

This way, in case you later need them again, an instruction .Insert will do the job.

···

2008/8/14 Stefaan Himpe stefaan.himpe@gmail.com

Hello Robin,

Are you wanting the items after the hidden one to move up to the “cell” occupied by the hidden item?

Yes, that’s what I was hoping for… I had misunderstood that one would use spacers instead of hidden controls to create gaps in UIs. As I understand it now, spacers add space in between controls, but do not fill a cell - i.e. they are not a control themselves.

Anyway I’ll fiddle a bit with the following ideas:

  1. add some methods in my program to clear and refill the sizer based on which controls are visible, or perhaps:

  2. write a customized sizer (based on wx.FlexGridSizer) that automatically removes hidden controls which are hidden

Best regards,

Stefaan.


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users