dialog
TCL/TK UseCase1
Abstract : Contains the dialog boxes used through out the program.
Comments : Pay close attention to the way in which the save and
open works. Most of the code is reused for both
functions and for the different type of saves.
proc nextcord {words} {
global passx
global passy
toplevel .asking
wm transient .asking .
message .asking.t -relief raised -background gray \
-width 150 -text $words
pack .asking.t -fill x
bind .area {set passx %x ; set passy %y ; destroy .asking}
update idletask
grab set .
tkwait window .asking
bind .area {whattodo %x %y}
}
proc ask {words} {
toplevel .asking
wm transient .asking .
message .asking.t -relief raised -background gray \
-width 150 -text $words
button .asking.b -text "Okay" -background red\
-command "destroy .asking"
pack .asking.t .asking.b -fill x
update idletask
grab .asking
tkwait window .asking
}
proc asklabel {words} {
global name
set name ""
toplevel .asking
wm transient .asking .
message .asking.t -relief raised -background gray \
-width 150 -text $words
entry .asking.name -background green -textvariable name
button .asking.b -text "Enter" -background red \
-command "destroy .asking"
button .asking.b2 -text "Cancel" -background red \
-command {set name "" ; destroy .asking}
pack .asking.t .asking.name -fill x
pack .asking.b .asking.b2 -side right -padx 1m -pady 1m
bind .asking.name {destroy .asking}
update idletask
grab .asking
tkwait window .asking
}
proc openfile {} {
toplevel .fs
wm title .fs "Select File:"
listbox .fs.files -relief raised -borderwidth 2 \
-yscrollcommand ".fs.scroll set"
tk_listboxSingleSelect .fs.files
scrollbar .fs.scroll -command ".fs.files yview"
button .fs.cancel -text {Cancel} -command {destroy .fs}
pack .fs.cancel -side bottom -fill x
pack .fs.scroll -side right -fill y
pack .fs.files -side left
foreach f [lsort [glob * *.*]] {.fs.files insert end $f}
bind .fs.files {
set filename [selection get]
#C++ call here!!!
global iGraph
# $iGraph g_delete:
set n [$iGraph cppOpenCD: $filename]
puts "Open & Draws returns $n"
# In case I would have to draw the stuff...
# $iGraph (insert PP call here...)
destroy .fs
}
}