Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/08/2011, 21:05
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: Ejecutar una función cada cierto tiempo en wxpython.

Puedes usar threads o puedes usar wx.Timer

Aquí un ejemplo con wx.Timer
Código Python:
Ver original
  1. import datetime
  2. import wx
  3.  
  4. class MyFrame(wx.Frame):
  5.    
  6.     def __init__(self, *args, **kwargs):
  7.         wx.Frame.__init__(self, *args, **kwargs)
  8.        
  9.         self.Bind(wx.EVT_CLOSE, self.onClose)
  10.         self.Bind(wx.EVT_TIMER, self.onTimer)
  11.        
  12.         self.timer = wx.Timer(self, -1)
  13.         self.timer.Start(1000)
  14.        
  15.        
  16.     def onClose(self, event):
  17.         self.timer.Stop()
  18.         self.Destroy()
  19.    
  20.     def onTimer(self, event):
  21.         print datetime.datetime.now()
  22.        
  23. app = wx.App(0)
  24. mFrame = MyFrame(None, -1)
  25. mFrame.Show()
  26. app.MainLoop()