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

# Define a function
def myClick():
   greet= "Hello " + name.get()
   label=Label(win, text=greet, font=('Arial', 12))

# 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)



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.