Add the line
from Tkinter import
On Apr 7, 2009, at 10:21 PM, Wayne Watson
<sierra_mtnv...@sbcglobal.net> wrote:
This looks good, but there's a slight problem. It looks right, but I
get this when I try to run it:
Traceback (most recent call last):
File "C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-
Utilities/Playground/fun-move_object.py", line 42, in <module>
root=Tk()
NameError: name 'Tk' is not defined
Howard Lightstone wrote:
Here is a *dumb* example of what I think you want. It can be
elaborated with crosshairs, ring sizing, etc.
import PIL
import Image
import ImageTk
class data:
startx=0
starty=0
def startmotioncallback(event):
data.startx=event.x
data.starty=event.y
def motioncallback(event):
deltax=event.x-data.startx
deltay=event.y-data.starty
data.startx=event.x
data.starty=event.y
# should put some limits on where the cirle is moved
# left as exercise.....
data.cnv.move(data.ring,deltax,deltay)
def Demo(root):
# resize window
root.geometry('400x400+0+0')
data.root=root
# make a canvas
cnv=Canvas(root)
cnv.pack(expand=1,fill=BOTH)
data.cnv=cnv
img=Image.open('white dragon.png') # some image you have.....
data.img=ImageTk.PhotoImage(img)
data.photo=cnv.create_image(0,0,image=data.img,anchor='nw')
data.ring=cnv.create_oval((100,100,300,300))
cnv.bind("<B1-Motion>",motioncallback)
cnv.bind("<Button-1>",startmotioncallback)
root.mainloop()
if __name__ == '__main__':
root=Tk()
Demo(root)
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig
--
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****
"Less than all cannot satisfy Man." -- William Blake
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig