我怀疑我这里有一些非常简单的错误,但我无法发现是什么。代码如下:
import Tkinter as Tk
Tk.tkMessageBox.showerror(message='some error')
给出:
AttributeError: 'module' object has no attribute 'tkMessageBox'
小部件(例如按钮、条目)工作正常。交互式地我得到了相同的结果,而且:
>>> import Tkinter as Tk
>>> print Tkinter
<module 'Tkinter' from 'C:\Python26\lib\lib-tk\Tkinter.pyc'>
和 tkMessageBox.py 位于 C:\Python26\Lib\lib-tk 中。虽然Lib/lib的大小写为什么不一样?!
这是在 Windows 上使用 Python 2.6,运行 Tkinter._test() 报告版本 8.5
最佳答案
我认为你的意思是:
import tkMessageBox
tkMessageBox.showerror(message='some error')
关于python - Tkinter导入问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7486113/