小编ins*_*tek的帖子

尝试使用tkFont时的AttributeError

当我运行此代码时:

from Tkinter import *
import tkFont

class Statify():

    def __init__(self):

        ### Broken
        self.titleFont = tkFont.Font(family='Helvetica', size=24, weight='bold')
        self.option_add(*Label*font, self.titleFont)
        ###

        self.root = Tk()
        self.root.withdraw()
        self.main = Toplevel(self.root)
        self.main.title('')
        self.main_header = Frame(self.main)
        self.main_footer = Frame(self.main)
        self.main_title = Label(self.main_header, text='Statify Me v1.0 (WIP)')
        self.main_exit = Button(self.main_footer, text='Quit', command=quit)
        self.main_header.pack()
        self.main_footer.pack()
        self.main_title.pack()
        self.main_exit.pack()
        mainloop()

statify = Statify()
Run Code Online (Sandbox Code Playgroud)

我明白了:

Traceback (most recent call last):
  File "Statify.py", line 23, in <module>
    statify = Statify()
  File "Statify.py", line 7, in __init__
    self.titleFont = tkFont.Font(family='Helvetica', size=24, …
Run Code Online (Sandbox Code Playgroud)

python fonts tk-toolkit tkinter attributeerror

4
推荐指数
1
解决办法
4640
查看次数

标签 统计

attributeerror ×1

fonts ×1

python ×1

tk-toolkit ×1

tkinter ×1