Canvas class Tkinter supports functions that are used to move objects from one position to another on any canvas or tkinter level.
Syntax: Canvas.move (canvas_object, x, y)
Parameters:
canvas_object is any valid image or drawing created with the help of Canvas class. To know how to create object using Canvas class take reference of this .
x is horizontal distance from upper-left corner.
y is vertical distance from upper-left corner.
We will use the class to see the move ()
method work.
Class parameters
Data members used:
master
x
y
canvas
rectangle-method/">rectangleMember functions used:
movement ()
left ()
right ()
up ()
down ()Widgets used: Canvas
Tkinter method used:
Canvas.create_rectangle-method/">rectangle ( )
pack ()
Canvas.move ()
after ()
bind ()
Below is the Python implementation:
|
Exit:
Additional print statements are used in the above code to show the correct operation of the move () method. The Keyword keysym (reserved by Tkinter) is used to print which keyboard key is pressed.