[Tkinter-discuss] single button threading
klappnase at web.de
Mon Jun 18 10:50:13 CEST 2007
On Sun, 17 Jun 2007 21:41:25 +0100 (BST)
Brill IanT <woswwf at yahoo.co.uk> wrote:
> I am writing an application which fetches and parses a large number of urls for hyperlinks.
> My problem is that when the prog is in the middle of the 'fetching' stage, the gui becomes almost completely unresponsive.
> This is not at all what I want. I want the user to be able to interact with the gui while this process is going on. Even if just one button, a 'stop' button, is the only thing working, I would be satisfied with that.
> Is there a way to perhaps thread a button or two while urllib2 is busy fetching a big list of urls? I ask this with some trepidation because I know how thread unfriendly tkinter is.
I did not find it that hard to use Tkinter with threads. You just have to make sure that
all interaction with Tk is done from the main (gui) thread. Typically I use a bunch
of variables to handle communication between Tkinter and the child thread, so the
"Stop" button would set a "stop_child_thread" flag to True, whereas the child
thread continually updates a "progress" flag that allows the gui to draw some visual feedback
about the progress made by the child.
I hope this helps
More information about the Tkinter-discuss