1 #!/home/people/tkys/Eos/util/I386LINUX/bin/bltwish
7 # Script to test the "busy" command.
11 # General widget class resource attributes
13 option add *Button.padX 10
14 option add *Button.padY 2
15 option add *Scale.relief sunken
16 #option add *Scale.orient horizontal
17 option add *Entry.relief sunken
18 option add *Frame.borderWidth 2
20 set visual [winfo screenvisual .]
21 if { $visual == "staticgray" || $visual == "grayscale" } {
26 option add *top.background white
29 set normalBg springgreen
32 option add *Button.background khaki2
33 option add *Button.activeBackground khaki1
34 option add *Frame.background khaki2
35 option add *bottom.tile textureBg
36 # option add *Button.tile textureBg
38 option add *releaseButton.background limegreen
39 option add *releaseButton.activeBackground springgreen
40 option add *releaseButton.foreground black
42 option add *holdButton.background red
43 option add *holdButton.activeBackground pink
44 option add *holdButton.foreground black
45 option add *top.background springgreen
49 # Instance specific widget options
51 option add *top.relief sunken
52 option add *top.background $normalBg
53 option add *testButton.text "Test"
54 option add *quitButton.text "Quit"
55 option add *newButton.text "New button"
56 option add *holdButton.text "Hold"
57 option add *releaseButton.text "Release"
58 option add *buttonLabel.text "Buttons"
59 option add *entryLabel.text "Entries"
60 option add *scaleLabel.text "Scales"
61 option add *textLabel.text "Text"
63 if { $tk_version >= 4.0 } {
69 # We have to do it this way because of Tk insists upon
70 # propagating events from toplevels to their children.
71 # This seems like way too much of hack just to handle
72 # keyboard accelerators.
74 bind keep-raised <Visibility> {
78 bindtags $w keep-raised
80 set file ./images/chalk.gif
81 image create photo textureBg -file $file
95 # This never gets used; it's reset by the Animate proc. It's
96 # here to just demonstrate how to set busy window options via
97 # the host window path name
99 option add *top.busyCursor bogosity
102 # Initialize a list bitmap file names which make up the animated
103 # fish cursor. The bitmap mask files have a "m" appended to them.
105 set bitmaps { fc_left fc_left1 fc_mid fc_right1 fc_right }
108 # Counter for new buttons created by the "New button" button
113 # Create two frames. The top frame will be the host window for the
114 # busy window. It'll contain widgets to test the effectiveness of
115 # the busy window. The bottom frame will contain buttons to
116 # control the testing.
122 # Create some widgets to test the busy window and its cursor
125 button .testButton -command {
126 puts stdout "Not busy."
128 button .quitButton -command { exit }
131 text .text -width 20 -height 4
134 # The following buttons sit in the lower frame to control the demo
136 button .newButton -command {
139 set name button#${numWin}
140 button .top.$name -text "$name" \
141 -command [list .top configure -bg blue]
143 .top.$name $numWin+3,0 -padx 10 -pady 10
146 button .holdButton -command {
147 if { [busy isbusy .top] == "" } {
149 .top configure -bg $activeBg
154 button .releaseButton -command {
155 if { [busy isbusy .top] == ".top" } {
159 .top configure -bg $normalBg
163 # Notice that the widgets packed in .top and .bottom are not their children
169 .text 1,1 -fill both \
170 .quitButton 2,0 -cspan 2
177 table configure .top \
178 .testButton .scale .entry .quitButton -padx 10 -pady 10
179 table configure .bottom \
180 .newButton .holdButton .releaseButton -padx 10 -pady 10
183 # Finally, realize and map the top level window
189 table configure . .bottom -fill both
191 # Initialize a list of bitmap file names which make up the animated
192 # fish cursor. The bitmap mask files have a "m" appended to them.
195 fc_left fc_left1 fc_mid fc_right1 fc_right
199 # Simple cursor animation routine: Uses the "after" command to
200 # circulate through a list of cursors every 0.075 seconds. The
201 # first pass through the cursor list may appear sluggish because
202 # the bitmaps have to be read from the disk. Tk's cursor cache
203 # takes care of it afterwards.
205 proc StartAnimation { widget count } {
207 set name [lindex $bitmapList $count]
208 set cursor [list @bitmaps/$name bitmaps/${name}m blue green ]
209 catch { busy configure $widget -cursor $cursor }
212 if { $count >= [llength $bitmapList] } {
216 set afterId($widget) [after 125 StartAnimation $widget $count]
219 proc StopAnimation { widget } {
221 after cancel $afterId($widget)
224 proc TranslateBusy { window } {
225 set widget [string trimright $window "_Busy"]
226 if { $widget != "." } {
227 set widget [string trimright $widget "."]
234 StartAnimation [TranslateBusy %W] 0
238 StopAnimation [TranslateBusy %W]
242 # For testing purposes allow the top level window to be resized
247 # Force the demo to stay raised