List Info

Thread: single button threading




single button threading
country flaguser name
United States
2007-06-17 15:41:25
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.
 
If there is no solution to this, can anyone tell me if reconstructing the gui with wx would help with this matter? I don't want to do this because I am familiar with tk and find it far easier to work with, but I really have to find a way of solving this problem.
 
Thank you very much for reading, and I hope someone can help me out.

;


Yahoo! Answers - Get better answers from someone who knows. Try it now.
Re: single button threading
country flaguser name
United States
2007-06-17 15:55:50
On Sun, Jun 17, 2007 at 09:41:25PM +0100, Brill IanT 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.
>    
>   If there is no solution to this, can anyone tell me
if reconstructing the gui with wx would help with this
matter? I don't want to do this because I am familiar with
tk and find it far easier to work with, but I really have to
find a way of solving this problem.
>    
>   Thank you very much for reading, and I hope someone
can help me out.
			.
			.
			.
There are several ways to achieve the responsiveness you
describe
within Tkinter.  I'll be tied up the next couple of days; I
hope
an answer that delayed still helps you.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discusspython.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Re: single button threading
country flaguser name
Germany
2007-06-18 03:50:13
On Sun, 17 Jun 2007 21:41:25 +0100 (BST)
Brill IanT <woswwfyahoo.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

Michael

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discusspython.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )