Moving things in Tkinter
Cameron Laird
claird at starbase.neosoft.com
Thu May 9 00:00:22 EDT 2002
In article <13285ea2.0205070644.56ec7365 at posting.google.com>,
J.Jacob <joost_jacob at hotmail.com> wrote:
>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.
John Grayson's <URL: http://www.manning.com/Grayson >--recommended.
It really accomplishes quite a bit more than Mark's, in regard to
Tkinter.
Rather than <Button-1>-<Motion-1>, I've found the best codings of
this sort of drag-and-drop functionality are likely to be in terms
of <ButtonPress-1>-<ButtonRelease-1>.
--
Cameron Laird <Cameron at Lairds.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
More information about the Python-list
mailing list