Re: Odd error when closing a window.



Donald Arseneau wrote:
"Dave (from the UK)" <see-my-signature@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:


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 {} {

... blah blah blah ... nothing relevant


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


Ha ha, hiding anything that is relevant to the problem.


Well, not exactly hiding, as I did provide a link to the *full* code.

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

But I did not think that bit was too relevant - obviously it was.


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""


Of course the good proc to show is what contains this command.

I presume it is the download proc that keeps chugging along,
even while you click the cancel button.

Yes, that is it.

You need to put a test in there, allowing the cancel button to actually cancel the procedure. You could have some global variable \
as a flag, but it makes sense to just look for the gui widgets,
like

if { ![winfo exists .twicWin.tf.txt] } {
# cancelled or closed. Abort what we were doing and disappear.
}


I'm still not convinced I know how best to solve it, as cancelling the download might be a problem - the idea of the cancel button was in case that stalled for some reason. But knowing what is causing the problem is obviously a huge help to finding a solution.

Cheers.

--
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
.