Tkinter Pack Manager acts based on using the extra space within the parent widget. While packing a widget, we can specify whether the widget should shrink or fill in the entire screen. In order to enable the widget to grow in the entire window, we can use the 'fill' property. It helps to fill the widget in the screen by adding “x” as horizontal, “y” as vertical or “BOTH”.
Whenever we use expand(boolean) property, then we are generally resizing the widget size to expand in its available space. It takes boolean values as true or false. When the expand property is true for the widget, it means we can enable the grow property. On the other hand, if the expand property is set to false, it means we will disable the grow property of widgets.
#Import tkinter library from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the Geometry win.geometry("750x250") #Create a Labelwin= Tk() Label(win, text= "Hey! There",font=('Helvetica 25 bold'), background= "burlywood1").pack(fill=BOTH, expand=1,padx=20,pady=20) win.mainloop()
Executing the above code snippet will display a full width text window.
Now, expand the screen a little bit to see the changes that the text adjusts its size in the entire window.