title: Python program not responding when I run it, using PyQt 5
body: <p>I am making a frequency table using PyQt 5 When I run the code, the window pops up, drawing the symbol on the screen but the window then freezes. It then says it is not responding. I do not understand whats happening. Here is the code:</p>
  <pre><code>import sys
  from PyQt5.QtWidgets import QWidget,QApplication,QTableWidget,QTableWidgetItem,QVBoxLayout
  from pynput.mouse import Button, Controller
  from pynput.keyboard import Listener, KeyCode
  a=KeyCode(char='r')
  
  def getSelectedItemData():
      for currentItem  in tableWidget.selectedItems():
          print(&quot;ROw : &quot;+str(currentItem.row())+&quot; Column : &quot;+str(currentItem.column())+&quot; &quot;+currentItem.text())
  
  app=QApplication(sys.argv)
  
  qwidget=QWidget()
  
  qwidget.setWindowTitle(&quot;Python GUI Table&quot;)
  qwidget.resize(300,400)
  
  layout=QVBoxLayout()
  
  tableWidget=QTableWidget()
  tableWidget.setColumnCount(3)
  tableWidget.setRowCount(2)
  
  #adding item in table
  tableWidget.setHorizontalHeaderItem(0,QTableWidgetItem(&quot;Scores&quot;))
  tableWidget.setHorizontalHeaderItem(1,QTableWidgetItem(&quot;Frquency&quot;))
  tableWidget.setHorizontalHeaderItem(2,QTableWidgetItem(&quot;FX&quot;))
  tableWidget.setItem(0,0,QTableWidgetItem(&quot;&quot;))
  tableWidget.setItem(0,1,QTableWidgetItem(&quot;&quot;))
  tableWidget.setItem(0,2,QTableWidgetItem(&quot;&quot;))
  
  tableWidget.setItem(1,0,QTableWidgetItem(&quot;&quot;))
  tableWidget.setItem(1,1,QTableWidgetItem(&quot;&quot;))
  tableWidget.setItem(1,2,QTableWidgetItem(&quot;&quot;))
  
  tableWidget.setItem(2,0,QTableWidgetItem(&quot;&quot;))
  tableWidget.setItem(2,1,QTableWidgetItem(&quot;&quot;))
  tableWidget.setItem(2,2,QTableWidgetItem(&quot;&quot;))
  
  tableWidget.setItem(3,0,QTableWidgetItem(&quot;&quot;))
  tableWidget.setItem(3,1,QTableWidgetItem(&quot;&quot;))
  tableWidget.setItem(3,2,QTableWidgetItem(&quot;&quot;))
  
  tableWidget.doubleClicked.connect(getSelectedItemData)
  layout.addWidget(tableWidget)
  qwidget.setLayout(layout)
  qwidget.show()
  
  #Adding loop 
  def on_press(key):
      if key == a:
          tableWidget.insertRow(tableWidget.rowCount()+1)
  
  with Listener(on_press=on_press) as listener:
      listener.join()
  
  sys.exit(app.exec_())  
  
  </code></pre>