panedwindow

[panedwindow ] creates and manipulates paned window widgets

Also called tk::panedwindow in Tk 8.5.

See Also

paned window
ttk::panedwindow
Custom sash handle for panedwindow

Documentation

TIP 41 , Paned Window Tk Widget
official reference

Description

Examples

Ro: I always find that I need some examples to get started with a widget. So here is a simple example that should get you started with the panedwindow from Tk 8.4 (be sure to check out the man page [L1 ] for details)

package require Tk 8.4
panedwindow .pw -orient vertical
label .pw.x1 -text Bapy -fg orange -bg black
label .pw.x2 -text Mojo -fg white  -bg red
.pw add .pw.x1 -minsize 200
.pw add .pw.x2 -minsize 100
pack .pw -fill both -expand yes

Maximize the window to see how you can alter the sizes of the panes, while respecting the minsize that was chosen by the config option -minsize .

The widgets that you add to the panedwindow MUST be children of the panedwindow, in this case they must be .pw.something .

On windows, mouse-button-1 resizes the panes once you let go of the sash, whereas mouse-button-2 resizes the panes as you move the sash.


TR - No, the widgets to add to panedwindow must NOT be children of the pane itself (at least it does not say so in the man page). This version work perectly fine:

panedwindow .pw -orient vertical
label .x1 -text Bapy -fg orange -bg black
label .x2 -text Mojo -fg white  -bg red
.pw add .x1 -minsize 200
.pw add .x2 -minsize 100
pack .pw -fill both -expand yes

BUT, the order of window generation is apparently important. This version, where the pane is created after the labels, does NOT work:

label .x1 -text Bapy -fg orange -bg black
label .x2 -text Mojo -fg white  -bg red
panedwindow .pw -orient vertical
.pw add .x1 -minsize 200
.pw add .x2 -minsize 100
pack .pw -fill both -expand yes

The pane will be visible but the labels won't.

LV: Could this be due to stacking order?

Misc


RS 2006-01-29: Hacking a Tk panedwindow with eTcl on my phone, I wasn't sure whether to arrange panes horizontally or vertically. Well, thought I, let the user decide - took me 4 lines of code, plus the demo below. Right-click on the sash to toggle:

proc toggle'orientation w {
    $w config -ori [expr {[$w cget -ori] eq "horizontal"? "vert": "hori"}]
}

#-- Demo and usage example:

pack [panedwindow .p]
.p add [label .p.1 -text Hello]
.p add [label .p.2 -text world]
bind .p <3> {toggle'orientation %W}

Some options and commands are about "proxy", what it means?

MG answered 2018-03-02 on c.l.t.:

By default, when you click and drag the sash to resize the panes, the resize happens in real-time.

If you set -opaqueresize to 0, it instead shows a 'ghost' version of the sash, to show you where it will be resized to, and the resize doesn't happen until you release the mouse button. The guide line to show where you're dragging the sash to is the proxy.

By default you wouldn't need to use the proxy subcommand, but if you impliment your own custom bindings you may want to.