2013-06-28 120 views
1

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

编辑:

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() 
+2

告诉我们在哪儿youre设法它 – Serial

+0

我不明白它的代码。现在它工作正常。我刚刚删除了字体参数,运行脚本,结束脚本,按Ctrl + Z,再次运行脚本,这很好...无论如何代码示例是在编辑 –

回答

0
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() 
-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() 
+1

修复代码缩进。更好的是,只需解释如何在'tk.Entry()'中使用'font'参数 –