title: Refresh the GUI windows
body: <p>I have a Client(C++) to Server (Python) Project.</p>
  
  <p>The client sent a Message to the server, and each Message contains three attributes.</p>
  
  <p>The Gui should show all the attributes over the screen.
  When the client sent the first message, everything works.
  But when he sent the next message I need to close the window, and when I do that it opens a new window and shows the following message, if I don't do that he doesn't show the new messages that received.</p>
  
  <p>I suspect that <code>app.exec_()</code> stop the program from getting a new message like <a href="https://stackoverflow.com/questions/23142719/pyqt-app-exec-stops-all-following-code-from-running">in this case</a>, but I'm not sure. 
  my question is :</p>
  
  <ol>
  <li><p>Is this really the case? And if so, where should I put the Thread?</p></li>
  <li><p>I never used <code>QThread</code> before, and I saw that we are doing Override for <code>Run()</code>
  and in the <code>Run()</code> method we put in all the logic, what logic I should put into my particular problem.
  you can find the full project <a href="https://github.com/shahf14/Client-To-Server-C-Phyton/blob/master/Server.py" rel="nofollow noreferrer" title="Github account">here</a></p></li>
  </ol>
  
  <p>Relevant code: </p>
  
  <pre><code>def recive(self):
  
          global income
          global table2
  
          msg = Payload(0, 0, 0)
  
          while (True):
  
              print('waiting for a connection..')
              conn, addr = self.My_socket.accept()
              print("connection has been established | " + repr(addr))
              logger.info("connection has been established | " + repr(addr))
  
              while conn:
                  myThread = MyThread()
  
                  buff = conn.recv(sizeof(msg))
  
                  print("recv %d bytes" % sizeof(msg))
                  payload_in = Payload.from_buffer_copy(buff)
  
                  print(f"Received id={payload_in.id}, counter={payload_in.counter}, opcode={payload_in.opcode}")
  
                  payload_out = payload_in
  
                  self.opcode = payload_in.opcode
  
                  if self.opcode == 1:
                      self.export()
                  elif self.opcode == 2:
                      payload_out.counter += 1
                  else:
                      logger.info("Unexpected opcode %d" % self.opcode)
  
                  nsent = conn.send(payload_out)
                  print("send %d bytes" % nsent)
                  print("send id=%d, counter=%d, opcode=%d" % (payload_out.id,
                                                               payload_out.counter,
                                                               payload_out.opcode))
                  self.setNewTable(payload_in, payload_out)
  
          print("Closing connection to client")
          print("----------------------------")
  
          sys.exit()
  
      def setNewTable(self,payload_in, payload_out):
              self.insertValues(table1, payload_in)
              self.insertValues(table2, payload_out)
              ex.show()
              app.exec_()
  
      def insertValues(self,table, payload):
              table.setItem(0, 1, QTableWidgetItem(str(payload.id)))
              table.setItem(1, 1, QTableWidgetItem(str(payload.counter)))
              table.setItem(2, 1, QTableWidgetItem(str(payload.opcode)))
  </code></pre>