Hi,
i'm new to this list and a newbie in programming with pygtk so please
forgive this stupid question.
I'm trying to write an python app which copies a file over a network.
While the coping will take place in a separate thread, i want to observe
the progress with a progressbar using a timeout. So for testing the
usage of progressbars i wrote the little piece of code below (observing
a counter).
The timeout function does it's job very well but there is a problem in
my thread.
The programm hangs without an error message when i remove the timeout. I
must have misunderstood something (gtk.threads_{enter/leave} or so).
Could you please give me hint?
I found some discussion of threading problems with pygtk in the list
archive and also some hints, but i am trying to solve this issue for
days without success. My system is Red Hat 8.0. I also updated to the
newest packages i found (rawhide) and recompiled the pygtk2.src.rpm
("./configure --enable-thread" was neccessary).
gtk+-1.2.10-23
gtk2-2.1.5-1
gtk2-devel-2.1.5-1
gtk2-engines-1.9.0-6
gtk+-devel-1.2.10-23
gtk-engines-0.11-14
pygtk2-1.99.14-4
pygtk2-debuginfo-1.99.14-4
pygtk2-devel-1.99.14-4
pygtk2-libglade-1.99.14-4
Any help would be appreciated.
Dirk
#!/usr/bin/env python2
import gtk, thread
from gtk import glade
from threading import *
xml = glade.XML('copy.glade')
progressbar = xml.get_widget('aktuell')
def gtk_main_quit(*args):
gtk.main_quit()
xml.signal_autoconnect(locals())
def progress():
global c
newfrac = c[0]/100000.0
if newfrac >=1:
newfrac=0
print 'progress', newfrac
gtk.threads_enter()
progressbar.set_fraction(newfrac)
gtk.threads_leave()
return 1
def t():
global progress_timeout, c
while c[0]<100000:
#print 't', c
c[0]=c[0]+1
gtk.threads_enter()
gtk.timeout_remove(progress_timeout)
# here it hangs; "test" isn't printed:
print "test"
gtk.threads_leave()
c=[0]
gtk.threads_init()
thread.start_new_thread(t,())
progress_timeout=gtk.timeout_add(100,progress)
gtk.main()
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/