Reputation: 1260
The idea is to continuos iteratation over list , adding its items to gtklist store , I use :
multiprocess.Process
to add rows in seperate flow processgtk.gdk.threads_enter()
, before calling main method and before the processThe error description is : no row added to the liststore despite of the loop runs well in the background.
Can anyone suggest or point to the solution ?
Here is the init method ,looping method (named list_updater)
'class sample():
def __init__(self , testmode ):
self.builder = gtk.Builder()
self.builder.add_from_file('test.glade')
self.list_store = self.builder .get_object('liststore1')
self.win = self.builder.get_object('window1')
self.win.set_default_size(200 , 400)
self.win.show()
self.list_ = [0,31,2,5,4,61,8,20,10]
gtk.gdk.threads_enter()
tar = self.list_updater
arg = ()
t = Process(target = tar , args = arg )
t.start()
gtk.gdk.threads_leave()
def list_updater(self ):
while True :
for item in self.list_ :
item = [item]
print item
self.list_store.prepend(item)
time.sleep(1)
Upvotes: 0
Views: 82
Reputation: 1260
Here is the items I used to work around this problem in my original code :
the multiple threading is differs from multiple processing , I have shifted to threading.
import threading # instead of multiprocessing
gtk.gdk.threads_enter()
tar = self.list_updater
arg = ()
t = threading.Thread(target = tar , args = arg )
t.start()
gtk.gdk.threads_leave()
gtk.gdk.threads_init() , gtk.gdk.thread.enter() before calling the main loop , gtk.gdk.thread.leave() after it
def main():
gtk.gdk.threads_init()
gtk.gdk.threads_enter()
gtk.main()
gtk.gdk.threads_leave()
Upvotes: 1