当我运行此代码时:
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)