Frozen Forest
March 1st, 2012, 11:08 AM
How do you make gtk run in a separate thread, as it's now does the Gtk,main() block everything, even things in separate threads.
What I though would happen with this code was that the gui was created an did run in the thread 'Gui' then would the thread 'test1' update the listview every second. What happen is that the gui get initiated, visible and block the 'test1' thread from starting. When the gui is terminated with Gtk.main_quit will test1 finally start executing.
def update_stat(self, t, data): # update the listview with new data
while True:
print(threading.current_thread().name)
self.stat_list[1][2]+=2
sleep(1)
def g(editor):
editor.window.show()
Gtk.main()
if __name__ == "__main__":
editor = Gui() # create gui
t = threading.Thread(target=g, name='Gui', args=(editor,))
t.daemon = True
t.start()
threading.Thread(target=editor.update_stat, name='test1', args=(None,None)).start()
How do you do this in gtk?
editor = Gui()
editor.window.show()
Gtk.main()
answer = calc_atoms_in_body()
editor.display_answer(answer)
What I though would happen with this code was that the gui was created an did run in the thread 'Gui' then would the thread 'test1' update the listview every second. What happen is that the gui get initiated, visible and block the 'test1' thread from starting. When the gui is terminated with Gtk.main_quit will test1 finally start executing.
def update_stat(self, t, data): # update the listview with new data
while True:
print(threading.current_thread().name)
self.stat_list[1][2]+=2
sleep(1)
def g(editor):
editor.window.show()
Gtk.main()
if __name__ == "__main__":
editor = Gui() # create gui
t = threading.Thread(target=g, name='Gui', args=(editor,))
t.daemon = True
t.start()
threading.Thread(target=editor.update_stat, name='test1', args=(None,None)).start()
How do you do this in gtk?
editor = Gui()
editor.window.show()
Gtk.main()
answer = calc_atoms_in_body()
editor.display_answer(answer)