Python Threads
Sick Monkey
sickcodemonkey at gmail.com
Sun Feb 18 21:37:02 EST 2007
Well if this cannot be done, can a thread call a function in the main
method?
I have been trying and have not been successive. Perhaps I am using thread
incorrectly.
On 2/18/07, Sick Monkey <sickcodemonkey at gmail.com> wrote:
>
> Is there anyway to get 2 python threads to talk to one another?
>
> I have a GUI which is spawning a thread to make a large calculation (that
> way the GUI does not appear to be non responsive). I am trying to attach a
> progress bar to the threaded action. As the thread is calculating data, I
> would like it to communicate with the other (progress) thread to update it.
>
> On windows, when I spawn the progress bar without using threads, the
> progress bar stalls.... <<this does not happen on linux.>> So I thought by
> spawning the progress bar by using a thread, it would not stall....... If
> anyone can think of another technique.... I am all ears.
>
> ~~~~~~~~~~START SAMPLE~~~~~~~~~~~~~~~~~~~~~~~~
> def progressBar(status):
> mroot = Tkinter.Tk(className='Worker Bee')
> metric = Meter(mroot, relief='ridge', bd=3)
> metric.pack(fill='x')
> metric.set(status, 'Starting ...')
>
> def fetchFiles(file1,file2,file3):
> method = ''
> print file1
> print file2
> print file3
> f1 = fopen(file1)
> a = f1.readlines(); f1.close()
> d1 = {}
> for c in a:
> for m in mailsrch.findall(c):
> d1[m.lower()] = None
>
> ####I Would like to Update the progress bar running in the other
> thread here.
> ## set status = .33 and update progress bar.
> if file2 == '':
> domain(d1,file3)
> #...
>
> def startProc():
> status = 0
> thread.start_new_thread(fetchFiles, (f1name,f2name,f3name,))
> thread.start_new_thread(progressBar, (status,))
>
> ~~~~~~~~~~END SAMPLE~~~~~~~~~~~~~~~~~~~~~~~~
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070218/632220c5/attachment.html>
More information about the Python-list
mailing list