这是我第一次使用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) C:\Users\Shalia\Desktop\accuadmin>python setup_py2exe.py py2exe
running py2exe
10 missing Modules
------------------
? PIL._imagingagg imported from PIL.ImageDraw
? PyQt4 imported from PIL.ImageQt
? PyQt5 imported from PIL.ImageQt
? PySide imported from PIL.ImageQt
? _imaging_gif imported from PIL.GifImagePlugin
? _util imported from PIL.ImageCms
? cffi imported from PIL.Image, PIL.PyAccess
? enchant imported from guess_language
? readline imported from cmd, code, pdb
? tkinter imported from PIL.ImageTk, __SCRIPT__
Building 'dist\AccuAdmin.exe'.
error: [Errno 2] No such file or directory: 'C:\\Users\\Shalia\\AppData\\Local\\
Programs\\Python\\Python35-32\\lib\\site-packages\\py2exe\\run-py3.5-win32.exe'
Run Code Online (Sandbox Code Playgroud)
所以我试着变得聪明并且去了那条路径并将run-py3.4-win32.exe重命名为run-py3.4-win32.exe,除了没有得到单独的错误.
C:\Users\Shalia\Desktop\accuadmin>python setup_py2exe.py py2exe
running …Run Code Online (Sandbox Code Playgroud) 我正在使用Python 3.4,并装有OS X Yosemite(10.10.4)。根据该网站,该版本的pytaglib应该兼容。
https://pypi.python.org/pypi/pytaglib
我尝试了页面上列出的所有安装方式,但仍然遇到相同的错误。
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv - O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c src/taglib.cpp -o build/temp.macosx-10.6-intel-3.4/src/taglib.o src/taglib.cpp:268:10: fatal error: 'taglib/tstring.h' file not found
#include "taglib/tstring.h"
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
AccuDeveloper-iMac:pytaglib-1.0.3 accudeveloper$ sudo ln -s/Developer/SDKs/MacOSX10.8.sdk MacOSX10.6.sdk
Run Code Online (Sandbox Code Playgroud)
也许它不认为我使用的是我实际使用的操作系统?
我已经创建了一个TreeView,但是当我调用特定的函数时,我希望能够隐藏某些列.所以这个TreeView最初是创建的,但是当我调用一个函数时,可以说除了[trackArtist]之外所有的列都被隐藏了.我该怎么做呢?我可以通过在函数中重写TreeView的部分(我想要出现的列)来使它工作,但这看起来非常多余.
def some_function(self):
self.tree = ttk.Treeview(self.stationBuilderMenuMiddleFrame)
ttk.Style().configure("displayField", background="#850664", foreground="#000000", fieldbackground="#FFFFFF")
ysb = ttk.Scrollbar(self.stationBuilderMenu, orient=tk.VERTICAL, command=self.tree.yview)
xsb = ttk.Scrollbar(self.stationBuilderMenu, orient=tk.HORIZONTAL, command=self.tree.xview)
self.tree.configure(yscrollcommand=ysb.set)
self.tree.configure(xscrollcommand=xsb.set)
self.tree["columns"]=("trackNumber", "trackTitle", "artistCat", "artistDisplay", "trackArtist", "album",
"albumLabel", "composer", "year", "trackDuration", "albumAsin", "albumItunes", "ISRC",
"filename", "albumCoverName", "notes")
self.tree.column("trackNumber", stretch=0, anchor=N)
self.tree.column("trackTitle", stretch=0, anchor=N)
self.tree.column("artistCat", stretch=0, anchor=N)
self.tree.column("artistDisplay", stretch=0, anchor=N)
self.tree.column("trackArtist", stretch=0, anchor=N)
self.tree.column("album", stretch=0, anchor=N)
self.tree.column("albumLabel", stretch=0, anchor=N)
self.tree.column("composer", stretch=0, anchor=N)
self.tree.column("year", stretch=0, anchor=N)
self.tree.column("trackDuration", stretch=0, anchor=N)
self.tree.column("albumAsin", stretch=0, anchor=N)
self.tree.column("albumItunes", stretch=0, anchor=N)
self.tree.column("filename", stretch=0, anchor=N)
self.tree.column("albumCoverName", stretch=0, anchor=N) …Run Code Online (Sandbox Code Playgroud) python ×3
python-3.x ×3
tkinter ×2
installation ×1
installer ×1
macos ×1
osx-yosemite ×1
pip ×1
py2exe ×1
treeview ×1