我是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()
答案 0 :(得分: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 :(得分:1)
使用font=("Calibri 12")
对我有用)
答案 2 :(得分: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()
答案 3 :(得分:-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()