Re: Bug in Tk 8.4.14?



George Petasis schrieb:
O/H Bryan Oakley έγραψε:

George Petasis wrote:

O/H Robert Heller έγραψε:


O/H Bryan Oakley Γ�


Is your tcl file named "Menu.tcl" by any chance?


Yes :-) Why?



It makes your toplevel window have the same *class* as that of a menu.


Is this documented? If not, its a bug. This is the first time I encounter this...
What is the relation of the file name and the class of the toplevels?


The relationship is mentioned in the wish man page:

"The class of the application, which is used for purposes such as specifying options with a RESOURCE_MANAGER property or .Xdefaults file, is the same as its name except that the first letter is capitalized."

You have to "read between the lines" to understand the ramifications of that statement, and how it interacts with bindings which are also tied to class names.

We get someone stumbling over this once every year or two on this newsgroup. Oddly, though, yours is the second report in only a week or so.

The fix is very simple, and is almost never a problem with real application development. Unfortunately, where it most often crops up is with newbies who are just learning the language. I think every manifestation of this issue I've ever heard of is related to naming the main file "menu.tcl" even though the same problem will occur with "toplevel.tcl", "button.tcl", etc. For some reason, "menu.tcl" seems to be a popular name.

One could argue whether it's a bug or not. After all, the application is behaving as documented. However, it seems like Tk could be smart enough to pick a different class name if it clashes with built-in class names.


I thought that only the application "name" was affected (i.e. what was return with tk appname). I have now idea what the "application class" is and how this interacts with the widgets :-( For example, menus have the class Menu. If my app is placed in a menu.tcl, the "application class" will also be Menu. But a quick check reveals that only the "." window uses the "application class" as its class. Other toplevels use the class Toplevel. Is "." the only window that is affected? (Shouldn't this be documented?)

George


Yes only the .(dot) window is affected.
However in your example the . window will have class "Menu.tcl" and
not "Menu" -- your filename should not be the cause of your problem...

place this inside your file to verify it:
puts stdout [winfo class .];
puts stdout [bindtags .];

-roger

.