title: AttributeError: 'Ui_MainWindow' object has no attribute 'btn_click'
body: <p>I keep getting this error when trying to call the button click function. I tried the other answers about attribute errors but couldn't figure out what I have done wrong. I am trying to grab the text in a qlineedit and store that in variable training_epochs then call a function Train. Thanks in advance.
  My code below:</p>
  
  <pre><code>class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
  
          MainWindow.setObjectName("MainWindow")
          MainWindow.resize(573, 483)
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName("centralwidget")
  
          self.Epochs = QtWidgets.QLineEdit(self.centralwidget)
          self.Epochs.setGeometry(QtCore.QRect(120, 120, 113, 20))
          self.Epochs.setObjectName("Epochs")
  
          def btn_click(self):
              training_epochs=self.Epochs.text()
              Train(training_epochs)
              return
  
          self.TrainNeuralNetwork = QtWidgets.QPushButton(self.centralwidget)
          self.TrainNeuralNetwork.setGeometry(QtCore.QRect(270, 90, 141, 23))
          self.TrainNeuralNetwork.setObjectName("TrainNeuralNetwork")
          self.TrainNeuralNetwork.clicked.connect(self.btn_click) #error occurs here
  
          self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget)
          self.graphicsView.setGeometry(QtCore.QRect(240, 240, 256, 192))
          self.graphicsView.setObjectName("graphicsView")
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 573, 21))
          self.menubar.setObjectName("menubar")
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtWidgets.QStatusBar(MainWindow)
          self.statusbar.setObjectName("statusbar")
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
  
      def retranslateUi(self, MainWindow):
          _translate = QtCore.QCoreApplication.translate
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
          self.label_2.setText(_translate("MainWindow", "Epochs"))
          self.TrainNeuralNetwork.setText(_translate("MainWindow", "Train Neural Network"))
  
  
  if __name__ == "__main__":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = QtWidgets.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>