- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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 resize an Entry Box by height in Tkinter?
An Entry widget in a Tkinter application supports singleline user inputs. You can configure the size of an Entry widget such as its width using the width property. However, tkinter has no height property to set the height of an Entry widget. To set the height, you can use the font('font_name', font-size) property. The font size of the text in an Entry widget always works as a height of the Entry widget.
Let us take an example to understand this more clearly. Follow the steps given below −
Import the required libraries
Create an Entry widget, set its width and height by specifying the font('font-name', font-size) property.
Create a Button to print the name of the user with the help of a Label widget.
Define a function to create a Label to display the name of the users.
Use the get() function to return the string input from the Entry widget.
# Import the required libraries from tkinter import * # Create an instance of tkinter frame win = Tk() # Set the size of the tkinter window win.geometry("700x350") # Define a function def myClick(): greet= "Hello " + name.get() label=Label(win, text=greet, font=('Arial', 12)) label.pack(pady=10) # Create an entry widget name=Entry(win, width=50, font=('Arial 24')) name.pack(padx=10, pady=10) # Create a button button=Button(win, text="Submit", command=myClick) button.pack(pady=10) win.mainloop()
Running the above program will display a window with an Entry widget asking users to enter their name and a Button to submit the name. When you hit "submit", it will display a Label widget on the screen.
Now enter your name in the field and click "Submit" to see the output.
- Related Articles
- How to get an Entry box within a Messagebox in Tkinter?
- How to place the text at the center of an Entry box in Tkinter?
- Creating a popup message box with an Entry field in tkinter
- How to resize an image using Tkinter?
- How to disable an Entry widget in Tkinter?
- How to add placeholder to an Entry in tkinter?
- How to explicitly resize frames in tkinter?
- How to interactively validate an Entry widget content in tkinter?
- How to get the value of an Entry widget in Tkinter?
- How To Dynamically Resize Button Text in Tkinter?
- How to insert the current time in an Entry Widget in Tkinter?
- How to use a StringVar object in an Entry widget in Tkinter?
- How to use the Entry widget in Tkinter?
- How to create a Password Entry Field in Tkinter?
- How to set focus on Entry widget in Tkinter?