Nesting behvior of tkwait
- From: "Dave Dean" <dave.dean@xxxxxxxxxx>
- Date: Wed, 27 Sep 2006 15:38:11 -0700
Hi all,
I'm concerned about some potential pitfalls I might run into using the
tkwait command. It seems like a very useful command, especially the "tkwait
variable" option. However, I'm wondering if it's dangerous to use "tkwait
variable" inside a procedure called by a binding. I tried this little
experiment:
button .button1 -text "1" -command "waitVar 1"
button .button2 -text "2" -command "waitVar 2"
button .continue -text "CONTINUE" -command "incr cont"
text .text -height 1m
pack .text -side bottom
pack .continue .button2 .button1 -side bottom -fill x
set var1 0; set var2 0; set cont 0
proc waitVar {num} {
tkwait variable cont
.text insert end $num
}
When run, this seems to allow a queue of commands to be built up. If press
"1" three times, I get three 1's when I press continue. If I press "1212"
then continue, I get "2121" in the text box. This is the behavior I'd
expect (I think).
Now, If I change the proc to the following:
proc waitVar {num} {
set cont $num
tkwait variable cont
.text insert end $num
}
If I press "111", I'd expect to get this displayed in the text box when I
press "2". It seems that pressing "2" would cause "cont" to change, which
should trigger the "tkwait variable" statements, and allow the "111" to be
displayed. Why does this not seem to be the case? My only hunch is that,
even though "cont" has been updated, the whole thing won't trigger until the
process that updates "cont" exits. If that's the case, is there any way to
force the triggering?
Thanks,
Dave
.
- Follow-Ups:
- Re: Nesting behvior of tkwait
- From: Donald Arseneau
- Re: Nesting behvior of tkwait
- From: Bruce Hartweg
- Re: Nesting behvior of tkwait
- Prev by Date: Re: no irc in tcllib?
- Next by Date: Re: Why no central repository for tcl extensions?
- Previous by thread: no irc in tcllib?
- Next by thread: Re: Nesting behvior of tkwait
- Index(es):