I can’t get any information on exactly how window and canvas sizes work in Tkinter.
If I create a window, I can set its size using either the .configure() method or the .geometry() method. If I set both, the .geometry() method appears to override the .configure() method, and I know I can also set the position using the .geometry() method.
I can also create a Canvas object and pack it inside the window. Regardless of the size I set for the canvas, either too large or too small, it still fits neatly inside the window.
Here is a code snippet to illustrate my experiments:
root = tkinter.Tk()
root.configure(background='#ECECEC', padx=20, pady=20)
root.geometry('800x600+200+200')
root.configure(width=1200, height=700)
canvas = tkinter.Canvas(root, width=600, height=1400, background='white')
canvas.pack(fill="both", expand=True)
root.mainloop()
What’s the relationship between the window .configure() and .geometry() methods, and how should this affect the included canvas?
fillparameter to.pack()says to ignore the natural size, and instead make the widget fit the window.