PDA

View Full Version : Timer events within a Tkinter class


kevin
07-27-2011, 04:16 PM
Hi all,

Is it possible to have a Vizard timer event occur within a Tkinter application? I seem to be running into a problem with the Tkinter main loop dominating the program execution, so Vizard's normal functionality temporarily halts in the background. In other words, a timer event created using vizact.ontimer() will not execute within the Tkinter application. Is there a way around this?

kevin
07-28-2011, 09:34 AM
Found the answer here: http://forum.worldviz.com/showthread.php?t=2865&highlight=tkinter

kevin
07-29-2011, 12:10 PM
Ran into another problem. Having Vizard embedded in the Tkinter frame works fine, and Vizard picks up mouse events. However, it does not pick up keyboard events. Here is the relevant code:

class InputSetup(Tkinter.Frame):
def __init__(self,master=None):
Tkinter.Frame.__init__(self,master,width=800,heigh t=600)
self.pack()

viz.go(viz.EMBEDDED,window=self.winfo_id())
viz.clearcolor(0.95,0.95,0.95)

viz.callback(viz.MOUSEDOWN_EVENT,self.record_input )
viz.callback(viz.KEYDOWN_EVENT,self.record_input)

self.after(1,self.update_vizard)

def update_vizard(self):
viz.updateframe()
self.after(1,self.update_vizard)

def set_selected_variable(self,value):
print value

def record_input(self,e):
self.set_selected_variable(e)

I've also tried updating Vizard's input monitoring directly using viz.update(viz.UPDATE_INPUT) with no luck.

Is there anything I'm overlooking that I need to manually ensure is updated?