Understanding the coordinate system
To draw graphic items on a canvas, we will need to specify their position using a coordinate system. Since a canvas is a two-dimensional space, points will be notated by their coordinates on the horizontal and vertical axes—commonly labeledxand y respectively.
With a simple application, we can easily illustrate how to locate these points in relation to the origin of the coordinate system, placed in the upper-left corner of the canvas area.
How to do it...
The following program contains an empty canvas and a label that shows the location of the cursor on the canvas; you can move the cursor to see what position it is placed in, giving clear feedback on how the x and y coordinates increment or decrement, depending on the direction you move the mouse pointer:
import tkinter as tk class App(tk.Tk): def __init__(self): super().__init__() self.title("Basic canvas") self.canvas = tk.Canvas(self, bg="white") self.label = tk.Label...