Hi, I was trying threads for the first time and not getting it to work, I 
browsed the list archives and found the below piece of code. It 
didn't work either and displayed the same symptoms as my 
program, ie my thread didn't seem to be getting any timeslice at 
all, but once I quit the mainloop(), the thread would jump to life.

Finally, I added an idlefunc which I commented out below, and 
suddenly everything worked, both my program and one below.
I am using win98, is this normal? 

-------------------------------------------
from gtk import *
from threading import *
import time

class Worker(Thread):
    def __init__ (self, widget):
        Thread.__init__(self)
        self.counter = 0
        self.widget = widget

    def run (self):
        while 1:
            threads_enter()
            self.widget.set_text ("Count: %d" % self.counter)
            threads_leave()
            time.sleep(1)
            self.counter = self.counter + 1

# def idlefunc():
#   time.sleep(0.1)
#   return TRUE

# idle_add(idlefunc)

win = GtkWindow()
label = GtkLabel()
win.add(label)
win.show_all()

threads_enter()
worker = Worker(label)
worker.start()
mainloop()
threads_leave()
-----------------------------------------

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to