I'm trying to make an object that handles basic time related functions. I want it so when any of the attributes (e.g. self.Time ) are referenced they are up to date. However, for some reason wx.CallLater(1000, self.Tick) doesn't seem to be updating the attributes. It will only print self.Time once, as opposed to every second (like I want it to).
How would I go about getting the behavior I desire? Should I use something besides wx.CallLater(1000, self.Tick)?
Snippet :
import wx, re, time, win32api, calendar
class TimeDate :
def __init__ (self) :
self.Tick()
def Tick (self) :
self.Year = int(time.strftime("%Y"))
self.Month = int(time.strftime("%m"))
self.Calendar = calendar.month(self.Year, self.Month)
self.Date = time.strftime('%A, %B %d, %Y')
self.Time = time.strftime('%I:%M %S %p')
print self.Time
wx.CallLater(1000, self.Tick)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…