Re: TK scope "can't read . . . no such variable"
- From: Bryan Oakley <oakley@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 22 Sep 2006 13:33:19 GMT
Lionel wrote:
Donald Arseneau wrote:
-command [$base.clientarea.browseinstalled configure -state disabled]
That should surely be
-command [list $base.clientarea.browseinstalled configure -state disabled]
OK. This is a bit confusing to me. What does list do in this case? It seems to be used in strange situations . . . for a Java programmer anyway :). But, what you said fixed the problem.
List gives a canonical form for the -command, guaranteeing that each argument remains a distinct tcl word when the command runs. In this specific case, assuming that the contents of $base does not contain any spaces or other special characters, it is effectively a no-op. Still, it's a good habit to always create -command arguments this way.
See http://www.tclscripting.com/articles/apr06/article3.html for for an article on this very subject.
(or -command {$base.clientarea.browseinstalled configure -state disabled}
if you want to delay substituting the value of $base.)
I was reading about this substituting the value at a later time. I can only vaguely recall it now. What does it all mean? I tell you one thing, when I do it this way I get the error "Error: can't read "base": no such variable". This is obviously where I'm coming unstuck.
The reason is, commands tied to a -command option run in a different scope then where the command is defined. $base is valid in the scope where you define the -command but it is not valid in the scope where the command is run. And since you use curly braces, that in hibits the evaluation of $base at the time the command is defined. Thus, $base gets substituted when the command actually runs.
the following location:" -command [list disableNext]
But you have no reason for a [list ] there.
.... except for the notion that it's a 'best practice' even in cases where it's a no-op. Strictly speaking though, it's not required.
.
- Follow-Ups:
- Re: TK scope "can't read . . . no such variable"
- From: lionelv
- Re: TK scope "can't read . . . no such variable"
- References:
- TK scope "can't read . . . no such variable"
- From: lionelv
- Re: TK scope "can't read . . . no such variable"
- From: Donald Arseneau
- Re: TK scope "can't read . . . no such variable"
- From: Lionel
- TK scope "can't read . . . no such variable"
- Prev by Date: Re: Tile image-only button size
- Next by Date: Re: Tile image-only button size
- Previous by thread: Re: TK scope "can't read . . . no such variable"
- Next by thread: Re: TK scope "can't read . . . no such variable"
- Index(es):
Relevant Pages
|