####################################################
proc chgcol {} {
if {[.b cget -bg] eq "green"} then {
.b configure -bg yellow
} else {
.b configure -bg green
}
}
button .b -text {Press me} -command chgcol -bg green
pack .b
####################################################
If I double click the file in windows explorer the button is created but
I get the runtime error:
unknown option "-state"
while executing
"$w cget -state"
(procedure "tk::ButtonEnter" line 3)
invoked from within
"tk::ButtonEnter ."
when moving the cursor over the toplevel.
The same appears after calling:
wish button.tcl
from DOS console.
When starting the wish and loading button.tcl via the "Execute..."
menu from the wish console it works correct, the same if the program
text is pasted into the wish window.
If the file is renamed (eg. to "btest.tcl"), it also works flawless in
all cases described above.
On Linux no problem at all.
Where does this strange behaviour come from?
--
Gerhard Reithofer
Tech-EDV Support Forum - http://support.tech-edv.co.at
> Hi, I've a simple demo program named button.tcl:
> ...
> Where does this strange behaviour come from?
http://wiki.tcl.tk/497 talks about "taboo" file names. There's a little
more at the bottom of http://wiki.tcl.tk/1723 as well.
Thank you for links, I could vaguely remember a discussion here but I
couldn't find details - now I'm more wise again ;-)
Shouldn't that behaviour be documented in the man pages?
On Thu, 2 Oct 2008, Alan Anderson wrote:
Is that bahaviuor related to windows only?
I couldn't experience any problems under Linux.
I'm not sure, but I *think* under Linux the file name would have had to be
Button.tcl -- it all has to do with the option database, read the option and
options man/help page for a little insight.
While there is *very* little magik in Tcl/Tk -- what there is tends to have
very powerful effects, as you have discovered when accidentally invoking it.
--
+------------------------------------------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
It is, on the wish(1) manual page in the APPLICATION NAME AND CLASS
section which has been there for longer than I've been using Tcl/Tk. But
you need to be experienced in both the ways of Tk and the ways of X11
applications in general to understand why what it says implies the
behaviour that tripped you up.
I suppose the docs could have been slightly clearer (such as saying
"this implies that calling an application the same thing as a widget is
bad practice") but even if they had been, would you have read them? I
only originally read that part because I was in the habit of printing
out Tcl and Tk docs and reading them while commuting...
Donal.
On Sun, 5 Oct 2008, Donal K. Fellows wrote:
> Gerhard Reithofer wrote:
> > Shouldn't that behaviour be documented in the man pages?
>
> It is, on the wish(1) manual page in the APPLICATION NAME AND CLASS
> section which has been there for longer than I've been using Tcl/Tk. But
> you need to be experienced in both the ways of Tk and the ways of X11
> applications in general to understand why what it says implies the
> behaviour that tripped you up.
thanks - once more I see that there are still many secrets to discover,
even after years of tcl coding.
But as you wrote, it is not easy to combine this information with
startup problems in "some" situations.
> I suppose the docs could have been slightly clearer (such as saying
> "this implies that calling an application the same thing as a widget is
> bad practice") but even if they had been, would you have read them? I
> only originally read that part because I was in the habit of printing
> out Tcl and Tk docs and reading them while commuting...
I agree fully and will consider this in future and inform others.
... and you are probably right that I wouldn't have read it.
windows only!
Under unix: The class name for the root window (.)
will be "Button.tcl" for button.tcl, inlcuding the extension.
-roger
Couldn't it be that on windows you'll run into issues with both
Button.tcl and button.tcl due to the case insensitivity of the file
system?
Mark
Definitly yes.
This has nothing to do with cases.
The difference is, that the extension is
removed under windows --to form the class
name of window root--
I guess, it was a clever thought:
It did allow to start tcl scripts via
double-click under windows and thus
mimics /bin/sh ... /usr/bin/wish ...
under unix.
Well, the consequence is, everyone learn[ed]
someday to avoid (.), for managing any windows
--except for menu-clones.
-roger