The Canvas widget is undoubtedly the most powerful widget available in Tkinter. It can be used to build anything from custom widgets and views to complete user interfaces. As the name implies, Canvas is a blank area on which figures and images can be drawn.
A Canvas object can be created like any other widget:
root = tk.Tk() canvas = tk.Canvas(root, width=1024, height=768) canvas.pack()
Canvas accepts the usual widget configuration arguments, as well as width and height for setting its size. Once created, we can start adding items to canvas using its many create_() methods.
For example, we can add a rectangle with this code:
canvas.create_rectangle(100, 100, 200, 200, fill='orange')
The first four arguments are the coordinates of the upper-left and lower-right corners, in pixels from the upper-left corner of the canvas...