1#How to change the font of a label in Tkinter
2
3#Import
4from tkinter import *
5
6#Screen
7window = Tk()
8window.title("New Window")
9window.geometry("300x250")
10
11Label(window, text = "This is my new project in python!", font = ("Bahnschrift", 14)).pack()
12#-------------------------------------------------------------------------------------------
13#'font' tells python that we are going to do something with the font
14#-------------------------------------------------------------------------------------------
15#'()' are needed becuase that is just how python works
16#-------------------------------------------------------------------------------------------
17#'"___"' put your font name in the quotes
18#-------------------------------------------------------------------------------------------
19#10 put vyour fontsize after adding a comma after the font name
20#-------------------------------------------------------------------------------------------
1 pythonCopyimport tkinter as tk
2
3class Test():
4 def __init__(self):
5 self.root = tk.Tk()
6 self.text = tk.StringVar()
7 self.text.set("Test")
8 self.label = tk.Label(self.root, textvariable=self.text)
9
10 self.button = tk.Button(self.root,
11 text="Click to change text below",
12 command=self.changeText)
13 self.button.pack()
14 self.label.pack()
15 self.root.mainloop()
16
17 def changeText(self):
18 self.text.set("Text updated")
19
20app=Test()
21
1stud_input=StringVar()
2stud_input.set("Label")
3lbl3=Label(add_image_frame,textvariable=stud_input,bg="#ED6244",fg="black").grid(row=4,column=0)
4stud_input.set("Changed Label")