Version 15 of ttk::panedwindow

Updated 2015-09-10 13:51:25 by SPB

[ttk::panedwindow ] creates and manipulates ttk paned window widgets.

See Also

paned window

Documentation

official reference

description

SPB 2015-09-14: I wish to have the "-stretch last" or "-stretch never" behaviour of tk::panedwindow, but I cannot figure out how one might do that with ttk::panedwindow. Any suggestions? (My specific problem is that I have a frame F backed into the bottom pane of my panedwindow, that I wish to always take up solely the space of the frame, unless the user moves the sash. Setting the weight to 0 fails, as the pane acquires no space at all and the frame F remains invisible when added to the PW. Setting non-zero weights causes extra (empty) space to become proportionally allocated to F, when I don't want it to get any extra space at all.) Is there a way to have a pane of a ttk::panedwindow to allocate the space of the frame it contains, but no more than that? Thank you!

WHD 2010-04-14: Is there a way to get a list of the names of the managed subwindows in index order? I can refer to managed subwindows from 0 to end, but I don't see any way in the interface to determine how many managed windows there are, nor the order in which they are stacked. winfo children returns the children of the panedwindow in the order of creation, which can be very different.

MG: The ttk::panedwindow has some undocumented subcommands, the one you want is $panedWindow panes:

(bin) 1 % pack [ttk::panedwindow .pw]
(bin) 2 % .pw foobar
bad command "foobar": must be add, configure, cget, forget, identify, insert, instate, pane, panes, sashpos, or state
(bin) 3 % set tcl_patchLevel
8.5.7

$panedWindow panes                            ;# returns a list of all widgets being used as panes, in order
$panedWindow add $widget [-option value ...]  ;# seems to be an alias for $panedWindow insert end $widget [-option value ...]

MHo 2008-04-09: Does someone know if and how it's possible to determine the dimension of a pane inside a panedwindow? I have a canvas inside a pane that holds an image. If resizing / maximizing the top-level windows, everything should grow to use the extra space. But the pane itself says it is has the dimension 1x1, and the canvas stays as its initial size (if I don't specify such initial size, something else goes wrong that is beyond the scope of this question...).

MG: I've noticed with this (and other Tile widgets) in Windows / Tk 8.5 that there's a delay before sizes and things fully update - calling update and/or update idletasks doesn't resolve the problem. I've had to resort to doing something like

$widget add $foo
after 25 [list doStuffWith $widget]

to give the widgets time to update their sizes and report the correct ones back. See if that resolves the problem? In your case, winfo width and winfo height on the canvas may work, too?

Create a Custom Sash Handle bar

In the default theme the sash handle bar is empty. So it is not obvious that it is a panedwindow. This little piece of code creates a new style for the panedwindow which as a Firefox-like sash handle bar.

image create photo img:sash -data {
R0lGODlhBQB5AKECADMzM9TQyP///////yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAMALAAA
AAAFAHkAAAJOjA95y+0LUAxpUkufboLh1UFPiIyeKTqk8R1rpp5xysk1zbytoaPl/LsFczYiDlRE
Hl1J5pLXhD4DPSDLd7XChFnudgO2KC5izA6sqTQKADs=
}

ttk::style element create Sash.xsash image \
        [list img:sash ] \
        -border {1 1} -sticky ew -padding {1 1}

ttk::style layout TPanedwindow {
        Sash.xsash
}

Example

package require Ttk

# ttk::setTheme clam

set xf [ttk::frame .f]
set pw [ttk::panedwindow .f.pw -orient horizontal ]

ttk::frame $pw.f1
ttk::label $pw.f1.l -text "Frame 1"
pack $pw.f1.l

ttk::frame $pw.f2
ttk::label $pw.f2.l -text "Frame 2"
pack $pw.f2.l

$pw add $pw.f1
$pw add $pw.f2

pack $pw -expand 1 -fill both
pack $xf -expand 1 -fill both