[wxPython-users] (Yet another) sizer question

Frank Millman frank at chagford.com
Tue Jun 6 01:56:21 PDT 2006


Robin Dunn wrote:
> 
> Frank Millman wrote:
> > Hi all
> > 
> > I have managed to avoid sizer problems until now. I do not 
> understand 
> > them in depth, but I try to keep my requirements simple, so I am 
> > usually able to get a reasonable layout without too much 
> trouble. Now 
> > I have a more complex situation which I cannot figure out.
> > 
> 
> I see a couple misconceptions in your code.  First splitter 
> windows don't use a sizer to manage the layout of their 
> children, so giving them a sizer containing their children is 
> useless.  Second, the initial position of the sash is not 
> dependent on the min or best size of the children.  Since you 
> don't specify an initial sash position then it is set by 
> default in the middle.  On the other hand, the best size of 
> the splitters is calculated based on what each child reports 
> as its best size, so the total size is enough to display both 
> children at their optimal size, but you're just missing the 
> step of setting the sash position appropriately.
> 
> So with these things in mind your TriPanel class can be 
> reduced to this, giving you the layout you want:
> 

Wonderful! This works perfectly. Thanks so much, Robin.

I have one more desire, but I suspect that it is not possible. Still, there
is no harm in asking.

Say I have a splitter window with a vertical sash, and a tree control in the
left pane.

If the tree gets too big, I can drag the sash to the right. The left pane
gets bigger, but the right pane gets smaller, which may not be what I want.

If instead I drag the right-hand border to the right, the right pane gets
bigger, and the left pane stays the same.

I was hoping that, if I drag the left-hand border to the left, the left pane
would get bigger, and the right pane would stay the same. In fact, it is
still the right pane that gets bigger, and the left pane stays the same.

I think that this is how the native control works. For example, if I try
this with Windows Explorer, it behaves in the same way.

Is it possible to achieve what I want? To do so, I would need to detect that
the left-hand border was being dragged, and then calculate a new position
for the sash, but I have not seen an event that gives this information.

The question is academic - I doubt if I would actually go to these lengths -
but it would be interesting to know if it is possible.

Any suggestions?

Thanks

Frank





More information about the wxpython-users mailing list