Q:

Thread to add items in Treeview - pygtk

I am trying to develop a downloader app in pygtk
So when a user adds a url following actions happen

addUrl()

which calls

validateUrl()
getUrldetails()

So it took a little while to add the url to the list because of urllib.urlopen delay
so i tried to implement threads. I added the following code to main window
thread.start_new_thread(addUrl, (self,url, ))
I passed a reference to the main window so that i can access the list from thread
but nothing seems to happen 

A:

I think that you check this thread first How to use threading in Python?.
for example:
    import Queue
    import threading
    import urllib2
# called by each thread
def get_url(q, url):
    q.put(urllib2.urlopen(url).read())

theurls = '''http://google.com http://yahoo.com'''.split()

q = Queue.Queue()

for u in theurls:
    t = threading.Thread(target=get_url, args = (q,u))
    t.daemon = True
    t.start()

s = q.get()
print s

Hope this helps you. 

