Tkinter event question
Russell E. Owen
no at spam.invalid
Tue Nov 4 02:04:26 CET 2003
I've found a quirk in Tkinter and am wondering if anyone knows a
workaround. I've got some widgets that generate events. Sometimes the
widgets are not displayed, but they may still want to generate these
The problem is, if a widget has never been displayed, event_generate
appears to be ignored. If I display the widget and then hide it again,
event_generate works fine. But...I've got many widgets that are normally
hidden and don't really want the screen flashing with stuff being
displayed and hidden again right away as the application starts up.
Here is a minimal and unrealistic script that shows the problem. Push
the button to generate a <<Foo>> event. The event is actually only
generated if the label that generates it is shown (you can then hide it
again and the events are still generated). Note that the label *is*
initially gridded, but it's taken hidden again before the window manager
ever actually gets to display it.
Suggestions? This is driving me mad, as such events could be quite
useful for communication if I could only generate them reliably.
from Tkinter import *
root = Tk()
print "Got <<Foo>>"
c = myLabel(text="I Am A Label")
b = Button(root, text="Send <<Foo>>", command=c.sendFoo)
showVar = IntVar()
showC = Checkbutton(root, text="Show Label",
More information about the Python-list