| Store | Cart

Re: [TCLCORE] ttk::panedwindow pane -stretch option

From: Joe English <jeng...@flightlab.com>
Fri, 11 Sep 2015 16:04:05 -0700
Sam Bromley wrote:
> [...]> I've played around with the weights a fair> bit before finding that it wasn't behaving as desired.> Specifically, when I specify -weight 0 for the bottom> frame, and later pack a widget within that (initially> empty frame), the panedwindow manager will not resize> the bottom frame to show the new content.>> If instead, I set a non-zero weight (say 1) to the> bottom frame, and a larger weight (say 10) to the> top frame, then initially, the bottom frame (containing the> empty placeholder frame) (a) still receives space, and (b)> does not resize when said frame is populated with> a larger widget (even though it is clear upon inspection that the> child frame itself has resized to encompass its children.)

Ah.  That's a different issue.

ttk::panedwindow only honors geometry requests from slaves
if they are currently unmapped.  IIRC, the core panedwindow
works the same way.

I do not recall the exact details, but doing otherwise led to
erratic behavior when the user dragged the sash, especially
in combination with ill-behaved megawidgets.

> The behaviour I seek is this:> 1) Start with a two-pane panedwindow, with the top pane containing> widgets, and the bottom pane containing an empty frame. The initial> view should give all space to the top pane, with a sash at the bottom> of the window.>> 2) I pack a widget into the frame within the bottom pane.> I desire that the panedwindow will reconfigure to accommodate> the new space required in its bottom child frame. But this does not happen.

If you unmap and remap the pane after adding subwindows,
that will retrigger geometry propagation.

> [...]> Here is some sample code that exhibits the unexpected behaviour:> #!/usr/bin/env wish> ttk::style theme use clam; # To see the sash;> ttk::panedwindow .pw -orient vertical;> pack .pw;> .pw add [ttk::label .pw.l -text TOP -width 10] -weight 1;> .pw add [ttk::frame .pw.f -height 5] -weight 1;> # Force the GUI to update at this stage (without the> # next line, things will work);> update idletasks;> # Paned window clearly gives space to .pw.f;> pack [ttk::label .pw.l2 -text BOTTOM -width 10] -in .pw.f -expand true> -fill both;> # Here there is no change at all in the appearance. (.pw.l2 does not> become visible.)>> How do I force a geometry update for the panedwindow?

If you do:

    .pw forget .pw.f ; .pw add .pw.f

at this point, you should get the desired behaviour.

If the reconfigured pane isn't the last one, you'll need to
remember its position and use [.pw insert $pos ...] instead
of [.pw add ...].  (Unfortunately there's no hide/show command.)

Hope this helps,

--Joe English


Tcl-Core mailing list

Recent Messages in this Thread
Joe English Sep 11, 2015 11:04 pm
Sam Bromley Sep 12, 2015 01:17 am
Sam Bromley Sep 10, 2015 07:33 pm
Messages in this thread