Search code examples
tcltk-toolkit

event generate all - ends in "_tkinter.TclError: bad window name/identifier all"


So while I didn't found a hint in the docs that event generate all <<Custom>> should work. I'm a bit surprised it doesn't.
Everything connected to events is handled by bindtags and widgets already handle events to the tag all like <<ThemeChanged>>.

So my question is, how do you trigger an event on all widgets at once? Is it possible or exclusively for core developers?

ThemeChangeProc


Solution

  • The undocumented Tcl command ttk::ThemeChanged is how Tk sends that sort of event, and all it actually does internally is iterate over all known widgets and send the event to each of them. Yes, that is a bit expensive, but theme changes aren't very common.

    all is a binding tag, not a widget. Events have to go to definite windows (the field in the C structure needs to be not None); Tk doesn't route events without a destination. Binding tags say which collection of bindings can respond to a particular event once it has been routed, and with what priority.