Version 4 of ttk::panedwindow

Updated 2008-11-17 06:58:10 by hae

Ttk's panedwindow widget.

http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_panedwindow.htm

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...).


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
}

Demo code

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