Re: -command scope
- From: Andreas Leitgeb <avl@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 03 May 2005 12:54:28 GMT
Ian Bell <ruffrecords@xxxxxxxxx> wrote:
> Andreas Leitgeb wrote:
> Sorry, I meant command as in a Tcl/Tk command not the -command option to a
> widget.
I see. I don't want to start splitting hairs about what is a
command (and a list), since there is always the generic term
and the tcl-term which are not exactly the same. So any
questions of type "is a <x> a <y>?" depends primarily on which
sense of <x> and <y> is meant.
> Sorry you have completely lost me there. Just about every widget man page
> says: "The 'widget name' command creates a new Tcl command ...
In this context the widget name is e.g. button,text,label,...
In other contexts it may be the name of the instance (.b1,.f1.b2,...)
> ... whose name is pathName. This command may be used to invoke
> various operations on the widget."
The interface is obviously identified with the widget itself.
That's a simplification.
> This new Tcl command appears to have global scope like any other Tcl command
> which was my question and reasoning.
The command created as result of a [button .b] invocation is
just plain a command in global scope, yes.
If you invoke a widget-creator command (like button), you pass it
a pathName, and it will create BOTH the graphical incarnation AND a
command (named like your chosen pathName).
If you never manually "rename" anything, these cannot not be
distinguished.
However if you rename the created command, you can investigate
the subtleties between the widget's pathName and the command.
button .b -text foo
rename .b mybutton
# bad: next time user clicks the button, it will likely popup some
# error-window complaining it doesn't know command ".b"
proc .b {args} {puts $args; eval mybutton $args}
# will now log every interaction to stdout. (may be quite informative)
.
- Follow-Ups:
- Re: -command scope
- From: Ian Bell
- Re: -command scope
- References:
- -command scope
- From: Ian Bell
- Re: -command scope
- From: William J Poser
- Re: -command scope
- From: Ian Bell
- Re: -command scope
- From: Andreas Leitgeb
- Re: -command scope
- From: Ian Bell
- Re: -command scope
- From: Andreas Leitgeb
- Re: -command scope
- From: Ian Bell
- -command scope
- Prev by Date: Re: TIP #246: Unify Pattern Matching
- Next by Date: Re: getting selection from disabled text window
- Previous by thread: Re: -command scope
- Next by thread: Re: -command scope
- Index(es):
Relevant Pages
|