home *** CD-ROM | disk | FTP | other *** search
Wrap
# Determine whether a file name is in the PATH # Return value is: # 1: no # 0: yes proc Shell_DoesBinaryExist {progname} { return [catch {exec {which} $progname}] } # Prompts the user if a binary is not found # Return value is: # "": the binary has not been found # the binary name if it has been found proc Shell_DoesBinaryExist_Prompt {progname} { while {[Shell_DoesBinaryExist $progname]} { global db toplevel .shell wm title .shell "Program Finder" frame .shell.even pack .shell.even -fill both -expand 1 -padx 4 -pady 4 message .shell.even.msg -width 15c -text "The wizard is unable to find the \"$progname\" program on your machine. Please specify the full path to this program." pack .shell.even.msg -fill y -expand 1 -padx 4 -pady 4 frame .shell.even.even pack .shell.even.even -fill both frame .shell.even.even2 pack .shell.even.even2 label .shell.even.even.lbl -text "Location:" -underline 0 bind .shell <Alt-KeyPress-l> _Shell_Location pack .shell.even.even.lbl -anchor e -side left -padx 4 -pady 4 entry .shell.even.even.entry -textvariable db(.shell._entry) pack .shell.even.even.entry -side left -padx 4 -pady 4 -fill x -expand 1 set db(.shell._entry) $progname button .shell.even.even.browse -text "Browse ..." -underline 0 -command _Shell_Browse bind .shell <Alt-KeyPress-b> _Shell_Browse pack .shell.even.even.browse -side left -padx 4 -pady 4 button .shell.even.even2.cancel -text "Cancel" -underline 0 -command _Shell_Cancel bind .shell <Alt-KeyPress-c> _Shell_Cancel pack .shell.even.even2.cancel -side right -padx 4 -pady 4 button .shell.even.even2.ok -text "Ok" -underline 0 -default active -command _Shell_Ok bind .shell <Alt-KeyPress-o> _Shell_Ok bind .shell <KeyPress-Return> _Shell_Ok pack .shell.even.even2.ok -side right -padx 4 -pady 4 _Shell_Location set db(.shell.progname) "" tkwait window .shell if {$db(.shell.progname) == ""} { # Cancel return "" } # Ok set progname $db(.shell.progname) } return $progname; } # Callback for the location accelerator proc _Shell_Location {} { focus .shell.even.even.entry } # Callback for the browse button proc _Shell_Browse {} { global db # Pop-up a file chooser set res [tk_getOpenFile -parent .shell.even.even.browse -title {Program Chooser}] if {$res != ""} { # Patch the entry box set db(.shell._entry) $res # Position its cursor at the end .shell.even.even.entry icursor [string length $res] } } # Callback for the cancel button proc _Shell_Cancel {} { # Dismiss the window destroy .shell } # Callback for the ok button proc _Shell_Ok {} { global db set db(.shell.progname) $db(.shell._entry) # Dismiss the window destroy .shell }