Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

tkinter
python

How to resize an entry box by height in Tkinter

Gutha Vamsi Krishna

Overview

Tkinter is the standard GUI library for Python. We can create graphical applications using this library in Python. In this Answer, we'll learn how to increase the height of the entry widget in Tkinter.

The entry widget is used to take a single line input from the user. There is no in-built way to increase its size. However, it resizes itself according to the font size we provide to it. Thus, to increase the height of the entry box, we increase the font size.

Let's take a look at an example of this.

Example

In the following example, we create two entry widgets, one with a normal height and the other with a slightly more height.

from tkinter import *

#get tinker instance frame
window = Tk()

#set window size
window.geometry("600x400")


#normal entry widget
entry=Entry(window, width= 30)
entry.pack(pady=20)

#entry with increased height
large_entry=Entry(window, width= 30, font=('Arial 24'))
large_entry.pack(pady=20)



window.mainloop()

Explanation

In the above code snippet:

  • Line 1: We import everything from the tkinter package.
  • Line 4: We create an instance of the Tkinter frame and store it in a variable window. We do this to keep the widgets inside the Tkinter frame to display them.
  • Line 7: We set the window size of the Tkinter frame.
  • Line 11–12: We create the normal entry widget with a default height.
  • Line 15–17: We create another entry widget with font height 24. Since the font size is bigger in this widget, the entry box is created with more height.

RELATED TAGS

tkinter
python

CONTRIBUTOR

Gutha Vamsi Krishna
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring