title: Detecting Mechanical Button Press with Python3 and QT5
body: <p>I have an application that is developed in Python 5.3 and PyQt 7.1 (I think).  So far I have everything in the GUI working just fine.  I now need to be able to detect the pressing of two external mechanical buttons via GPIO.add_event_detect.  I added the GPIO command for detecting the falling edge of the signal and when I try to execute the code I get the "Conflicting edge detection already enabled for this GPIO Channel."
  I tried moving the the code to different classes (it's not in a while loop) just to see if I would get a different error.
  I am looking for any documentation or instructions that explains how to use the add_event_detect into an event based application like QT.<br>
  As always, much thanks!
  Mike </p>
  
  <p>EDIT:
  I tried the recommendation below and I am having an issue with execution.  The code below is only three classes - I didn't add a executable code because I wasn't sure anybody would want to spend time to add 2 N.C. buttons to GPIO pins.  I am hoping you'll be able to see an issue just by reading the code.</p>
  
  <p>The class ExecuteSession works fine.  I am trying to add the ability to read the falling edge of two signals on the GPIO pins 16 &amp; 18 in classes PStop and EStop.  When the ExecuteSession starts I can see the print statements "In PStop" and "In EStop".  When I push the buttons I don't see the other print statement.  I am pretty new to Python and Threads and would appreciate any suggestions.</p>
  
  <p>I did create a small test program to make sure the Pi was seeing the state transition, and it did.</p>
  
  <p>Thanks</p>
  
  <pre><code>class PStop(QThread):
  
      PT_event_detected = pyqtSignal(int)
      def __init__(self):
          QThread.__init__(self)
          self.queue=Queue()
          GPIO.add_event_detect(16, GPIO.FALLING, callback=self.queue.put)
          print("In PStop")
  
          def run(self):
              while True:
                  print("In PStop Run")
                  self.PT_event_detected.emit(self.queue.get())
                  print("PT EVENT " +str(self.queue.get()))
  
  class EStop(QThread):
  
      ER_event_detected = pyqtSignal(int)
      def __init__(self):
          QThread.__init__(self)
          self.queue=Queue()
          GPIO.add_event_detect(18, GPIO.FALLING, callback=self.queue.put)
          print("In EStop")
  
          def run(self):
              while True:
                  print("In EStop Run")
                  self.ER_event_detected.emit(self.queue.get())                
                  print("ER EVENT " +str(self.queue.get()))
  
  class ExecuteSession(QThread):
  
      PBValueSig = pyqtSignal(int)
      PBValueDone = pyqtSignal(int)
      PBValuePause = pyqtSignal(int)
      PBTimeActual = pyqtSignal(int)
  
      durComplete = 0
  
      def __init__(self, dur='', pause='', stopExe =''):
          QThread.__init__(self)
          self.dur = dur
          self.pause = pause
          self.stopExe = stopExe
  
          self.E_Stop = EStop()
          self.E_Stop.ER_event_detected.connect(self.Ext_Stop_Detect)
          self.E_Stop.start()
  
          self.P_Stop = PStop()
          self.P_Stop.PT_event_detected.connect(self.Ext_Stop_Detect)
          self.P_Stop.start()
  
      def stop(self):
          self.stop()
  
      def __del__(self):
          self.wait()
  
      def run(self):
          i = 1
          while i &lt;= dur: #self.dur:
              iA = i
              if self.stopExe == True:
                  durComplete = i
                  i = self.dur + 1 #Complete
  
              elif self.pause == False: #12/15 added el
                  self.PBValueSig.emit(i)
                  i = i + 1
                  durComplete = i
                  time.sleep(1)
          self.PBTimeActual.emit(iA)
          time.sleep(1)
          self.PBValueDone.emit(durComplete)
  
  def Ext_Stop_Detect(self, channel):
      print("CHANNEL " +str(channel))
  </code></pre>