如何在Tkinter中通过高度调整Entry Box的大小?

huangapple go评论79阅读模式
英文:

How to resize an Entry Box by height in Tkinter?

问题

有没有一种简便的方法来增加Tkinter Entry对象的高度,就像在代码中所示:

website_entry = Entry(width=35,bg="#001C30",fg="white")
website_entry.grid(column=1,row=1,columnspan=2)
website_entry.focus()

尝试使用以下方法:

widget.place(x=int,y=int,width=int,height=int)

但是这会导致与.grid方法一起使用时出现错误。

英文:

is there any short method to increase the height of website_entry Tkinter Entry object as in code -

> website_entry = Entry(width=35,bg="#001C30",fg="white")
> website_entry.grid(column=1,row=1,columnspan=2)
> website_entry.focus()

tried using

widget.place(x=int,y=int,width=int,height=int)

but it creates error to be created with .grid method

答案1

得分: 0

很抱歉,目前没有办法直接告诉Entry组件按你所需的方式增加高度。该组件的高度由字体大小决定。你可以像这样更改字体和字体大小:

website_entry = Entry(width=35, bg="#001C30", fg="white", font=('Arial', 40))

请注意,你可以选择任何你想要的字体,不一定非要是Arial。更一般地说:

font=('font_name', font_size)
英文:

Unfortunately there's no way to explicitly tell the Entry to increase in height as you have. The height of the box is dictated by the font size. You can change the font and font size like this:

website_entry = Entry(width=35,bg="#001C30",fg="white", font=('Arial', 40))

Note that you can pick any font that you want, it doesn't have to be Arial.
More generally:

font=('font_name', font_size)

huangapple
  • 本文由 发表于 2023年7月27日 18:16:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76778732.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定