Python3 Tkinter fonts not working

前端 未结 2 1507
小鲜肉
小鲜肉 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()
    
    0 讨论(0)
  • 2021-01-12 21:01
    from tkinter import *
    from time import sleep
    
    window = Tk()
    window.geometry("350x400")
    window.title("tkinter!")
    
    lbl = Label(window, text="this is a lable", size=12)
    lbl.pack()
    
    sleep(1)
    
    lbl.configure(text="now it is a big lable", size=48)
    
    0 讨论(0)
提交回复
热议问题