4

I am a newbie in Python and I would like to set font size in Entry widget. I tried to set parameter font=("Calibri",12), but nothing happened, font size is just like the default. Is there any way how to set it?

Edit:

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()
Cœur
  • 37,241
  • 25
  • 195
  • 267
Milan Skála
  • 1,656
  • 3
  • 15
  • 20
  • 3
    Show us the code where youre trying it – Serial Jun 28 '13 at 17:05
  • I don´t understand it. It works fine now. I just deleted font paramerer, ran script, ended script, pressed Ctrl+Z, ran script again and it was fine... Anyway code sample is in Edit – Milan Skála Jun 28 '13 at 17:43

4 Answers4

4

Use font=("Calibri 12") It works for me)

alexmosk25
  • 134
  • 1
  • 2
  • 12
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()
Ari
  • 39
  • 2
0

You could make a variable

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()
-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()
Gerald Leese
  • 355
  • 4
  • 13