
May 14th, 2004, 05:56 AM
|
|
Contributing User
|
|
Join Date: Feb 2004
Location: London, England
|
|
A thread is a function that runs in the background, and the thread terminates when the function ends. So all you need to do is to return from the function.
I presume the dialog box is non-modal, since displaying a modal dialog will stop the thread from doing its thing. I suggest having a boolean flag somewhere that the dialog sets to True when the user clicks Cancel, and the thread function checks this flag at regular intervals and returns when it is True.
What GUI library are you using? If it is wxPython then there are issues with using the GUI from outside of the main thread. You may find this page useful: http://wiki.wxpython.org/index.cgi/LongRunningTasks
There may be similar issues with Tkinter, but it has been a while since I have used it so I can't say for sure.
Dave - The Developers' Coach
|