I am developing a multithreaded application in pygtk using quickly and stuck with threads. So I am experimenting with various possibilities and found out that my thread work only when I do something in the gui Here is my code
t = threading.Thread(target=self.calc,args=(treeiter))
t.daemon = True
t.start()
def calc(self,treeiter):
store=self.builder.get_object('liststore1')
per=0
while 1:
print "Calcing and changing percent,per="+str(per)
tore.set_value(treeiter,4,str(int(per))+"%")
per+=1
time.sleep(1)
I am trying to update the value in a liststore
by thread but it only get update when I click some button or some other gui events why is that so? why is the thread not running in the background?
Threads and GTK don't always play nice together. There are a few tricks that help, but don't be surprised to have weird bugs. I recently removed all threads from an application and it feels much better.
So, the first thing you should think about is whether you can rewrite your application to take advantage of the GLib async methods.
If you insist on having threads, keep these two rules in mind:
These are rules, not guidelines. You must always do this when working with threads.
Using time.sleep() is not a good idea when you are using gtk. You could try use a timer event. (I don't use quickly anymore but this should work i think.)