Moving things in Tkinter

J.Jacob joost_jacob at hotmail.com
Tue May 7 10:44:04 EDT 2002


You want to click on an image and move it with the mouse.

Put the image on a Tkinter canvas.  Catch the mouse events and bind
them to your function that moves the image, like:
myfancycanvas.bind('<Button-1>', selectimagefunction )
myfancycanvas.bind('<Motion-1>', moveimagefunction )

The callback functions have to have an event in their header, like:
def moveimagefunction(event):
    yourcode = here

This is off the top of my head and i am not sure about the correct
event strings but this is about what i would do.

I think you need a book about Tkinter programming, the best thing i
found was the chapters in Programming Python from Mark Lutz.  There is
another book on Tkinter programming but i could never get my hands on
it.



More information about the Python-list mailing list