[Python-es] Ejecutar una función cada cierto tiempo

Arnau Sanchez pyarnau en gmail.com
Jue Jun 17 20:03:54 CEST 2010


On Thu, 17 Jun 2010 18:03:53 +0200 Jesús Genicio wrote:

> if __name__ == "__main__":
>     try:
>         a = App()
>         gobject.timeout_add( 1000, a.imprime)
>         gtk.main()
>     except KeyboardInterrupt:
>         pass
> 
> Y me da la temperatura una vez, pero ya no más.

Veamos la documentación:

http://library.gnome.org/devel/pygobject/stable/glib-functions.html#function-glib--timeout-add

"The function is called repeatedly until it returns FALSE, at which point the
timeout is automatically destroyed and the function will not be called again."

Es decir, sólo tienes que hacer un "return True" al final de "imprime". 

> [adjuntos grandecitos]

No soy administrador de la lista, pero diría que es preferible subir código
e imágenes a servicios externos y enlazar (especialmente si son imágenes)

arnau


Más información sobre la lista de distribución Python-es