Python3 Tkinter fonts not working

前端 未结 2 1628
小鲜肉
小鲜肉 2021-01-12 20:42

I am using python 3.3 with tkinter, and the package python3-tk is installed. In most docs the old \"import tkFont\" is used, which is not working any more.

This is s

2条回答
  •  醉话见心
    2021-01-12 21:01

    You should import font not fonts. Also, if the code you posted is actual code, you are neglecting to create a root window before working with fonts. You must create a root window first.

    from tkinter import font
    import tkinter as tk
    ...
    root = tk.Tk()
    ...
    appHighlightFont = font.Font(family='Helvetica', size=12, weight='bold')
    font.families()
    

提交回复
热议问题