tkinter python entry height

你。 提交于 2019-12-29 06:59:36

问题


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.


回答1:


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



回答2:


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




回答3:


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




回答4:


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



回答5:


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

from tkinter import Entry, Tk

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

window.mainloop()


来源:https://stackoverflow.com/questions/24501606/tkinter-python-entry-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!