[Tkinter-discuss] thread module

Amit Finkler amit.finkler at gmail.com
Wed Apr 2 09:41:05 CEST 2008

Tim Jones wrote:

> On Apr 1, 2008, at 6:05 AM, Amit Finkler wrote:
>> Hi,
>> Following a previous post of mine (http://mail.python.org/pipermail/ 
>> tkinter-discuss/2008-March/001320.html), I finally managed to start  
>> a new thread using the thread module. This new thread is started by  
>> clicking on a button on my Tkinter GUI and it just continuously  
>> plots a graph using matplotlib.
>> Now, however, a new problem arises - how does one close the  
>> thread??? The function this thread starts has a Ctrl-C Exception  
>> which works fine if the thread module is not used. Now, however,  
>> pressing Ctrl-C does nothing. The thread has a life of its own!!!
>> Your help will be greatly appreciated.
> The simplest solution is to set a global flag "QuitThread" and set it  
> to False while running.  Then, allow the user to click a button and  
> then set the value to True.  In the thread, check the value of the  
> variable and exit if it's True.
> HTH,
> Tim
Thanks for the tip. It seems like a reasonable solution. One question
remains: after I set the flag to be true, how do I exit the thread? I
tried to check whether the flag is true and then execute thread.exit().
Nothing happened, though. The graph continued on plotting and obviously
the thread kept on running.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080402/d3c3f470/attachment.htm 

More information about the Tkinter-discuss mailing list