title: PyQt5 - Dialog not closing via push button
body: <p>Im having trouble getting my cancel button to close the dialog for a simple login app. </p>
  
  <p>Im going round in circles trying to figure this out but I keep getting unknown "attribute errors".</p>
  
  <p>I used pyuic5 to generate the ptyhon code for the ui and then copied over that portion to the end of main.py</p>
  
  <p>This part fo the code looks different to other examples ive seen on the web</p>
  
  <p>Any advice?</p>
  
  <p>Login_Dialog.py</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  
  class Ui_loginDialog(object):
      def setupUi(self, loginDialog):
      loginDialog.setObjectName("loginDialog")
      loginDialog.resize(400, 300)
      self.newuser_pushButton = QtWidgets.QPushButton(loginDialog)
      self.newuser_pushButton.setGeometry(QtCore.QRect(50, 230, 75, 31))
      self.newuser_pushButton.setObjectName("newuser_pushButton")
      self.login_pushButton = QtWidgets.QPushButton(loginDialog)
      self.login_pushButton.setGeometry(QtCore.QRect(160, 230, 75, 31))
      self.login_pushButton.setObjectName("login_pushButton")
      self.cancel_pushButton = QtWidgets.QPushButton(loginDialog)
      self.cancel_pushButton.setGeometry(QtCore.QRect(270, 230, 75, 31))
      self.cancel_pushButton.setObjectName("cancel_pushButton")
      self.username_LineEdit = QtWidgets.QLineEdit(loginDialog)
      self.username_LineEdit.setGeometry(QtCore.QRect(140, 60, 201, 31))
      self.username_LineEdit.setObjectName("username_LineEdit")
      self.password_LineEdit = QtWidgets.QLineEdit(loginDialog)
      self.password_LineEdit.setGeometry(QtCore.QRect(140, 110, 201, 31))
      self.password_LineEdit.setEchoMode(QtWidgets.QLineEdit.Password)
      self.password_LineEdit.setObjectName("password_LineEdit")
      self.label = QtWidgets.QLabel(loginDialog)
      self.label.setGeometry(QtCore.QRect(30, 70, 91, 16))
      self.label.setObjectName("label")
      self.label_2 = QtWidgets.QLabel(loginDialog)
      self.label_2.setGeometry(QtCore.QRect(60, 120, 47, 13))
      self.label_2.setObjectName("label_2")
  
      self.retranslateUi(loginDialog)
      QtCore.QMetaObject.connectSlotsByName(loginDialog)
  
  def retranslateUi(self, loginDialog):
      _translate = QtCore.QCoreApplication.translate
      loginDialog.setWindowTitle(_translate("loginDialog", "Login"))
      self.newuser_pushButton.setText(_translate("loginDialog", "New User"))
      self.login_pushButton.setText(_translate("loginDialog", "Login"))
      self.cancel_pushButton.setText(_translate("loginDialog", "Cancel"))
      self.label.setText(_translate("loginDialog", "Username (Email)"))
      self.label_2.setText(_translate("loginDialog", "Password"))
  </code></pre>
  
  <p>main.py</p>
  
  <pre><code>import sys
  import Login_Dialog
  from PyQt5 import QtCore, QtGui, QtWidgets
  from Login_Dialog import Ui_loginDialog
  
  
  
  class ui(Login_Dialog):
  
      def __init__(self):
          super(ui, self).__init__()
          self.cancel_pushButton.clicked.connect(self.reject)
  
      def reject(self):
          self.close()
  
  
  if __name__ == "__main__":
      app = QtWidgets.QApplication(sys.argv)
      loginDialog = QtWidgets.QDialog()
      ui = Ui_loginDialog()
      ui.setupUi(loginDialog)
      loginDialog.show()
      sys.exit(app.exec_())
  </code></pre>