python - Button Release Tkinter -
here's situation. have 2 tkinter buttons:
- play button: plays sound
- 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
Post a Comment