ter*_*naz 12 python tkinter python-3.x
这是我第一次使用Tkinter.我已经导入了它,直到这一刻它一直在努力.文件类型似乎有问题?我也在Mac上,如果这有任何区别的话.
这是我的代码:
def importTracks(self):
self.fname = askopenfilename(filetypes=(("Mp3 Files", "*.mp3")))
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误,
/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /Users/accudeveloper/PycharmProjects/AccuAdmin2.0/AccuAdmin2.0.py
Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/__init__.py", line 1533, in __call__
return self.func(*args)
File "/Users/accudeveloper/PycharmProjects/AccuAdmin2.0/AccuAdmin2.0.py", line 68, in importTracks
self.fname = askopenfilename(filetypes=(("Mp3 Files", "*.mp3")))
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/filedialog.py", line 375, in askopenfilename
return Open(**options).show()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/commondialog.py", line 48, in show
s = w.tk.call(self.command, *w._options(self.options))
_tkinter.TclError: bad file type "*.mp3", should be "typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?
Run Code Online (Sandbox Code Playgroud)
Kev*_*vin 21
filetypes=(("Mp3 Files", "*.mp3"))相当于filetypes=("Mp3 Files", "*.mp3").我猜你打算将外括号对作为一个元组,但这需要一个尾随逗号.或者你可以使用一个列表.
self.fname = askopenfilename(filetypes=(("Mp3 Files", "*.mp3"),))
Run Code Online (Sandbox Code Playgroud)
要么
self.fname = askopenfilename(filetypes=[("Mp3 Files", "*.mp3")])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5337 次 |
| 最近记录: |