Tkinter does not change font family Tkinter does not change font family tkinter tkinter

Tkinter does not change font family


How exactly is it not working? The following does for me (using Python 3.6.2) as you can see in the screenshot:

from tkinter import *import tkinter.font as fontclass Window:    def __init__(self):        root = Tk()        #print(font.families())  # print list of what's available        root.title("Serial Connection Program")        self.mainFrame = Frame(root)        self.mainFrame.pack()        def_font=font.Font(family='Times')        self.portLabel = Label(self.mainFrame, text="Port1: ", font=def_font)        self.portLabel.pack()        my_font=font.Font(family='Arial')        self.portLabel = Label(self.mainFrame, text="Port2: ", font=my_font)        self.portLabel.pack()        root.mainloop()win = Window()

screenshot of tkinter window with buttons with two different fonts


I had a similar problem in Raspbian OS.

I changed 'Code-Bold' to 'codebold' and it worked. So for you, maybe try changing Times -> times.


I had the same issue in Linux. since the fonts are more limited in Linux, you have to list all the fonts available in your system with font.families() then choose the desired font from the list.