title: How do I call secondary window using a pushbutton
body: <p>I am new to programming and PyQt5. I have designed a UI with Qt designer and successfully converted them to python scripts. However, I need a way to call  another window using a pushbutton in my main window. I have been racking my brains (and the internet) for the past 16 hours and still cannot find a solution. Also it appears that my pushbuttons do not run programs they are connected to.</p>
  
  <p>This is the main code that calls the primary gui saved as primary.py</p>
  
  <pre><code>    # -*- coding: utf-8 -*-
  
  from PyQt5 import QtWidgets
  from primary import Ui_Primary
  import sys
  
  class Primary(QtWidgets.QMainWindow, Ui_Primary):
      def __init__(self, parent = None):
          QtWidgets.QMainWindow.__init__(self, parent)
          Ui_Primary().setupUi(self)
  
  if __name__== '__main__':
      app = QtWidgets.QApplication(sys.argv)
      myapp = Primary()
      myapp.show()
      app.aboutToQuit.connect(app.deleteLater)
      app.exec_()
  </code></pre>
  
  <p>Below is the code for my primary gui</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  
  class Ui_Primary(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName("MainWindow")
          MainWindow.resize(250, 300)
          sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
          sizePolicy.setHorizontalStretch(0)
          sizePolicy.setVerticalStretch(0)
          sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
          MainWindow.setSizePolicy(sizePolicy)
          MainWindow.setMinimumSize(QtCore.QSize(250, 300))
          MainWindow.setMaximumSize(QtCore.QSize(250, 300))
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName("centralwidget")
          self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget)
          self.verticalLayout_2.setObjectName("verticalLayout_2")
          self.verticalLayout = QtWidgets.QVBoxLayout()
          self.verticalLayout.setContentsMargins(5, 10, 5, 5)
          self.verticalLayout.setSpacing(10)
          self.verticalLayout.setObjectName("verticalLayout")
          self.setupPush = QtWidgets.QPushButton(self.centralwidget)
          self.setupPush.setObjectName("setupPush")
          self.verticalLayout.addWidget(self.setupPush)
          self.line_5 = QtWidgets.QFrame(self.centralwidget)
          self.line_5.setFrameShape(QtWidgets.QFrame.HLine)
          self.line_5.setFrameShadow(QtWidgets.QFrame.Sunken)
          self.line_5.setObjectName("line_5")
          self.verticalLayout.addWidget(self.line_5)
          self.nodePropPush = QtWidgets.QPushButton(self.centralwidget)
          self.nodePropPush.setObjectName("nodePropPush")
          self.verticalLayout.addWidget(self.nodePropPush)
          self.line_4 = QtWidgets.QFrame(self.centralwidget)
          self.line_4.setFrameShape(QtWidgets.QFrame.HLine)
          self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)
          self.line_4.setObjectName("line_4")
          self.verticalLayout.addWidget(self.line_4)
          self.elPropLabel = QtWidgets.QPushButton(self.centralwidget)
          self.elPropLabel.setObjectName("elPropLabel")
          self.verticalLayout.addWidget(self.elPropLabel)
          self.line_3 = QtWidgets.QFrame(self.centralwidget)
          self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
          self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
          self.line_3.setObjectName("line_3")
          self.verticalLayout.addWidget(self.line_3)
          self.bcPush = QtWidgets.QPushButton(self.centralwidget)
          self.bcPush.setObjectName("bcPush")
          self.verticalLayout.addWidget(self.bcPush)
          self.line_2 = QtWidgets.QFrame(self.centralwidget)
          self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
          self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
          self.line_2.setObjectName("line_2")
          self.verticalLayout.addWidget(self.line_2)
          self.solvePush = QtWidgets.QPushButton(self.centralwidget)
          self.solvePush.setObjectName("solvePush")
          self.verticalLayout.addWidget(self.solvePush)
          self.line = QtWidgets.QFrame(self.centralwidget)
          self.line.setFrameShape(QtWidgets.QFrame.HLine)
          self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
          self.line.setObjectName("line")
          self.verticalLayout.addWidget(self.line)
          self.resultPush = QtWidgets.QPushButton(self.centralwidget)
          self.resultPush.setObjectName("resultPush")
          self.verticalLayout.addWidget(self.resultPush)
          self.verticalLayout_2.addLayout(self.verticalLayout)
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 250, 21))
          self.menubar.setObjectName("menubar")
          self.menuFEA = QtWidgets.QMenu(self.menubar)
          self.menuFEA.setObjectName("menuFEA")
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtWidgets.QStatusBar(MainWindow)
          self.statusbar.setObjectName("statusbar")
          MainWindow.setStatusBar(self.statusbar)
          self.actionExit = QtWidgets.QAction(MainWindow)
          self.actionExit.setObjectName("actionExit")
          self.menuFEA.addAction(self.actionExit)
          self.menubar.addAction(self.menuFEA.menuAction())
          self.setupPush.clicked.connect(self.code)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          _translate = QtCore.QCoreApplication.translate
          MainWindow.setWindowTitle(_translate("MainWindow", "FEA - Bar 2D"))
          MainWindow.setStatusTip(_translate("MainWindow", "Ready"))
          self.setupPush.setStatusTip(_translate("MainWindow", "Setup"))
          self.setupPush.setText(_translate("MainWindow", "Setup"))
          self.nodePropPush.setStatusTip(_translate("MainWindow", "Input node properties"))
          self.nodePropPush.setText(_translate("MainWindow", "Node Properties"))
          self.elPropLabel.setStatusTip(_translate("MainWindow", "Input element properties"))
          self.elPropLabel.setText(_translate("MainWindow", "Element Properties"))
          self.bcPush.setStatusTip(_translate("MainWindow", "Input boundary conditions"))
          self.bcPush.setText(_translate("MainWindow", "Boundary Conditons"))
          self.solvePush.setStatusTip(_translate("MainWindow", "Solve"))
          self.solvePush.setText(_translate("MainWindow", "Solve"))
          self.resultPush.setStatusTip(_translate("MainWindow", "List solution results"))
          self.resultPush.setText(_translate("MainWindow", "List Results"))
          self.menuFEA.setTitle(_translate("MainWindow", "FEA"))
          self.actionExit.setText(_translate("MainWindow", "Exit"))
          self.actionExit.setStatusTip(_translate("MainWindow", "Exit"))
          self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
  
      def code(self):
          print('Finally, I work! :)')
  </code></pre>
  
  <p>Below is the gui I would like to call with my setup pushbutton name above as setupPush</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  
  class Ui_SetUp(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName("MainWindow")
          MainWindow.resize(300, 190)
          sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
          sizePolicy.setHorizontalStretch(0)
          sizePolicy.setVerticalStretch(0)
          sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
          MainWindow.setSizePolicy(sizePolicy)
          MainWindow.setMinimumSize(QtCore.QSize(300, 190))
          MainWindow.setMaximumSize(QtCore.QSize(300, 190))
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName("centralwidget")
          self.formLayoutWidget = QtWidgets.QWidget(self.centralwidget)
          self.formLayoutWidget.setGeometry(QtCore.QRect(20, 10, 261, 101))
          self.formLayoutWidget.setObjectName("formLayoutWidget")
          self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
          self.formLayout.setContentsMargins(5, 10, 5, 5)
          self.formLayout.setSpacing(10)
          self.formLayout.setObjectName("formLayout")
          self.nnodeLabel = QtWidgets.QLabel(self.formLayoutWidget)
          self.nnodeLabel.setObjectName("nnodeLabel")
          self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.nnodeLabel)
          self.nelLabel = QtWidgets.QLabel(self.formLayoutWidget)
          self.nelLabel.setObjectName("nelLabel")
          self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.nelLabel)
          self.ndofLabel = QtWidgets.QLabel(self.formLayoutWidget)
          self.ndofLabel.setObjectName("ndofLabel")
          self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.ndofLabel)
          self.ndof = QtWidgets.QLineEdit(self.formLayoutWidget)
          self.ndof.setObjectName("ndof")
          self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.ndof)
          self.nel = QtWidgets.QLineEdit(self.formLayoutWidget)
          self.nel.setObjectName("nel")
          self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.nel)
          self.nnode = QtWidgets.QLineEdit(self.formLayoutWidget)
          sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
          sizePolicy.setHorizontalStretch(0)
          sizePolicy.setVerticalStretch(0)
          sizePolicy.setHeightForWidth(self.nnode.sizePolicy().hasHeightForWidth())
          self.nnode.setSizePolicy(sizePolicy)
          self.nnode.setObjectName("nnode")
          self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.nnode)
          self.ndof.raise_()
          self.nnodeLabel.raise_()
          self.nelLabel.raise_()
          self.nel.raise_()
          self.nnode.raise_()
          self.ndofLabel.raise_()
          self.mainOkPush = QtWidgets.QPushButton(self.centralwidget)
          self.mainOkPush.setGeometry(QtCore.QRect(20, 120, 75, 23))
          self.mainOkPush.setToolTip("")
          self.mainOkPush.setObjectName("mainOkPush")
          self.mainCancelPush = QtWidgets.QPushButton(self.centralwidget)
          self.mainCancelPush.setGeometry(QtCore.QRect(210, 120, 75, 23))
          self.mainCancelPush.setObjectName("mainCancelPush")
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 300, 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", "Main Window"))
          self.nnodeLabel.setText(_translate("MainWindow", "Number of Nodes"))
          self.nelLabel.setText(_translate("MainWindow", "Number of Elements"))
          self.ndofLabel.setText(_translate("MainWindow", "Number of DOF per node"))
          self.mainOkPush.setStatusTip(_translate("MainWindow", "Save and continue"))
          self.mainOkPush.setText(_translate("MainWindow", "OK"))
          self.mainCancelPush.setStatusTip(_translate("MainWindow", "Cancel"))
          self.mainCancelPush.setText(_translate("MainWindow", "Cancel"))
  </code></pre>