Исходя из вашего кода, вы импортируете модуль tkinter.font
(как Font
) и пытаетесь вызвать его. Но модули Python не могут быть вызваны. Я думаю, что вы пытаетесь импортировать Font
из модуля tkinter.font
.
Обратите внимание, что сначала вы должны создать корневое окно.
Вот пересмотренный код:
from tkinter import *
from tkinter.font import Font
# Define Font
root = Tk() # create the root window
root.title("Hello, World!") # set the title of the root window
titleFont = Font(family="Arial", size="48") # create the Font object (don't forget to specify its master!)
Label(root, text="Hello, World!", font=titleFont).pack() # create a label to preview the font
root.mainloop() # start the root window's mainloop