- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the min and max height or width of a Frame in Tkinter?
In order to manage too many widgets in the window, we can use Frame widgets in Tkinter. In order to place the widgets inside the frame widget, we have to set the relative width and height of the frame. To configure the relative height and width of the frame, we have to configure it using the place(relx, rely) method.
Now, let us create a frame and add a button to it.
Example
#import required libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win= Tk() #Set the geometry of the window win.geometry("750x250") #Create a LabelFrame frame= Frame(win, width= 100, height= 100, background= "green") frame.pack(fill= BOTH, expand= True) #Configure the Frame frame.place(relx=0.3, rely=.3, anchor= "c") #Create Button widget in Frame ttk.Button(frame, text= "Button").pack() win.mainloop()
Output
Running the above code will display a frame that has a minimum and maximum width/height is set.
- Related Articles
- Set min-width and max-width of an element using CSS
- Set min-height and max-height of an element using CSS
- How to set the height/width of a Label widget in Tkinter?
- How to change the width of a Frame dynamically in Tkinter?
- How do I get the width and height of a Tkinter window?
- The min-width and max-width declaration for Flexbox doesn’t work on Safari? Why?
- How to set viewport height and width in CSS
- How to set cell width and height in HTML?
- How to set padding of all widgets inside a window or frame in Tkinter?
- How to set the width of a Tkinter Entry widget in pixels?
- How to set width and height of an element using jQuery?
- How to determine the row that have min and max values in an R data frame column?
- How I can set the width and height of a JavaScript alert box?
- Getting screens height and width using Tkinter Python
- How to use min and max attributes in HTML?

Advertisements