I need to generate virtual events for a tkinter window running in a separate thread. Calling event_generate
from non-gui thread is supposed to be safe and it works well, when tkinter runs in the main thread and events are generated in another thread.
For a certain reason I need that the statements generating the events run in main thread (more specifically, I want those statements to be in the toplevel of the module).
But, when I do root = Tk(); root.mainloop()
in a new thread and root.event_generate("<<my-event>>")
in the main thread, I get stack overflow. When I swap the threads (root = Tk(); root.mainloop()
in the main thread and root.event_generate("<<my-event>>")
in a new thread) then everything works again.
I have taken care that root is fully construted (and also idle), before I try generating the event.
Any ideas how to get this setup working?
(I'm using Python 3.2.3)