tkinter python 入口高度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24501606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
tkinter python entry height
提问by Abdul Hamid
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?
我正在制作一个简单的应用程序只是为了练习 python,我想在其中编写文本,就好像它是记事本一样。但是,我不能让我的条目更大。我正在为此使用 tkinter。有人知道如何使条目的高度更大吗?
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.
我知道这不起作用,因为没有“高度”的属性。但是,我看到有一个 width 属性。
采纳答案by Abdul Hamid
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:
听起来您正在寻找tkinter.Text
,它允许您调整小部件的高度和宽度。下面是一个简单的脚本来演示:
from tkinter import Text, Tk
r = Tk()
r.geometry("400x400")
t = Text(r, height=20, width=40)
t.pack()
r.mainloop()
回答by Damjan
Another way would be to increase the internal padding by adding this in the pack method:
另一种方法是通过在 pack 方法中添加以下内容来增加内部填充:
...
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()
例如。这对我来说适用于“条目”,它也适用于 .grid()
回答by Harish Kumawat
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 thisgithub
了解更多关注这个github
output image this is output of above code
输出图像这是上述代码的输出
回答by kalsara Magamage
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()
回答by Leon Zou
Actually it's very easy. You don't need to set "height" in the "Entry()", but in the "place()". for example:
其实这很容易。您不需要在“Entry()”中设置“height”,而是在“place()”中设置。例如:
from tkinter import Entry, Tk
window = Tk()
t = Entry(window)
t.place(width=150,height=50)
window.mainloop()
回答by Srinjay Vatsa
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 !
根据您的需要更改值!有用 !