I'm currently in the process of developing a GUI that appears as so:
One of my many widgets, the 'Start' button (in the bottom right hand corner), serves a sort of "dual purpose". When the button is pressed, it runs the many functions that are interconnected to an actual instrument, but also once it is pressed, the text changes to 'Stop' and now it acts as a stop button. What I'm attempting is when this 'stop' button is pressed, it terminates all active code and halts the program. I just can't seem to figure out how to do a 'realtime' check on the button status. As I have it now, an if statement checks the status of the button, if it is clicked, all the functions run. However, wouldn't this mean that regardless of the state of the button AFTER it is clicked, it will run through the entirety of the code before terminating? How do I have it so that when the 'stop' button is clicked it terminates the program at any point in the code?
This is my function for the text change:
def startStopButtonTextChange(self):
if self.startStopButton is not None:
text = self.startStopButton.text()
self.startStopButton.setText("STOP" if text == "START" else "START")
And this is where I am stumped
def startStopButton_clicked(self):
#Call the function to change the text
startStopButtonTextChange(self)
if self.startStopButton.isChecked():
#Do the stuff
else:
#TERMINATE THE PROGRAM
Edit for clarification: "Do the stuff" is many, many functions. It will take actual real time minutes to produce a result due to the nature of the instrument
