Mark msysGit as obsolete
[msysgit.git] / mingw / lib / tk8.5 / demos / ttkpane.tcl
bloba4d573890252728d16713b5724ddf83051b8bb91
1 # ttkpane.tcl --
3 # This demonstration script creates a Ttk pane with some content.
5 if {![info exists widgetDemo]} {
6 error "This script should be run from the \"widget\" demo."
9 package require Tk
10 package require Ttk
12 set w .ttkpane
13 catch {destroy $w}
14 toplevel $w
15 wm title $w "Themed Nested Panes"
16 wm iconname $w "ttkpane"
17 positionWindow $w
19 ttk::label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration shows off a nested set of themed paned windows. Their sizes can be changed by grabbing the area between each contained pane and dragging the divider."
20 pack $w.msg [ttk::separator $w.msgSep] -side top -fill x
22 ## See Code / Dismiss
23 pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
25 ttk::frame $w.f
26 pack $w.f -fill both -expand 1
27 set w $w.f
28 ttk::panedwindow $w.outer -orient horizontal
29 $w.outer add [ttk::panedwindow $w.outer.inLeft -orient vertical]
30 $w.outer add [ttk::panedwindow $w.outer.inRight -orient vertical]
31 $w.outer.inLeft add [ttk::labelframe $w.outer.inLeft.top -text Button]
32 $w.outer.inLeft add [ttk::labelframe $w.outer.inLeft.bot -text Clocks]
33 $w.outer.inRight add [ttk::labelframe $w.outer.inRight.top -text Progress]
34 $w.outer.inRight add [ttk::labelframe $w.outer.inRight.bot -text Text]
35 if {[tk windowingsystem] eq "aqua"} {
36 foreach i [list inLeft.top inLeft.bot inRight.top inRight.bot] {
37 $w.outer.$i configure -padding 3
41 # Fill the button pane
42 ttk::button $w.outer.inLeft.top.b -text "Press Me" -command {
43 tk_messageBox -type ok -icon info -message "Ouch!" -detail "That hurt..." \
44 -parent .ttkpane -title "Button Pressed"
46 pack $w.outer.inLeft.top.b -padx 2 -pady 5
48 # Fill the clocks pane
49 set i 0
50 proc every {delay script} {
51 uplevel #0 $script
52 after $delay [list every $delay $script]
54 set zones {
55 :Europe/Berlin
56 :America/Argentina/Buenos_Aires
57 :Africa/Johannesburg
58 :Europe/London
59 :America/Los_Angeles
60 :Europe/Moscow
61 :America/New_York
62 :Asia/Singapore
63 :Australia/Sydney
64 :Asia/Tokyo
66 # Force a pre-load of all the timezones needed; otherwise can end up
67 # poor-looking synch problems!
68 foreach zone $zones {clock format 0 -timezone $zone}
69 foreach zone $zones {
70 set city [string map {_ " "} [regexp -inline {[^/]+$} $zone]]
71 if {$i} {
72 pack [ttk::separator $w.outer.inLeft.bot.s$i] -fill x
74 ttk::label $w.outer.inLeft.bot.l$i -text $city -anchor w
75 ttk::label $w.outer.inLeft.bot.t$i -textvariable time($zone) -anchor w
76 pack $w.outer.inLeft.bot.l$i $w.outer.inLeft.bot.t$i -fill x
77 every 1000 "set time($zone) \[clock format \[clock seconds\] -timezone $zone -format %T\]"
78 incr i
81 # Fill the progress pane
82 ttk::progressbar $w.outer.inRight.top.progress -mode indeterminate
83 pack $w.outer.inRight.top.progress -fill both -expand 1
84 $w.outer.inRight.top.progress start
86 # Fill the text pane
87 if {[tk windowingsystem] ne "aqua"} {
88 # The trick with the ttk::frame makes the text widget look like it fits with
89 # the current Ttk theme despite not being a themed widget itself. It is done
90 # by styling the frame like an entry, turning off the border in the text
91 # widget, and putting the text widget in the frame with enough space to allow
92 # the surrounding border to show through (2 pixels seems to be enough).
93 ttk::frame $w.outer.inRight.bot.f -style TEntry
94 text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0
95 pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot.f -pady 2 -padx 2
96 ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview"
97 pack $w.sb -side right -fill y -in $w.outer.inRight.bot
98 pack $w.outer.inRight.bot.f -fill both -expand 1
99 pack $w.outer -fill both -expand 1
100 } else {
101 text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0
102 scrollbar $w.sb -orient vertical -command "$w.txt yview"
103 pack $w.sb -side right -fill y -in $w.outer.inRight.bot
104 pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot
105 pack $w.outer -fill both -expand 1 -padx 10 -pady {6 10}