Python 3.8
OS windows 10
I'm trying to create an alarm with a GUI. Basically, when a condition is met (current time == set time) a widget must pop up with two buttons: Cancel, and Run this other code. if I press any of the buttons the alarm should stop making any sound because both acknowledge that the alarm went off.
I'm displaying the widget and using multiprocessing to play the alarm music, but I can't make the alarm stop. This is a test code that simply plays the alarm and asks the user to press enter to stop it. If I can make this work I will be able to finish my widget alarm
import multiprocessing
from playsound import playsound
def Child_process():
print("Playing music")
playsound('Perfect_Ring_Tone.mp3', block=False)
def terminator(process):
process.terminate()
if __name__ == '__main__':
# Create widget......
# Play alarm sound
P = multiprocessing.Process(target = Child_process)
P.start()
P.join()
input("Press Enter to acknowledge the alarm")
terminator(P)
print("Child Process successfully terminated")
# Do some more code...
If I do this the alarm never make a sound unless I remove the block
but then I'd have to wait for it to finish which defeats the purpose