
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Widget Rowconfigure vs Grid Rowconfigure in Tkinter
While building an application with Tkinter, we can use many components and widgets to extend the application. To render the widgets in the application, we use the Geometry Manager.
The geometry manager configures the widget position and size within the window. The Grid Geometry manager treats the widget to place in rows and columns.
If we want to span the widget and extend in one more cell or column, we use widget.rowconfigure() or widget.grid_rowconfigure(). It takes params such as weight and row/col value.
The widget.rowconfigure() is sometimes used in place of widget.grid_rowconfigure(). Using these methods will allow the widget to have a weight property that can be applied in rows and columns.
Example
# Import the required libraries from tkinter import * # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") # Add a new Frame f1=Frame(win, background="bisque", width=10, height=100) f2=Frame(win, background="blue", width=10, height=100) # Add weight property to span the widget in remaining space f1.grid(row=0, column=0, sticky="nsew") f2.grid(row=0, column=1, sticky="nsew") win.columnconfigure(0, weight=1) win.rowconfigure(1, weight=0) win.mainloop()
Output
Running the above code will display some colored bands in the window. The bands can be given weight property to provide extra space in the given column.