View Full Version : TK with Vizard
DavidHeesom
02-12-2008, 07:56 AM
Hi
Just downloaded and started to play with TK and Vizard as we want to create an application that uses a windows style interface and menus but is it possible to embed the vizard graphics window into a TK application or is there an example on the forum I have missed somewhere.
Thanks for any help...
farshizzo
02-13-2008, 02:19 PM
Here is a simple script that embeds the Vizard graphics window in a Tk application:import viz
from Tkinter import *
import win32gui
class VizardApp(Frame):
def __init__(self, master=None):
Frame.__init__(self, master,width=800, height=600)
self.pack()
#Embed vizard using the viz.EMBEDDED flag and passing handle to existing window
viz.go(viz.EMBEDDED,window=self.winfo_id())
#Initialize Vizard environment
viz.add('tut_ground.wrl')
ball = viz.add('ball.wrl',pos=(0,1.8,2))
ball.add(vizact.spin(0,1,0,90))
#Need to setup timer to manually update vizard engine
self.after(10,self.updateVizard)
def updateVizard(self):
"""Update the vizard engine"""
viz.updateframe()
self.after(10,self.updateVizard)
# create the application
myapp = VizardApp()
# set title of application
myapp.master.title("Vizard Tkinter example")
# start the program
myapp.mainloop()We have also embedded Vizard in wxPython applications, and it works a lot better than Tk. If you are not too attached to using Tk, then I would recommend using wxPython.
DavidHeesom
02-19-2008, 08:24 AM
Thats great - thanks. I've downloaded wxPython and started looking at that at the moment. Thanks for the help.
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.