제 프로그램에서 임의로 사운드를 재생하려고합니다. 하지만 문제는 내가들을 수 없다는 것입니다. 나는 아무런 오류가 없거나, 그런 소리를들을 수 없다. 도와 주셔서 감사합니다. 미안해, 내 영어가 나쁘다면. 또한 여기 내 코드입니다 : 당신은 wxPython에 자체에 문제가 있는지 여부를파이썬 모듈 wx는 오디오 사운드를 재생하지 않습니다.
import Tkinter as tk
import random
import wx
class SampleApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.state("zoomed")
container= tk.Frame(self)
container.config()
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=2)
container.grid_columnconfigure(0, weight=1)
self.frames={}
for F in (fenster, fensta):
frame= F(container, self)
self.frames[F]=frame
frame.grid(row=0, column=0, sticky="nsew")
frame.pack_propagate(0)
self.show_frame(fenster)
def show_frame(self, c):
frame=self.frames[c]
frame.tkraise()
class fenster(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
button=tk.Button(self, text="Start",
command=lambda: controller.show_frame(fensta))
button.pack()
class fensta(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
def ok():
def do_a():
def __init__(self, parent):
wx.Frame.__init__(self, parent)
self.test = wx.Sound('ja.wav')
self.test.Play(wx.SOUND_SYNC)
print("a")
def do_b():
def __init__(self, parent):
wx.Frame.__init__(self, parent)
self.testa = wx.Sound('nein.wav')
self.testa.Play(wx.SOUND_SYNC)
print("b")
a=random.randint(1,2)
if a==1:
do_a()
elif a==2:
do_b()
button=tk.Button(self, text="press", command=ok)
button.pack()
if __name__== "__main__":
app=SampleApp()
app.mainloop()
어떤 플랫폼을 사용하고 있습니까? –
@DizietAsahi Python IDLE 2.7을 사용하고 있습니다. – Duardo
Windows? OSX? 리눅스? wxpython을 어떻게 설치 했습니까? –