xrc unknown control sizer problem

Hi,
I'm having problems with a grid control which I attach to an xrc 'unknown
control' node. I'd like the grid to appear in its minsize and not be expanded by
the sizer. The attached examples demonstrates the problem. The grid control
appears to be larger than the space the sizer thinks it needs. Therefor it is
partly hidden by the buttons. Why isn't the sizer respecting the grid's minsize?
Any ideas?

Regards, Christian

gridexpand.py (3.61 KB)

gridexpand.xrc (1.24 KB)

Christian Kristukat wrote:

Hi,
I'm having problems with a grid control which I attach to an xrc 'unknown
control' node. I'd like the grid to appear in its minsize and not be expanded by
the sizer. The attached examples demonstrates the problem. The grid control
appears to be larger than the space the sizer thinks it needs. Therefor it is
partly hidden by the buttons. Why isn't the sizer respecting the grid's minsize?
Any ideas?

When a "unknown control" is used in XRC it actually creates a panel to put into that spot, and then when you use the AttachUnknownControl method it reparents your control to that panel. So basically there is an extra window between your grid and the panel that you thought was its parent.

There is a sizer on that panel, but it looks like it is not behaving as expected. There is an easy workaround though. After you do the AttachUnknownControl do something like this:

         grid.GetParent().SetMinSize(grid.GetMinSize())

···

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

Robin Dunn wrote:

Christian Kristukat wrote:

Hi,
I'm having problems with a grid control which I attach to an xrc 'unknown
control' node. I'd like the grid to appear in its minsize and not be
expanded by
the sizer. The attached examples demonstrates the problem. The grid
control
appears to be larger than the space the sizer thinks it needs.
Therefor it is
partly hidden by the buttons. Why isn't the sizer respecting the
grid's minsize?
Any ideas?

When a "unknown control" is used in XRC it actually creates a panel to
put into that spot, and then when you use the AttachUnknownControl
method it reparents your control to that panel. So basically there is
an extra window between your grid and the panel that you thought was its
parent.

There is a sizer on that panel, but it looks like it is not behaving as
expected. There is an easy workaround though. After you do the
AttachUnknownControl do something like this:

        grid.GetParent().SetMinSize(grid.GetMinSize())

I see. Thanks a lot. I noticed that in addition a grid.Layout() is needed
thereafter.
Btw. can I supress the display of one of the scrollbars in the grid? As this
grid is quite small I always want to display it in its full representation.

Regards, Christian

ps: I just recieved your book in Japan. I'm pleased that I already knew much of
its content by reading that list and the demo and I really enjoyed the part
concerning MVC.

Christian Kristukat wrote:

Btw. can I supress the display of one of the scrollbars in the grid? As this
grid is quite small I always want to display it in its full representation.

This is a tricky side-effect of how the scrolled window handles its virtual size and scrolling. The scrollbars are set to scroll a certain amount when clicking on the arrow buttons, a.k.a. the scroll rate. The virtual size set for a scrolled window is then rounded up to the next multiple of this scroll rate in order for the whole virtual area of the window to be displayed when scrolling. Most of the time this results in the virtual size being just a little bigger than expected, and if you size the window to be same size as the expected virtual size then scrollbars appear in order to show the extra space.

···

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