我是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()
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()
使用font=("Calibri 12")
它适用于我)
你可以做一个变量
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()
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()