3 # This demonstration script creates a toplevel window containing
4 # a paned window that separates two windows vertically.
6 if {![info exists widgetDemo]} {
7 error "This script should be run from the \"widget\" demo."
15 wm title $w "Vertical Paned Window Demonstration"
16 wm iconname $w "paned2"
19 label $w.msg -font $font -wraplength 4i -justify left -text "The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)"
22 ## See Code / Dismiss buttons
23 set btns [addSeeDismiss $w.buttons $w]
24 pack $btns -side bottom -fill x
26 # Create the pane itself
27 panedwindow $w.pane -orient vertical
28 pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m
30 # The top window is a listbox with scrollbar
52 set f [frame $w.pane.top]
53 listbox $f.list -listvariable paneList -yscrollcommand "$f.scr set"
54 # Invert the first item to highlight it
55 $f.list itemconfigure 0 \
56 -background [$f.list cget -fg] -foreground [$f.list cget -bg]
57 ttk::scrollbar $f.scr -orient vertical -command "$f.list yview"
58 pack $f.scr -side right -fill y
59 pack $f.list -fill both -expand 1
61 # The bottom window is a text widget with scrollbar
62 set f [frame $w.pane.bottom]
63 text $f.text -xscrollcommand "$f.xscr set" -yscrollcommand "$f.yscr set" \
64 -width 30 -height 8 -wrap none
65 ttk::scrollbar $f.xscr -orient horizontal -command "$f.text xview"
66 ttk::scrollbar $f.yscr -orient vertical -command "$f.text yview"
67 grid $f.text $f.yscr -sticky nsew
68 grid $f.xscr -sticky nsew
69 grid columnconfigure $f 0 -weight 1
70 grid rowconfigure $f 0 -weight 1
71 $f.text insert 1.0 "This is just a normal text widget"
73 # Now add our contents to the paned window
74 $w.pane add $w.pane.top $w.pane.bottom