tkinter python entry height
Asked Answered
A

8

17

I'm making a simple app just to practice python in which I want to write text as if it were Notepad. However, I can't make my entry bigger. I'm using tkinter for this. Does anybody know how to make the height of an entry bigger?

I tried something like this:

f = Frame()
f.pack()
e = Entry(f,textvariable=1,height=20)
e.pack()

I know this doesn't work because there isn't a property of "height". However, I see that there is a width property.

Alexaalexander answered 1/7, 2014 at 2:22 Comment(1)
Does this answer your question? How do I set the width of an Tkinter Entry widget in pixels?Faunia
L
3

You can also change it by changing the font size :

Entry(
root,
font=("default", 40 or 20 whatever )

)
Liebman answered 30/10, 2020 at 9:0 Comment(0)
P
31

It sounds like you are looking for tkinter.Text, which allows you to adjust both the height and width of the widget. Below is a simple script to demonstrate:

from tkinter import Text, Tk

r = Tk()
r.geometry("400x400")

t = Text(r, height=20, width=40)
t.pack()

r.mainloop()
Prefix answered 1/7, 2014 at 2:29 Comment(0)
B
17

Another way would be to increase the internal padding by adding this in the pack method:

...
e = Entry(f,textvariable=1,height=20)
e.pack(ipady=3)
...

for instance. This worked for me for an 'Entry' and it also works with .grid()

Berns answered 4/12, 2015 at 19:31 Comment(4)
This should be the answer to this question. The accepted answer(i.e. @iCodez's answer) is an alternative.Caftan
@SunBear. I disagree, re-read the question and not the code snippet.Incompliant
tk.Entry() does not have a height parameter to be setBitchy
Thanks! This is technically not the answer to this question, but it did answer the question I was having. :)Arturo
H
8

Actually it's very easy. You don't need to set height in Entry(), but in place(). for example:

from tkinter import Entry, Tk

window = Tk()
t = Entry(window)
t.place(width=150,height=50)

window.mainloop()
Hazlett answered 2/7, 2019 at 9:46 Comment(0)
F
6
from tkinter import *

root=Tk()

url = Label(root,text="Enter Url")
url.grid(row=0,padx=10,pady=10)

entry_url = Entry(root,width="50")
entry_url.grid(row=0,column=1,padx=5,pady=10,ipady=3)

root.geometry("600x300+150+150")

root.mainloop()

learn more follow this github

output image this is output of above code

Fairley answered 7/3, 2019 at 19:13 Comment(1)
This doesn't answer the question, and doesn't create an experience similar to notepad where you can enter multiple lines of text and use carriage returns. Your solution changes the appearance of tk.entry which is a single line and meant for user input. The OP needed a solution where you have a text editor experience.Incompliant
A
3

To change an entry widget's size, you have to change it's font to a larger font.

Here is my code:

import tkinter as tk

large_font = ('Verdana',30)
small_font = ('Verdana',10)

root = tk.Tk()

entry1Var = tk.StringVar(value='Large Font!')
entry1 = tk.Entry(root,textvariable=entry1Var,font=large_font)
entry1.pack()    

entry2Var = tk.StringVar(value='Small Font!')
entry2 = tk.Entry(root,textvariable=entry2Var,font=small_font)
entry2.pack()

root.mainloop()
Approval answered 13/3, 2019 at 11:47 Comment(0)
L
3

You can also change it by changing the font size :

Entry(
root,
font=("default", 40 or 20 whatever )

)
Liebman answered 30/10, 2020 at 9:0 Comment(0)
S
0

You can change the height of the entry widget. To do so you can write:

entry_box.place(height=40, width=100)

Change the value according to your needs! IT WORKS !

Swanhilda answered 5/5, 2020 at 18:36 Comment(0)
C
0

By using the .place(width= , height= ) method, you can adjust the size of the entry. Another Method is to change the font of the text, but that limits your ability to change the font.

.place() method:

textbox.place(width= (Your desired width) ,height= (Your desired height))

Font Method:

textbox = Entry(root, font=("default", (Your font size))

Hope this helps!

Chou answered 8/8, 2022 at 19:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.