Reputation: 91
TFont = ("Verdana", 36) # Changes font
Currently, I am trying to change the font size for a GUI in Python. No matter what I change here, the font size in the window stays the same.
Here is how my code looks currently:
TFont = ("Verdana", 36) # Change font
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.iconbitmap(self, default = "GUIIconICO.ico")
tk.Tk.wm_title(self, "Graduate Technical Project")
container = tk.Frame(self)
container.pack(side = "top", fill = "both", expand = True)
container.grid_rowconfigure(0, weight = 1)
container.grid_columnconfigure(0, weight = 1)
self.frames = {}
for F in (TitleScreen, PlayerPage, SessionPage, PlayerPosition):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row = 0, column = 0, sticky = "nsew")
self.show_frame(TitleScreen)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class TitleScreen(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
label = tk.Label(self, text = "Home Page", font = "TFont")
label.pack(side = "top")
button1 = ttk.Button(self, text = "Player", command = lambda : controller.show_frame(PlayerPage))
button1.pack(side = tk.LEFT)
button6 = ttk.Button(self, text = "Session", command = lambda : controller.show_frame(SessionPage))
button6.pack(side = tk.LEFT)
button10 = ttk.Button(self, text = "Player Position", command = lambda : controller.show_frame(PlayerPosition))
button10.pack(side = tk.LEFT)
Could anyone help?
Upvotes: 0
Views: 1103
Reputation: 91
Solved, changed TFont from a string to a variable as recommended
label = tk.Label(self, text = "Home Page", font =
"TFont")label = tk.Label(self, text = "Home Page", font = TFont)
Whilst not listed in this query, TFont was also inside of a parent class causing an error. Placing the TFont variable outside this class seemed to fix this.
Upvotes: 1