I have 4 push buttons (open outer, close outer, open inner, close inner) which control 2 doors (via 2 relays), an inner and an outer door. Only one door can be open at a time, I have got this much of the code sorted, now the issue is when I close the outer door I would like it to disable all the other push buttons except for the "open" outer door button. Is this possible? I will paste the relevant section of my code below:
#@QtCore.pyqtSlot()
def OuterDoorOpen(self):
if Door2_Channel == 0:
return GPIO.output(self.Door1,GPIO.HIGH)
else:
return "Please Close Inner Door"
#@QtCore.pyqtSlot()
def OuterDoorClose(self):
if Door2_Channel == 1:
return
GPIO.output(self.Door2,GPIO.LOW), self.pushButton_2.setEnabled(False),
self.pushButton_3.setEnabled(False),
self.pushButton_4.setEnabled(False)
#@QtCore.pyqtSlot()
def InnerDoorOpen(self):
if Door1_Channel == 0:
return GPIO.output(self.Door2,GPIO.HIGH)
else:
return "Please Close Outer Door"
#@QtCore.pyqtSlot()
def InnerDoorClose (self):
if Door1_Channel == 1:
return GPIO.output(self.Door2,GPIO.LOW)
I have designed the GUI using QtDesigner and Im using pyqt5 on python 3.7. I am controlling the relays using a raspberry pi. Whenever I run this code and hit the pushbutton close it causes the programme to crash.
Thanks
i managed to get this to work by using partials and setting the SetEnabled to False. Here is the relevant section of the code.
def OuterDoorClose(self):
if GPIO.input(Outer)==0: #Outer Door Open
self.ui.pushButton_3.setEnabled(False)
self.ui.pushButton_4.setEnabled(False)
QtCore.QTimer.singleShot(10000,partial(self.ui.pushButton_3.setEnabled,True))
return GPIO.output(Outer,GPIO.HIGH)