import visual as vs
import Tkinter as tk
class VisualModel:
def __init__(self):
self.scene=vs.display(center=(0,0,0),background=(1,1,1))
self.scene.exit=False
self.box=vs.box(pos=(0,0,0))
def Update(self,x):
self.box.pos=(x,0,0)
class ControlWindow(tk.Frame):
def __init__(self,vs_model):
self.window = tk.Tk()
self.vs_model=vs_model
tk.Frame.__init__(self, self.window)
self.slider = tk.Scale(self.window, from_=0, to=1,resolution=0.001,command=self.Update)
self.slider.pack(side=tk.LEFT)
self.window.mainloop()
def Update(self,arg=None):
x=self.slider.get()
print x
self.vs_model.Update(x)# Comment this line
vsm=VisualModel() # Comment this line
w=ControlWindow(vsm)# Comment this line
#w=ControlWindow(None)# Uncomment this line
--
I don't think it is possible to use Tkinter with VPython, which is based on the GUI library wxPython. Even with your program not giving an error, note that the box doesn't appear. This is due to the fact that the rendering of the 3D objects, and the handling of events, goes through the wxPython machinery, which is inaccessible when Tkinter takes over these responsibilities.
See the VPython example program widgets.py for how to access wxPython widgets. My impression is that the wxPython widget set is at least as powerful as that of Tkinter.