10 catch {
exec which bimg} result
11 set bsoftbin [
file dirname $result]
13 eval destroy [
winfo child .]
14 wm title . "Bsoft program interface"
15 set font {Helvetica 14}
16 set bigfont {Helvetica 24}
17 set smallfont {Helvetica 10}
22 set Bsoft [
exec printenv BSOFT]
23 if { [
string length $Bsoft] < 2 } {
24 set Bsoft /usr/local/bsoft
26 set bshow_script $Bsoft/tcltk
27 set bshow_lib $Bsoft/lib
32 source $bshow_script/show_info.tcl
36 proc executecommand { } {
38 set p [
lindex $thecmd 0]
39 if [
file executable $p] {
40 puts "Executing: $thecmd"
41 catch "
exec $thecmd" result
54 set name [
tk_getOpenFile]
56 .file.$i.name delete 0 end
57 .file.$i.name insert 0 $name
65 proc constructcmd { } {
66 set cmd [
lindex [.cmd get] 0]
67 foreach opt [.opt.list cget -text] {
68 upvar [.opt.$opt.label cget -variable] on
70 append cmd " " $opt " " [.opt.$opt.e1 get]
73 foreach i [.file.list cget -text] {
74 upvar [.file.$i.label cget -variable] on
76 append cmd " " [.file.$i.name get]
88 proc select_program { p } {
98 if { [
string first "brun" $p] > -1 } {
return}
100 if ![
file executable [
lindex $p 0]] {
return}
107 text .t -relief sunken -bd 2 -setgrid 1 -height 30
108 pack .t -expand yes -fill both
109 catch {
exec $p} result
110 .t insert 0.0 $result
113 set ib [ .t search -nocase "usage" $ib end]
114 set use [ .t get "$ib linestart" "$ib lineend"]
115 label .usage -font $font -justify left -text $use
116 pack .usage -side top -pady 2
122 set use [
string range $use [
string first " " $use] [
string length $use]]
123 set use [
string trimleft $use]
124 set use [
string range $use [
string first " " $use] [
string length $use]]
127 set ind [
string first "\]" $use]
128 if { $ind < 0 } {
set ind 0}
131 set use [
string range $use [
expr $ind + 1] [
string length $use]]
132 set use [
string trimleft $use]
133 if { $use < " " } { break}
134 set ind [
string first " " $use]
135 if { $ind < 0 } {
set ind [
string length $use]}
136 set f [
string range $use 0 [
expr $ind-1]]
138 checkbutton .file.$i.label -text "$f" -variable $f -relief flat \
139 -command "constructcmd"
140 .file.$i.label deselect
141 entry .file.$i.name -width 50
142 button .file.$i.button -text "Browse ..." -command "getfile $i"
143 pack .file.$i.label .file.$i.name .file.$i.button -side left -pady 1 -padx 4
144 pack .file.$i -side top -fill x
148 label .file.list -text $flist
149 if { $i > 1 } {
pack .file -side top -pady 2}
152 label .opt.head -font $font -justify left -text "Options:"
153 pack .opt.head -side top -fill x -expand 1
157 set ib [ .t search -regexp -- {^\-[A-Za-z]} "$ib +2 chars" end]
158 if { $ib == "" } { break}
159 set iv [.t search " " "$ib" "$ib lineend"]
160 set b [.t get $ib $iv]
161 set idesc [.t search " " "$iv +1 chars" "$ib lineend"]
162 set v [.t get "$iv +1 chars" $idesc]
163 set idesc [ .t search -regexp -- {[A-Za-z]} "$idesc +1 chars" "$idesc lineend"]
164 set d [.t get "$idesc wordstart" "$idesc lineend"]
166 label .opt.$b.descr -font $smallfont -justify left -text $d
167 entry .opt.$b.e1 -width [
string length $v]
168 checkbutton .opt.$b.label -text "$b" -variable $b -relief flat \
169 -command "constructcmd"
170 .opt.$b.label deselect
172 .opt.$b.e1 insert 0 $v
173 pack .opt.$b.label .opt.$b.e1 .opt.$b.descr -side left -pady 1 -padx 4
175 .opt.$b.e1 insert 0 ""
176 pack .opt.$b.label .opt.$b.descr -side left -pady 1 -padx 4
178 pack .opt.$b -side top -fill x
181 label .opt.list -text $olist
182 pack .opt -side left -pady 2
187 entry .cmd -width 100
188 .cmd insert 0 "Select a program and fill in the options"
189 pack .cmd -side top -fill x -expand 1
192 pack .buttons -side top -fill x -pady 2m
193 menubutton .buttons.program -text "Program" -underline 0 -direction below \
194 -menu .buttons.program.m -relief raised -width 20
195 menu .buttons.program.m -tearoff 0
196 set file_list [lsort [glob [
file join $bsoftbin/*]]]
197 foreach p [
split $file_list] {
198 set prog [
file tail $p]
199 if { [
file executable $p] && [
file isfile $p] } {
200 .buttons.program.m add command -label $prog -command "select_program $p"
203 button .buttons.run -text Execute -command executecommand
204 button .buttons.dismiss -text Dismiss -command "destroy ."
205 pack .buttons.program .buttons.run .buttons.dismiss -side left -expand 1
208 label .file.list -text ""
210 label .opt.list -text ""