title: Python run a function on main thread from a background thread
body: <p>Created a background thread this way</p>
  <pre><code> def listenReply(self):
          while self.SOCK_LISTENING:
              fromNodeRED = self.nodeRED_sock.recv(1024).decode()
              if fromNodeRED==&quot;closeDoor&quot;:
                  self.door_closed()
  
   ...
  
      self.listenThread = Thread(target=self.listenReply, daemon=True)
      self.SOCK_LISTENING = True
      self.listenThread.start()
  </code></pre>
  <p>But self.door_closed() has some UI stuffs so that's no good. How do I call self.door_closed in main thread instead?</p>