import tkinter as tk root = tk.Tk() canvas = tk.Canvas(root, width=300, height=200) canvas.pack() # Getting the height of the canvas canvas_height = canvas.winfo_height() # returns 200 # Drawing a rectangle on the canvas x1, y1 = 10, 10 x2, y2 = 100, 100 canvas.create_rectangle(x1, y1, x2, y2, fill="red") root.mainloop()In this example, we create a canvas widget with a width of 300 and a height of 200. We retrieve the height of the canvas using the `winfo_height` attribute and store it in the `canvas_height` variable. We then draw a rectangle with one corner at (10, 10) and the other corner at (100, 100) on the canvas. Overall, the Tkinter Canvas widget is a versatile tool for creating graphical applications, and the `winfo_height` attribute provides essential information for positioning shapes correctly.