Il giorno sab, 07/04/2012 alle 00.24 +0800, Lion Chen ha scritto:
> many thanks. so import glib is also right?

sure

import glib
glib.timeout_add(...)

but notice you answered to me instead than to the list

Pietro

> 
> Lion
> > Il giorno ven, 06/04/2012 alle 17.09 +0200, Petr Kubánek ha scritto:
> >> What about this:
> >>
> >> import gobject
> >>
> >> self.color_cycle_timeout_id = 
> >> gobject.timeout_add(500,self.color_cycle_timeout())
> >>
> >> Does it helps?
> > Petr's solution indeed should work indeed. A couple of notes:
> >
> > - gtk_timeout_add translated to Python as gtk.timeout_add. Similarly,
> > g_timeout_add translates to glib.timeout_add. That said, as Petr pointed
> > out, gobject.timeout_add will work too (assuming it isn't or doesn't
> > become deprecated too)
> >
> > - I may be wrong (don't know what you're trying to do exactly), but I
> > guess the second argument should probably be self.color_cycle_timeout
> > (without the brackets)
> >
> > Pietro
> >
> >
> >
> >> Petr
> >>
> >> Lion Chen píše v Pá 06. 04. 2012 v 23:03 +0800:
> >>> 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?
> >>>
> >>> _______________________________________________
> >>> pygtk mailing list   [email protected]
> >>> http://www.daa.com.au/mailman/listinfo/pygtk
> >>> Read the PyGTK FAQ: http://faq.pygtk.org/
> >>
> >> _______________________________________________
> >> pygtk mailing list   [email protected]
> >> http://www.daa.com.au/mailman/listinfo/pygtk
> >> Read the PyGTK FAQ: http://faq.pygtk.org/
> >
> > _______________________________________________
> > pygtk mailing list   [email protected]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://faq.pygtk.org/



_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to