使用ActiveTcl8.5.14和Python 2.7,有什么好的在线资源?

时间:2013-08-18 05:57:08

标签: python-2.7 tkinter

我正在尝试使用Tkinter和python 2.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

1 个答案:

答案 0 :(得分:0)

根据askopenfilename documentation,askopenfilename没有mode参数。

WORDLIST_FILENAME = tkFileDialog.askopenfilename(parent=master,title="Archivo para abrir")

请参阅http://wiki.python.org/moin/TkInter了解文件。

相关问题