views:

35

answers:

2

I have a wxPython application which allows the users to select items from menus that then change what is visible on the screen. This often requires a recalculation of the layout of panels. I'd like to be able to call the layout of all the children of a panel (and the children of those children) in reverse order. That is, the items with no children have their Layout() function called first, then their parents, and so on.

Otherwise I have to keep all kinds of knowledge about the parents of panels in the codes. (i.e. how many parents will be affected by a change in this-or-that panel).

A: 

Have a look at wxSizers and some examples for a fluid way to layout forms.

You can specify heights, poportions etc. etc. and then let the layout code do the rest for you :)

Jon Cage
I already use sizers to layout all the panels in the application. What happens though, is that based on the choices made (i.e. in a wxChoice control) the user is presented with a different set of additional controls. When one set of controls is presented it takes up a small amount of room in the panel, when the other set is presented it takes up a large amount of room, so I need to call the Layout() function of the parent. The problem is that after that, the parent might take up too much room in its own panel, so it needs to have ITS parent call Layout().
David Morton
A: 

More in response to your comment to Jon Cage's answer, than to your original question (which was perfectly answered by Jon):

The user might find it irritating, if the position of every element in your dialog changes, when he makes a choice. Maybe it'll look better, if only the "variable part" is updated. To achieve this, you could make a panel for each set of additional controls. The minimum size of each panel should be the minimum size of the largest of these panels. Depending on the user's choice you can hide or show the desired panel.

Alternatively, wxChoicebook might be what you need?

Ralph
You're right on with the users perspective. I've been trying to get my app to do something that will indeed be irritating. I'll use the wxChoicebook with minimum size set to the largest of the 'variable parts'. Thanks!
David Morton