python - winsound stops ongoing animation -


i'm newer python, , new tkinter, , need playing sound every time ball in screen moves. code have

def leftmove(event):     canvas.move(circle_item2, -5, 0)     x1, y1, x2, y2 = canvas.coords(circle_item)     winsound.playsound('doorslam.wav',winsound.snd_filename)  rightmove(event):  canvas.move(circle_item2, 5, 0)  x1, y1, x2, y2 = canvas.coords(circle_item)  def upmove(event):  canvas.move(circle_item2, 0, -5)  canvas.after(.1, upmove)  def downmove(event):  canvas.move(circle_item2, 0, 5)  x1, y1, x2, y2 = canvas.coords(circle_item)  root.bind('<left>',leftmove) root.bind('<right>',rightmove) root.bind('<up>',upmove) root.bind('<down>',downmove) 

the problem every time press left key, stops animation until sound done playing. proper way make both play @ same time?

play sound in separate thread, this:

playsound = lambda: winsound.playsound('doorslam.wav',winsound.snd_filename) t = threading.thread(target = lambda: playsound) t.start() 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -