Tkinter is used to develop GUI (Graphical User Interface) applications. It supports a variety of widgets as well as a variety of widgets methods or universal widget methods.
grid_location() method –
This method returns a tuple containing (column, row) of any specified widget. Since this method is a widget method you cannot use it with master object ( or
Tk() object). In order to use this method, you should first create a
Frame and treat it as a parent (or master).
Syntax: widget.grid_location(x, y)
x and y are the positions, relative to the upper left corner of the widget (parent widget).
In below example,
grid_location() is used to get the location of the widget in the
grid_size() method –
This method is used to get the total number of grids present in any parent widget. This is a widget method so one cannot use it with master object. One has to create a
Syntax: (columns, rows) = widget.grid_size()
Return Value: It returns total numbers of columns and rows (grids).
Below is the Python code-
Every time you click the mouse button it will return the same value until more widgets are not added OR number of rows and columns are not increased.
- Python | after method in Tkinter
- resizable() method in Tkinter | Python
- Python | pack() method in Tkinter
- Python | grid() method in Tkinter
- Python | place() method in Tkinter
- maxsize() method in Tkinter | Python
- Python | geometry method in Tkinter
- iconphoto() method in Tkinter | Python
- destroy() method in Tkinter | Python
- minsize() method in Tkinter | Python
- Python | forget_pack() and forget_grid() method in Tkinter
- Python Tkinter | Moving objects using Canvas.move() method
- Python GUI - tkinter
- RadioButton in Tkinter | Python
- Different messages in Tkinter | Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.