Tk按钮激活playsound()函数时Python崩溃
当我运行tkinter代码时,当用函数playsound()作为命令按下按钮时,它会使python崩溃。 文件在此:Tk按钮激活playsound()函数时Python崩溃,python,tkinter,Python,Tkinter,当我运行tkinter代码时,当用函数playsound()作为命令按下按钮时,它会使python崩溃。 文件在此: import Tkinter as tk from playsound import playsound class App: def __init__(self,master): frame = tk.Frame(master, height=100,width=200) frame.pack() self.label1
import Tkinter as tk
from playsound import playsound
class App:
def __init__(self,master):
frame = tk.Frame(master, height=100,width=200)
frame.pack()
self.label1 = tk.Label(frame,
text="Now playing: \'A song\'",
fg = "blue")
self.label1.pack()
self.button = tk.Button(frame,
text="Play the Beats!", fg="light green",
command=self.sound)
self.button.pack()
self.quitbutton = tk.Button(frame,
text="Stop the beats", fg="red",
command=quit)
self.quitbutton.pack()
def sound(self):
playsound('/Users/willgreen1/Documents/Sounds/sound.mp3')
def main():
root = tk.Tk()
app = App(root)
root.mainloop()
main()
请共享
playsound()
函数的代码,否则没有人可以帮助您。当您说“它崩溃”时,您的意思是程序完全退出,还是冻结?