***Drawer Example*** [bll] 2016-5-23. A "Drawer" is a widget that slides in and out -- a pop-open task pane (reference [BOOK About Face] 4th edition pp 464). This is a simple example of an animated drawer using a paned window. ====== #!/usr/bin/tclsh package require Tk variable oldpos proc movesash { inc limit } { set sp [.x.p sashpos 0] incr sp $inc if { ($inc < 0 && $sp < $limit) || ($inc > 0 && $sp > $limit) } { set sp $limit .x.p sashpos 0 $sp return } .x.p sashpos 0 $sp after 15 movesash $inc $limit } proc doclose { w args } { variable oldpos set sp [.x.p sashpos 0] set oldpos $sp movesash -10 12 .x.cyan.sep.c configure -text "\u27eb\n\u27eb" bind .x.cyan.sep [list doopen %W] bind .x.cyan.sep.c [list doopen %W] } proc doopen { w args } { variable oldpos movesash 10 $oldpos .x.cyan.sep.c configure -text "\u27ea\n\u27ea" bind .x.cyan.sep [list doclose %W] bind .x.cyan.sep.c [list doclose %W] } wm withdraw . update frame .x wm manage .x ttk::style configure TPanedwindow \ -background lightblue ttk::style configure Sash -sashthickness 0 \ -handlesize 0 -handlepad 0 -sashpad 0 font create l font configure l -size 11 -weight bold ttk::panedwindow .x.p -orient horizontal -style TPanedwindow -height 200 pack .x.p -in .x -fill both -expand true frame .x.cyan -background cyan -height 200 -width 50 frame .x.cyan.sep -width 12 -relief flat -background lightblue pack .x.cyan.sep -in .x.cyan -padx 0 -pady 0 -side right -fill y -anchor e label .x.cyan.sep.c -background lightblue -foreground darkblue \ -text "\u27ea\n\u27ea" -font l pack .x.cyan.sep.c -in .x.cyan.sep -fill y -expand true ttk::button .x.cyan.a -text {Button 1} ttk::button .x.cyan.b -text {Button 2} ttk::button .x.cyan.c -text {Button 3} pack .x.cyan.a .x.cyan.b .x.cyan.c -in .x.cyan -side top -anchor nw frame .x.yellow -background yellow -height 200 -width 200 ttk::label .x.yellow.txt -text {This is frame two.} pack .x.yellow.txt -in .x.yellow -anchor ne .x.p add .x.cyan -weight 0 .x.p add .x.yellow -weight 1 set w [expr {[winfo reqwidth .x.cyan]+[winfo reqwidth .x.yellow]+12}] .x.p configure -width $w .x.p sashpos 0 [expr {[winfo reqwidth .x.cyan]+12}] bind .x.cyan.sep [list doclose %W] bind .x.cyan.sep.c [list doclose %W] wm protocol .x WM_DELETE_WINDOW exit ====== <>Widget