Search code examples
pythonmultithreadinguser-interfacegtkpygtk

gobject.timeout_add() not working after calling gtk.threads_init() on windows xp


Following simple code will hang forever on windows XP, and the "check dialog" text is never outputted to console. The window created in the code showed but is blocked (when I move mouse into the window area, the mouse pointer is always a "loading" icon)

While same code works well on Windows 7

Runtime details: Windows XP SP3, python 2.7.5, pytgtk-2.24-allinone

import gtk
import gobject

def checkDialog():
  print 'check dialog'
  return True

gobject.timeout_add(500, checkDialog)
gtk.threads_init()
w = gtk.Window()
w.show()
gtk.main()

Solution

  • Finally one guy from irc channel #pygtk gives me the answer:

    I need use gobject.threads_init() instead of gtk.threads_init()

    A complete solution can be found here pygtk gobject.timeout_add() won’t work after calling gtk.threads_init() on windows xp