如何在Tkinter中设置Entry的字体大小

问题描述 投票:1回答:4

我是Python的新手,我想在Entry小部件中设置字体大小。我试图设置参数font=("Calibri",12),但没有发生任何事情,字体大小就像默认值。有什么方法可以设置吗?

编辑:

from Tkinter import *

root = Tk()

EntryList = []
for i in range(81):

    EntryList.append(Entry(root,font=("Calibri",12),justify="center",width=6,bg="#1E6FBA",fg="yellow",disabledbackground="#1E6FBA",disabledforeground="yellow",highlightbackground="black",highlightcolor="red",highlightthickness=1,bd=0))
    EntryList[i].grid(row=i/9,column=i%9,ipady=14)     

root.mainloop()
python tkinter fonts size tkinter-entry
4个回答
1
投票
from Tkinter import *

root = Tk()

EntryList = []
for i in range(81):

EntryList.append(Entry(root, font = "Helvetica 44 bold",justify="center",width=6,bg="#1E6FBA",fg="yellow",disabledbackground="#1E6FBA",disabledforeground="yellow",highlightbackground="black",highlightcolor="red",highlightthickness=1,bd=0))
EntryList[i].grid(row=i/9,column=i%9,ipady=14)     

root.mainloop()

1
投票

使用font=("Calibri 12")它适用于我)


0
投票

你可以做一个变量

from Tkinter import *
import tkinter.font

root = Tk()

EntryList = []
for i in range(81):
FontOfEntryList=tkinter.font.Font(family="Calibri",size=12)
EntryList.append(Entry(root,font=FontOfEntryList,justify="center",width=6,
bg="#1E6FBA",fg="yellow",disabledbackground="#1E6FBA",disabledforeground="yellow",
highlightbackground="black",highlightcolor="red",highlightthickness=1,bd=0))
EntryList[i].grid(row=i/9,column=i%9,ipady=14)     

root.mainloop()

-2
投票
class StartPage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
                            #---------RIGHT HERE----#
    entry1 = tk.Entry(self, font="Helvetica 20 bold", width=20)
    entry1.pack(pady=5, padx=5 )



app = project1()
app.mainloop()
© www.soinside.com 2019 - 2024. All rights reserved.