[vtkusers] Resource forking problems on Mac with python and vtk

Alethea Bair abair at viz.tamu.edu
Fri Dec 14 14:10:02 EST 2007


On Dec 14, 2007, at 8:51 AM, Sean McBride wrote:

>
> I'm sorry I can't help more... I've never used Python.  Which  
> executable
> runs Python scripts?  Have you used other Python scripts that  
> display a
> window and successfully allow interaction?
>

The executable is 'python' and is generally found in /usr/bin/
And I have successfully used the module 'Tkinter' (stands for Tk  
interface). The following script opens a window that opens and closes  
fine and registers keys and clicks (Obviously it doesn't use  
vtkRenderWindow)

________________
# File: MouseKeyClicks.py

from Tkinter import *# load Tkinter module
root = Tk()             # root widget is the window

# define mouse and key callbacks
def callback(event):
         frame.focus_set()
         print "clicked mouse"

def key(event):
         frame.focus_set()
         print "pressed key"

# make window
frame = Frame(root, width=300, height=300)
# bind callbacks to keys and left mouse click
frame.bind("<Key>",key)
frame.bind("<Button-1>",callback)
frame.pack()              # size window and make it visible
frame.focus_set()     # set focus to the frame so events will be  
registered

root.mainloop()   # enter event loop
________________

-Alethea

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071214/6ab36d1d/attachment.htm>


More information about the vtkusers mailing list