Hello i have a Python program with a function "startAutomation" and inside this funtion i have the loop:
for i,j in zip(int_datadelta, int_timedelta):
Att1.SetAttenuation(i) # Set attenuation
print('Set Attenuation: ',i)
lcd.display(i)
time.sleep(j)
I have 4 buttons "Start", "Stop","Pause" and "Continue". I am able to start the function "startAutomation" with the button "Start" but the other buttons i can't get working. I need something to check the loop (boolean) and if "Stop" is clicked the loop should stop; when "Pause" is clicked the loop should pause as long as the button "Continue" is clicked or aborted when "Stop" is clicked. This is my code so far:
# start button
def startAutomation(self, lcd, browse_le, rssi_le, add_le, *btns):
int_timedelta =[]
int_datadelta =[]
for i,j in zip(int_datadelta, int_timedelta):
Att1.SetAttenuation(i) # Set attenuation
print('Set Attenuation: ',i)
lcd.display(i)
time.sleep(j)
def parsed():
btn3 = QtWidgets.QPushButton('Start')
btn4 = QtWidgets.QPushButton('Stop')
btn10 = QtWidgets.QPushButton('Pause')
btn11 = QtWidgets.QPushButton('Continue')
btn3.clicked.connect(functools.partial(self.startAutomation, lcd, le, le4, le5, rbtn, rbtn2, rbtn3))
btn4.clicked.connect(functools.partial(self.stopAutomation))
btn10.clicked.connect(functools.partial(self.pauseAutomation))
btn11.clicked.connect(functools.partial(self.continueAutomation))
hbox3.addWidget(btn3)
hbox3.addWidget(btn4)
hbox3.addWidget(btn10)
hbox3.addWidget(btn11)
...
return vbox
# stop button
def stopAutomation(self):
print ("Stop")
# pause button
def pauseAutomation(self):
print ("Pause")
# continue button
def continueAutomation(self):
print ("Continue")
I tried several things whith a while loop but i can't get it working. It would be glad if someone could help ?