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()
4

4 回答 4

4

使用font=("Calibri 12") 它对我有用)

于 2018-11-10T19:34:27.670 回答
3
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()
于 2014-05-28T20:36:05.373 回答
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()
于 2019-03-30T07:28:23.553 回答
-4
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()
于 2017-04-20T19:15:04.917 回答