/usr/share/blt2.4/demos/bgexec4.tcl is in blt-demo 2.4z-7ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | #!/usr/bin/wish
package require BLT
# --------------------------------------------------------------------------
# Starting with Tcl 8.x, the BLT commands are stored in their own
# namespace called "blt". The idea is to prevent name clashes with
# Tcl commands and variables from other packages, such as a "table"
# command in two different packages.
#
# You can access the BLT commands in a couple of ways. You can prefix
# all the BLT commands with the namespace qualifier "blt::"
#
# blt::graph .g
# blt::table . .g -resize both
#
# or you can import all the command into the global namespace.
#
# namespace import blt::*
# graph .g
# table . .g -resize both
#
# --------------------------------------------------------------------------
if { $tcl_version >= 8.0 } {
namespace import blt::*
namespace import -force blt::tile::*
}
source scripts/demo.tcl
source scripts/globe.tcl
option add *HighlightThickness 0
set program ../src/bltwish
if { [info exists tcl_platform ] } {
puts stderr $tcl_platform(platform)
if { $tcl_platform(platform) == "windows" } {
set shells [glob C:/Program\ Files/Tcl/bin/tclsh8*.exe ]
set program [lindex $shells 0]
}
}
if { ![file executable $program] } {
error "Can't execute $program"
}
set command [list $program scripts/bgtest.tcl]
array set animate {
index -1
interval 200
colors "#ff8813 #ffaa13 #ffcc13 #ffff13 #ffcc13 #ffaa13 #ff8813"
numBitmaps 30
prefix globe
}
proc Animate {} {
global animate
if { [info commands .logo] != ".logo" } {
set animate(index) 0
return
}
if { $animate(index) >= 0 } {
.logo configure -bitmap $animate(prefix).$animate(index)
incr animate(index)
if { $animate(index) >= $animate(numBitmaps) } {
set animate(index) 0
}
after $animate(interval) Animate
}
}
proc InsertText { string tag } {
.text insert end "$tag: " "" $string $tag
set textlen [expr int([.text index end])]
scan [.vscroll get] "%s %s %s %s" total window first last
if { $textlen > $total } {
.text yview [expr $textlen-$window]
}
update idletasks
}
proc DisplayOutput { name1 name2 how } {
upvar #0 $name1 arr
InsertText "$arr($name2)\n" stdout
set arr($name2) {}
}
proc DisplayErrors { name1 name2 how } {
upvar #0 $name1 arr
InsertText "$arr($name2)\n" stderr
set arr($name2) {}
}
option add *text.yScrollCommand { .vscroll set }
option add *text.relief sunken
option add *text.width 20
option add *text.height 10
option add *text.height 10
option add *text.borderWidth 2
option add *vscroll.command { .text yview }
option add *vscroll.minSlider 4p
option add *stop.command { set results {} }
option add *stop.text { stop }
option add *logo.padX 4
option add *title.text "Catching stdout and stderr"
option add *title.font -*-Helvetica-Bold-R-*-*-14-*-*-*-*-*-*-*
set visual [winfo screenvisual .]
if { [string match *color $visual] } {
option add *text.background white
option add *text.foreground blue
option add *stop.background yellow
option add *stop.activeBackground yellow2
option add *stop.foreground navyblue
option add *start.activeBackground green2
option add *start.background green
option add *start.foreground navyblue
option add *logo.background beige
option add *logo.foreground brown
option add *logo.foreground green4
option add *title.background lightblue
option add *logo.background lightblue
}
. configure -bg lightblue
trace variable results(stdout) w DisplayOutput
trace variable results(stderr) w DisplayErrors
proc Start { command } {
global results animate
.text delete 1.0 end
if { $animate(index) < 0 } {
set results(status) {}
eval "bgexec results(status) -lasterror results(stderr) \
-lastoutput results(stdout) $command &"
set animate(index) 0
Animate
}
}
proc Stop { } {
global results animate
set results(status) {}
set animate(index) -1
}
# Create widgets
text .text
.text tag configure stdout -font -*-Helvetica-Bold-R-*-*-18-*-*-*-*-*-*-* \
-foreground green2
.text tag configure stderr -font -*-Helvetica-Medium-O-*-*-18-*-*-*-*-*-*-* \
-foreground red2
scrollbar .vscroll
button .start -text "Start" -command [list Start $command]
button .stop -text "Stop" -command Stop
label .logo -bitmap globe.0
label .title
# Layout widgets in table
table . \
.title 0,0 -columnspan 4 \
.text 1,0 -columnspan 3 \
.vscroll 1,3 -fill y \
.logo 2,0 -anchor w -padx 10 -reqheight .6i -pady 4 \
.start 2,1 \
.stop 2,2
set buttonWidth 1i
table configure . c1 c2 -width 1i
table configure . c3 r0 r2 -resize none
table configure . .start .stop -reqwidth $buttonWidth -anchor e
table configure . .title .text -fill both
wm min . 0 0
|