title: PyQt5 Designer. Getting a button event to function
body: <p>I am trying to get a button event handler working using Qt Designer. </p>
  
  <p>I am using Anaconda-Spyder with Python 3.6</p>
  
  <p>The form appears but the button <code>btn_browse</code> does not function. The line edit box has a cursor in it and you can type into it.</p>
  
  <p>The Python file generated automatically from the ui is below. It is called <code>file_reader.py</code></p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  
  class Ui_Dialog(object):
      def setupUi(self, Dialog):
          Dialog.setObjectName("Dialog")
          Dialog.resize(640, 320)
          self.btn_browse = QtWidgets.QPushButton(Dialog)
          self.btn_browse.setGeometry(QtCore.QRect(220, 50, 113, 32))
          self.btn_browse.setObjectName("btn_browse")
          self.lineEdit = QtWidgets.QLineEdit(Dialog)
          self.lineEdit.setGeometry(QtCore.QRect(170, 120, 241, 131))
          self.lineEdit.setObjectName("lineEdit")
          self.retranslateUi(Dialog)
          QtCore.QMetaObject.connectSlotsByName(Dialog)
  
      def retranslateUi(self, Dialog):
          _translate = QtCore.QCoreApplication.translate
          Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
          self.btn_browse.setText(_translate("Dialog", "MyButton"))
  </code></pre>
  
  <p>The code I have used (pretty much from the QtDesigner Docs site) is</p>
  
  <pre><code>from PyQt5 import QtGui
  from PyQt5.QtWidgets import QDialog, QApplication
  from file_reader import Ui_Dialog
  class Dialog(QDialog):
      def __init__(self):
          super(Dialog, self).__init__()
  
          # Set up the user interface from Designer.
          self.ui = Ui_Dialog()
          self.ui.setupUi(self)
  
          # Make some local modifications.
          self.ui.colorDepthCombo.addItem("2 colors (1 bit per pixel)")
  
          # Connect up the buttons.
          self.ui.btn_browse.clicked.connect(self.browse_folder)
  
  
      def browse_folder(self):
          #exit
          print("Hello")
          #self.textBrowser.clear() # In case there are any existing elements in the list
          directory = QtGui.QFileDialog.getExistingDirectory(self,"Pick a folder")
          # execute getExistingDirectory dialog and set the directory variable to be equal
          # to the user selected directory
  
          if directory: # if user didn't pick a directory don't continue
              for file_name in os.listdir(directory): # for all files, if any, in the directory
                  self.listWidget.addItem(file_name)  # add file to the listWidget
  
  
  
  
  import sys        
  app = QApplication(sys.argv)
  window = Dialog() #Also tried QDialog() here
  ui = Ui_Dialog()
  ui.setupUi(window)
  
  window.show()
  sys.exit(app.exec_())
  </code></pre>
  
  <p>I don't think the function <code>browse_folder</code> is being called. I think the issue might be the QDialog class being used rather than QMainForm. I</p>
  
  <p>I am working on that. Also, I am unsure what the x switch in the ui convertor does.</p>
  
  <p>I have looked at several answers here and can't see what I am doing wrong.</p>