Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! usr/bin/env python
- # GUI of main window
- import pygtk
- pygtk.require('2.0')
- import gtk
- import gtk.glade
- import time
- from multiprocessing import Process
- import threading
- 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]
- if testmode == '0' or testmode == 'normal' :
- for item in self.list_ :
- item = [item]
- print item
- self.list_store.prepend(item)
- elif testmode == '1' or testmode == 'loop':
- 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)
- ###############################################4
- def main(self):
- gtk.main()
- if __name__ == '__main__':
- testmode= raw_input('''please enter 0 or 1 \n
- enter 0 or 'normal' to show the result without error
- the treeview will be filled with 9 rows \n \n
- enter 1 or loop to show the error occuring in the loop mode \n
- \n error is : no rows added to the gtk treeview despite of the code works well in the background
- the expected action is continious adding of rows in each cycle of the loop
- ''')
- sample1 = sample(testmode)
- gtk.gdk.threads_enter()
- sample1.main()
- gtk.gdk.threads_leave()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement