Odd error when closing a window.



Hi,
I have a bit of long procedure (::tools::twic) which open a new window, amongst other thing. It has a 'Download' and a 'Cancel' button - see below. Closing the Window works fine, but if I hit the download button first, then try to hit Cancel, it generates an error.



proc ::tools::twic {} {
set w .twicWin
if {[winfo exists $w]} {
destroy .twicWin
set twicWin 0
return
}
set twicWin 1
toplevel $w
wm title $w [tr TitleDownloadFromTWIC]
wm minsize $w 25 10
bind $w <Destroy> {set .twicWin 0}
bind $w <F1> {helpWindow TWIC}

# Frame 1
set tf [frame $w.tf]
set txt [text $tf.txt -wrap word]
set yscroll [scrollbar $tf.yscroll -orient vertical -command [list $txt\
yview]]
$txt configure -yscrollcommand [list $yscroll set]
grid $txt -sticky news
grid $yscroll -column 1 -row 0 -sticky ns
grid rowconfigure $tf 0 -weight 1
grid columnconfigure $tf 0 -weight 1

$tf.txt tag configure h1 -font "helvetica 16" -underline on

$tf.txt tag configure h2 -font "helvetica 13" -justify "left" -underline on

$tf.txt tag configure normal -font "helvetica 10" -justify "left"\
-underline off

pack $tf

<snip>

button $b.close -text "Cancel -command { destroy .twicWin }
button $b.download -text "Download" -command {::tools::twic::download}

}

Hitting the 'Cancel' button closes things fine.

As you can see above, there is also a 'Dwonlaod' button, which when pressed calls ::tools::twic::download. That works fine.

proc ::tools::twic::download {} {
# There are no buttons in this procedure.
}


But if I
1) Hit the 'dwonload' button then
2) Hit the cancel button,

I get this:

invalid command name ".twicWin.tf.txt"
invalid command name ".twicWin.tf.txt"
while executing
".twicWin.tf.txt insert end "$ZIPFILE ( $ZIPFILESIZE b )\n""
(procedure "::tools::twic::download" line 156)
invoked from within
"::tools::twic::download"
invoked from within
".twicWin.b.download invoke"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke]"
(procedure "tk::ButtonUp" line 22)
invoked from within
"tk::ButtonUp .twicWin.b.download"
(command bound to event)


Any ideas?

If it helps, there are links to the complete files below.

http://chessdb.cvs.sourceforge.net/*checkout*/chessdb/chessdb/tcl/tools/twic.tcl?revision=1.20&content-type=text%2Fplain
http://chessdb.cvs.sourceforge.net/*checkout*/chessdb/chessdb/tcl/tools/download-twics.tcl?revision=1.2&content-type=text%2Fplain



--
Dave (from the UK)

Please note my email address changes periodically to avoid spam.
It is always of the form: month-year@xxxxxxxxxxxx
Hitting reply will work for a few months only - later set it manually.

http://chessdb.sourceforge.net/ - a Free open-source Chess Database
.