Could anyone explain why time does not update when running inside Panda? It seems to only update every 60 seconds or so, but it’s not very consistent.
Here, I’m trying to update time every second using a task. If you uncomment the print statement below you will see that it’s the variable not updating rather than Panda not redrawing it correctly. Does Panda mess with the system time?
from pandac.PandaModules import *
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.gui.OnscreenText import OnscreenText
from direct.task import Task
import datetime
class World(DirectObject):
def __init__(self):
base.setBackgroundColor(0,0,0)
base.disableMouse()
base.camera.setPos(0,0,0)
#Show time
self.TimeText = OnscreenText(scale=0.08, pos=(0,0), align=TextNode.ACenter, shadow=(0,0,0,1), fg=(255,255,255,1), mayChange=True)
self.timeTask = taskMgr.doMethodLater(1, self.getTime, 'timetask')
def getTime(self, task):
now = datetime.datetime.now()
#print now.strftime("%a, %b %d %I:%M:%S %p")
self.TimeText.setText(now.strftime("%a, %b %d %I:%M:%S %p"))
return task.again
w = World()
run()