multi-thread problem of python/Tkiner on windows

Y

York

Hi, everyone,

I just want to know whether python/Tkinter support multi-thread or not. As
my experience, my GUI (based on Tkinter) program can run in multi-thread
style on Linux, but on windows, it has to be turn to non-thread style,
otherwise it will crash at once.

Thanks in advance.

York
 
A

Alex Martelli

York said:
I just want to know whether python/Tkinter support multi-thread or not. As
my experience, my GUI (based on Tkinter) program can run in multi-thread
style on Linux, but on windows, it has to be turn to non-thread style,
otherwise it will crash at once.

You should encapsulate your Tkinter GUI within one thread, dedicated to
just that job, and communicating with all other threads via instances
of Queue. In my experience (with older releases of Python, Tkinter, and
Tk itself -- haven't tried with the current ones) this is also needed
on Linux -- making calls to Tkinter method from multiple threads can
cause crashes (and I think that is in fact documented).


Alex
 
E

Eric Brunel

York said:
Hi, everyone,

I just want to know whether python/Tkinter support multi-thread or not. As
my experience, my GUI (based on Tkinter) program can run in multi-thread
style on Linux, but on windows, it has to be turn to non-thread style,
otherwise it will crash at once.

From my experience, Tkinter works with multi-thread on Windows, as long as you
keep calls to Tkinter in the thread where it was initialized. We use the method
event_generate on Tkinter widgets and Queues to make other threads communicate
with the thread where Tkinter runs, and it works without (too much...) problems.

Can you give you precisions on what are you doing exactly?

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top