I use the try-except inside the while loop, like this. The variable "done" is the flag. Set it to True and it will exit.Same with your button.
Code:
done = Falsewhile not done: try: led.off() # call the image method image("elevator.jpg") if(button.is_pressed == True): done = True led.on() time.sleep(2) # call the video method video("handshake1080.mp4") led.off() except KeyboardInterrupt: done = True quit()
Statistics: Posted by SurferTim — Mon Jan 20, 2025 8:42 am