At the bottom of the below code, I have a while loop set to stop when unread
is false
, which occurs inside of a def
after a button is pushed (this is on an RPi). Everything is successful in execution. I have comments detailing more, since it's easier to explain that way. I'm fairly new to python, so apologies if this is a simple error.
from customWaveshare import *
import sys
sys.path.insert(1, "../lib")
import os
from gpiozero import Button
btn = Button(5) # GPIO button
unread = True # Default for use in while loop
def handleBtnPress():
unread = False # Condition for while loop broken, but loop doesn't stop
os.system("python displayMessage.py") # this code runs, and then stops running,
while unread is not False:
os.system("echo running") # this is printed continuously, indicating that the code never stops even after the below line is called successfully
btn.when_pressed = handleBtnPress # Button pushed, go to handleBtnPress()
Thanks for any and all help!