【发布时间】:2015-12-16 02:19:42
【问题描述】:
我正在使用带有 tkinter 的 python 3.3,并且安装了包 python3-tk。在大多数文档中,使用的是旧的“import tkFont”,它不再起作用了。
这应该可以工作:
from tkinter import font
appHighlightFont = font.Font(family='Helvetica', size=12, weight='bold')
font.families()
但是,我在第二行得到了这个异常:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.3/tkinter/font.py", line 92, in __init__
root.tk.call("font", "create", self.name, *font)
AttributeError: 'NoneType' object has no attribute 'tk'
我检查了http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/fonts.html 和 http://www.tkdocs.com/tutorial/fonts.html,它们是迄今为止最有用的 tkinter 文档。
不幸的是,我仍然无法弄清楚我做错了什么。
【问题讨论】:
标签: python python-3.x fonts tkinter python-import