Re: -command scope



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)

.



Relevant Pages

  • Re: renaming a directory thru DOS on winxp
    ... Your problem may be with the spaces in your pathname, ... DOS emulator, also called the Command Prompt, in WinXP, you must enclose the ... to simply rename it in the same place, ...
    (microsoft.public.windowsxp.basics)
  • Re: Design question/tablelist
    ... The tablelist code chokes in the aquahig::aquatable proc, ... catch {destroy .dirview} ... By the looks of the error, you have an image named after some command ... dialog seems to be failing trying to create a text widget. ...
    (comp.lang.tcl)
  • Re: TIP #169: Add Slave Text Widgets
    ... I agree (and also think peer or clone is a better name than slave) ... >> it would seem that having one text widget create a slave is not really ... >> the normal text command to construct it, ...
    (comp.lang.tcl)
  • Re: coordlist for create window command
    ... i create a window inside a canvas with this command ... you give the geometry via the relevant widget command ... either during creation or via $widget configure .. ... is to be anchored to this point via -anchor $anchor ...
    (comp.lang.tcl)
  • Re: Text Editor navigation
    ... The NewGuy wrote: ... WIDGET - Brown ... Have you tried the Find command? ... You'll need to use a real news reader if you want me to see your posts. ...
    (comp.sys.mac.apps)