Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out the current widget size in tkinter?

Tags:

python

tkinter

People also ask

Which method is used to specify the window size in Tkinter?

In Tkinter, minsize() method is used to set the minimum size of the Tkinter window. Using this method a user can set window's initialized size to its minimum size, and still be able to maximize and scale the window larger.

How many widgets are there in Tkinter?

Ttk Widgets Ttk comes with 18 widgets, twelve of which already existed in tkinter: Button , Checkbutton , Entry , Frame , Label , LabelFrame , Menubutton , PanedWindow , Radiobutton , Scale , Scrollbar , and Spinbox . The other six are new: Combobox , Notebook , Progressbar , Separator , Sizegrip and Treeview .

What is the use of pack () for Tkinter widget?

The pack() fill option is used to make a widget fill the entire frame. The pack() expand option is used to expand the widget if the user expands the frame. fill options: NONE (default), which will keep the widget's original size.


Use somewidget.winfo_width() and somewidget.winfo_height() to get the actual widget size, the somewidget['width'] property is only a hint given to the geometry manager.


somewidget.winfo_width() and somewidget.winfo_height() give 1. You need to update Tk (issue tk.update()) before getting these values.


You can use the function somewidget.winfo_reqheight() for height and somewidget.winfo_reqwidth() for width, but first don't forget to call the update function of the widget you want to know the dimension somewidget.update(). If you do not call the update function you will get the default value 1.