- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is correct: widget.rowconfigure or widget.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.
# 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()
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.
- Notebook widget in Tkinter
- How to horizontally center a widget using a grid() in Tkinter?
- Progressbar widget in Python Tkinter
- Underline Text in Tkinter Label widget
- Tkinter Spinbox Widget Setting Default Value
- How to center a Tkinter widget?
- How to make a Tkinter widget invisible?
- Get contents of a Tkinter Entry widget
- How to set focus for Tkinter widget?
- Vertical and Horizontal Scrollbars on Tkinter Widget
- How to clear Text widget content while clicking on the Entry widget itself in Tkinter?
- Dynamically change the widget background color in Tkinter
- How to use the Entry widget in Tkinter?
- How to update a Button widget in Tkinter?
- Getting the Cursor position in Tkinter Entry widget