[wxPython-users] problem setting the sashposition of a SplitterWindow

Humberto Abdelnur humberto.abdelnur at loria.fr
Sat Oct 27 08:01:58 PDT 2007


Hi, as you said, the initial size of the splitter is (20,20) and not the size it should. 
So using the wx.CallAfter function make it work as i want it. Thanks a lot for the explanation and all the help.

Humberto

Humberto Abdelnur wrote:
> Yes, the problem is that i can not specified the sashposition as at all 
> (neither absolute nor relative).  I ve no control at all in the 
> rightmost sashposition when i ve the outer notebook. The code is below. 
> I added a few more frames to pictured better in the screenshot. You can 
> see there that in the first 2 frame (the ones without the outer 
> Notebook), i m able to set the sashpositions as i want.
> However, in the last 3 frames (the ones with an outer Notebook) the 
> sashposition of the rigthmost splitter is not modified.
> 

I haven't bee following this thread very closely since Kyle has been 
answering, so please forgive me if this doesn't apply.  I just wanted to 
mention that a common problem with splitter windows comes from the fact 
that when they are initially created their default size is very small 
(20,20).  Since the sash position is constrained to fit within the size 
of the widget setting a position of 200 or something just won't work 
correctly until after the splitter has been set to the final initial size.

So the splitter window defers the setting of the sash position the first 
time until it gets the first EVT_SIZE event (or something like that.) 
The assumption is that this size event is due to the sizer in the parent 
being evaluated after the top-level parent has been sized and shown. 
Most of the time this works great, but in some cases, such as nested 
splitters and other complex layouts, the first size event is not the 
final initial size that the splitter will eventually be set to, and it 
may still be too small for the requested sash position so it ends up at 
the wrong place because of the constraints.   In these situations you 
can do things like change when you call the splitter's Split* methods, 
or use wx.CallAfter to call SetSashPosition after all the initial layout 
has been done.

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

-- 
Humberto J. Abdelnur
Ph.D student 
Madynes LORIA/INRIA Lorraine
http://www.loria.fr/~abdelnur






More information about the wxpython-users mailing list