问题描述
我一直在尝试制作一个假的核发射控制面板,并且我想播放一些声音以及按钮。我认为尝试在单击大红色按钮后出现的两个按钮中添加声音效果会很有趣,但是那根本行不通。
我尝试过PlaySound("explosion.wav",SND_FILENAME)
,然后尝试winsound.PlaySound("exploion.wav",winsound.SND_FILENAME
,但他们只是给了我:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Nicholas Blundell\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py",line 1705,in __call__
return self.func(*args)
File "C:\Users\Nicholas Blundell\Documents\documents backup\vol 4 - documents of post-now\code\python\multiple file programs\nukes\control panel for nucular launch.py",line 18,in fraud
winsound.PlaySound("attack.wav",winsound.SND_FILENAME )
NameError: name 'winsound' is not defined
然后它给了我:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Nicholas Blundell\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py",line 13,in win
winsound.PlaySound("Explosion3.wav",winsound.SND_FILENAME )
NameError: name 'winsound' is not defined
我的代码:
def startkeypad():
def win():
label.delete(0,tk.END)
label.insert(0,"account vertified,nukes succesfully launched")
for i in range(10):
winsound.PlaySound("Explosion3.wav",winsound.SND_FILENAME )
sleep(0.25)
def fraud():
label.delete(0,"account is fraud,nuke launch unsucesful")
winsound.PlaySound("attack.wav",winsound.SND_FILENAME )
buttonone = tk.Button(
text = "press either me or him",bg = "yellow",command = win
)
buttontwo = tk.Button(
text = "press either me or her",bg = "green",command = fraud
)
label = tk.Entry(
text = "press one of the buttons",width = 50
)
buttonone.grid(row=3,column=1)
buttontwo.grid(row=3,column=3)
label.grid(row=3,column=2)
按钮:
bigredlaunchbutton = tk.Button(
text = "LAUNCH NUKES",command = startkeypad,bg = "red",width = 16,height = 2,)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)