|
From: Donal K. F. <don...@ma...> - 2004-10-25 08:13:58
|
Kevin Walzer wrote: > You were kind enough last month to provide the sample code above to help > me get started with the Tile progress bar widget. I've tweaked the code > for use in the application I'm working on and it works > beautifully...except that I don't know how to back out of the loop I've > set up. It cycles for an indefinite period of time (which is exactly > what I wanted it to do :-)). Destroying the window containing the > progress bar doesn't help because the every and update procedures are > still chugging in memory, and I get error messages that loop at the same > frequency of the code. And I've looked for a way to kill the procedure > itself, by using after cancel, but nothing seems to work. Can you give > me any direction in *closing* the loop? Thank you so much. OK, you need a cancel-able [every]. :^) Once you've got this though, it's easy to add a <Destroy> binding to clean things up. Here's some code (it's also on the wiki at http://wiki.tcl.tk/every of course.) proc every {ms body} { global everyId if {$ms eq "cancel"} { after cancel $everyId($body) unset everyId($body) } else { set everyId($body) [after $ms [info level 0]] uplevel #0 $body } } every 250 {Update .p 10} bind .p <Destroy> {every cancel {Update .p 10}} I'm sure this sort of thing could be improved upon fairly easily, but it should at least inspire... Donal. |