Set Height and Width of Tkinter Entry Widget in Python
In this tutorial, we will discuss setting the height and width of an entry widget in the Tkinter library in Python.
A Tkinter library is a GUI package containing various elements like buttons, menus, display areas, and many more which takes any input referred to as an entry widget.
Set the width of an entry widget
When dealing only with the width of an entry widget, we can do this using the following snippet-
import tkinter as tk obj = tk.Tk() obj.geometry("200x200") Entry = tk.Entry(obj, width=20) Entry.pack(pady=20) obj.mainloop()
We have imported the tkinter library and then created a window using Tk()
with geometry 200*200 and then created an entry widget with a width of 20 and packed it.
Setting both the height and width of an entry widget in Tkinter
In the above paragraph, we have discussed how to set the width of the entry widget now we will have a look on how to set both the height and width of an entry widget.
Here’s the implementation-
import tkinter as tk obj = tk.Tk() obj.geometry("400x200") Entry = tk.Entry(obj) Entry.place(x=10, y=10, width=380, height=100) obj.mainloop()
This is how we can set the height and width of an entry widget in tkinter entry widget in Python. The flow of the program is similar to the above example, here we have set the height and width of the widget as 100 and 380 respectively.
I hope, you have got to know how to set the height and width of any entry widget in Tkinter Python. Thanks for reading!
it works but is it possible to write text in that box more than 1 line