我正在尝试使用Tkinter和Python2.7编写我的第一个程序。我安装的Tkinter库是: ActiveTcl8.5.14。我的问题是:对于这种组合,什么是好的在线资源?我一直在不断地尝试和犯错,但现在我被卡住了。我正在尝试将stringVar设置为文件名。但我担心我使用的代码是针对错误版本的Python或Tkinter的。
def abrir_capitulo():
##Dialog box for selecting the chapter to be loaded.
import tkFileDialog
WORDLIST_FILENAME = tkFileDialog.askopenfilename(mode='r',parent=master,title="Archivo para abrir")这是回溯:
Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1470, in __call__
return self.func(*args)
File "/Users/Noel/Documents/Professional Development/MIT CS 6.0/Recall Game/Recall_Game.py", line 103, in abrir_capitulo
WORDLIST_FILENAME = tkFileDialog.askopenfilename(mode='r',parent=master,title="Archivo para abrir")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/tkFileDialog.py", line 125, in askopenfilename
return Open(**options).show()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/tkCommonDialog.py", line 48, in show
s = w.tk.call(self.command, *w._options(self.options))
TclError: bad option "-mode": must be -defaultextension, -filetypes, -initialdir, -initialfile, -message, -multiple, -parent, -title, -typevariable, or -command发布于 2013-08-18 14:02:10
根据askopenfilename documentation的说法,askopenfilename没有mode参数。
WORDLIST_FILENAME = tkFileDialog.askopenfilename(parent=master,title="Archivo para abrir")有关文档,请参阅http://wiki.python.org/moin/TkInter。
https://stackoverflow.com/questions/18296169
复制相似问题