0
我试图打开音乐曲目并将它添加到Pyglet中的播放器的队列中。Pyglet文件名“资源未找到”
def QueueAudio(self):
self.musicpath=filedialog.askopenfilename()
print(self.musicpath)
Player.queue(pyglet.resource.media(r"self.musicpath"))
当print语句打印文件名时,musicpath变量正常工作。玩家尝试排队时会出现错误。下面的错误。
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\pyglet\resource.py", line 605, in media
location = self._index[name]
KeyError: 'self.musicpath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\Rob\Google Drive\Coursework\Part 2\music player tests\test5.py", line 99, in QueueAudio
self.playerpath=pyglet.resource.media(r"self.musicpath")
File "C:\Python33\lib\site-packages\pyglet\resource.py", line 615, in media
raise ResourceNotFoundException(name)
pyglet.resource.ResourceNotFoundException: Resource "self.musicpath" was not found on the path. Ensure that the filename has the correct captialisation.
有没有人知道这是为什么,什么可以解决它?
好主意,但它仍然没有工作。同样的错误。 – QuarterGeekster
这是_definitely_问题的一部分,毫无疑问。如果你仍然遇到* an *错误,你不可能得到*相同的确切错误(除非从文件对话框中,你选择了一个真正名为'“self.musicpath”'的文件)。新的错误应至少包括您选择的文件的名称。您可能希望将新代码和新错误消息添加到您的问题中,以显示您已经完成的研究。 –