python - Button Release Tkinter -


here's situation. have 2 tkinter buttons:

  1. play button: plays sound
  2. stop button: stop sound during play

code follows:

def play(self):     //plays file pygame module  def stop(self):     //stop using pygame stop   button( root, text ='play', command= play).pack() button( root, text ='stop', command= stop).pack() 

the issue that, when click 'play' button, stays pressed until completes playing sound, freezing entire program, not allowing me press 'stop' button during time.

how prevent program freezing while play in progress allow me other things stop?

the way prevent gui freezing while song playing use separate thread or separate processes play song. long function plays song running , in main thread, event loop can't run. if event loop can't run, gui frozen.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -