In Python3/tkinter how to set the size of a frame relative to its parent window size? In Python3/tkinter how to set the size of a frame relative to its parent window size? tkinter tkinter

In Python3/tkinter how to set the size of a frame relative to its parent window size?


If you know the size you want and have it you do:

root = # Your root windowmyFrame = ttk.Frame(root, height=desiredHeight, width=desiredWidth)myFrame.pack()

So if you want it relative to the root:

root = # Your root windowrootHeight = root.winfo_height()rootWidth = root.winfo_width()# Say you want it to be 20 pixels smallermyFrame = ttk.Frame(root, height=rootHeight-20, width=rootWidth-20)myFrame.pack()# ORmyFrame = ttk.Frame(root) # No set dimensionsmyFrame.pack(padx=20, pady=20)# This will make it have a padding of 20 pixels on height and width,# with respect to parent rather than itself