我试图用tkiner中的一个按钮打开保存的视频,但我一直收到一个错误-
AttributeError: 'Biceps' object has no attribute 'os'
这是我的密码
class Biceps(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Biceps!!!", font=LARGE_FONT)
label.pack(pady=10,padx=10)
button1 = tk.Button(self, text="Back to Home",
command=lambda: controller.show_frame(StartPage))
button1.pack()
button2 = tk.Button(self, text="Back to Menu",
command=lambda: controller.show_frame(Menu))
button2.pack()
rb1 = tk.Button(self, text = "Play", command=self.video).pack()
def video(self):
self.os.system("J:\Comp Project\Bicep.mp4")
这是错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35-32\lib\tkinter\__init__.py", line 1550, in __call__
return self.func(*args)
File "D:\Comp Project\Computer Science project2 test.py", line 253, in video
self.os.system("J:\Comp Project\Bicep.mp4")
AttributeError: 'Biceps' object has no attribute 'os'
在
video
方法中,self
引用在Biceps
类上定义video
方法的类的实例。这个类没有os
属性,因此会出现错误。如果您在模块中导入了os
,您应该直接访问它。你知道吗尝试:
问题就在这里。你知道吗
试试这个
您正在尝试调用名为
os
的Biceps
属性,在这里您应该导入os
库并调用system
。你知道吗相关问题 更多 >
编程相关推荐