[pygtk] How to use g_timeout_add () function?

Lion Chen chnlion79 at gmail.com
Fri Apr 6 23:03:42 WST 2012


Hello all,  i have a question:

when i check gtk_time_out in the gtk+2 reference, it said " gtk_timeout_add has been deprecated since version 2.4 and should not be used in newly-written code. Use g_timeout_add() instead."

but i don't know how to use the g_timout_add() function. if i use the function, i would get an error message:

self.color_cycle_timeout_id = g_timeout_add(500, self.color_cycle_timeout())

Traceback (most recent call last):
  File "/home/lionchen/workspace/testtext/testtext_bak.py", line 296, in set_colors
    self.color_cycle_timeout_id = g_timeout_add(500, self.color_cycle_timeout())
NameError: global name 'g_timeout_add' is not defined
 
or:

self.color_cycle_timeout_id = gtk.g_timeout_add(500, self.color_cycle_timeout())

Traceback (most recent call last):
  File "/home/lionchen/workspace/testtext/testtext_bak.py", line 296, in set_colors
    self.color_cycle_timeout_id = gtk.g_timeout_add(500, self.color_cycle_timeout())
AttributeError: 'module' object has no attribute 'g_timeout_add'

when i use the gtk.timeout_add(), no error message occurse.

can i use g_timeout_add() in pygtk?



More information about the pygtk mailing list