[Tkinter-discuss] thread module
timj at tolisgroup.com
Tue Apr 1 17:26:32 CEST 2008
On Apr 1, 2008, at 6:05 AM, Amit Finkler wrote:
> 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.
More information about the Tkinter-discuss