Threading and tkinter

Jani Hakala jahakala at
Sat Mar 7 09:40:26 CET 2009

gert <gert.cuykens at> writes:

> After reading the docs and seeing a few examples i think this should
> work ?
> Am I forgetting something here or am I doing something stupid ?
> Anyway I see my yellow screen, that has to count for something :)
I have been using the following scheme:
  - Pass the root object to the thread object when creating the object
  - Define a event_handler: root.bind('<<SomeEvent>>', evt_handler) in
    the main thread.

  - When the thread has done something that the GUI part should now
    about, signal an event in the thread:
        root.event_generate('<<SomeEvent>>')    (no other arguments)

  - Call a method of the thread object in the event handler e.g. to get
    some data from a queue object.

This ensures that only the main thread accesses Tkinter-related things.

-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-python
Size: 1126 bytes
Desc: tkinter and threading
URL: <>
-------------- next part --------------

Jani Hakala

More information about the Python-list mailing list