import tkinter.font as tkFont
import tkinter.messagebox as messagebox
运行上面代码时,报错没有tkinter.font模板
报错提示:
import tkinter.font as tkFont
ModuleNotFoundError: No module named 'tkinter.font'
如果遇到这种情况,可能是因为你的 Python 版本太旧,导致 tkinter 库中的 font 模块不存在。
在 Python 3.9 版本之前,tkinter 的 font 模块是独立的,需要使用 import tkinter.font 来导入。但是在 Python 3.9 版本之后,font 模块被合并到了 tkinter 库的 tkinter.ttk 模块中,所以你需要使用 import tkinter.ttk 来导入 font 模块。
因此,如果你使用的是 Python 3.9 或更高版本,可以尝试使用 import tkinter.ttk as tkFont 来导入 font 模块。
另外,如果你使用的是 Python 3.8 或更低版本,你需要检查你的 Python 版本是否较老,如果是的话,可以尝试升级 Python 版本来解决这个问题。