I want to make the canvas size change dynamically when the size of the size if the window changes. my canvas is in a frame and the frame is inside the root. as you can see in the code:
canvas = tk.Canvas(elementFrame, height=920, width=920, bg="lightblue") canvas.grid(row=0, column=1, pady=20)
and this is the code of the frame :
elementFrame = tk.Frame(root)
elementFrame.columnconfigure(0, weight=1)
elementFrame.columnconfigure(1, weight=1)
I tried to create a function that takes the width and the height of the window when it's dimensions change
def resize_layout(event):
window_width = event.width
window_height = event.heigh
canvas.config(height=window_height - 20, width=window_height - 20)
root.bind('<Configure>', resize_layout)
it didn't work at all and the canvas disappeared