如何使用按钮调用辅助窗口

时间:2017-03-31 19:28:58

标签: python-3.x pyqt5

我是编程和PyQt5的新手。我设计了一个带有Qt设计器的UI,并成功将它们转换为python脚本。但是,我需要一种方法在主窗口中使用按钮调用另一个窗口。在过去的16个小时里,我一直绞尽脑汁(和互联网)仍然无法找到解决方案。此外,我的按钮似乎不会运行它们所连接的程序。

这是调用主要gui保存为primary.py

的主要代码
    # -*- 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_()

以下是我的主要gui的代码

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! :)')

以下是我想用我的设置按钮名称作为setupPush

来调用的gui
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"))

1 个答案:

答案 0 :(得分:0)

必须在Primary类或从QObject继承的类中给出信号连接。你使用Ui_primary及其方法的方式也是不正确的。最后,您必须创建一个可以使用您的设计的类,这称为SetUp,然后我们将show函数连接到按钮(我使用了按钮nodePropPush)。

class SetUp(QtWidgets.QMainWindow, Ui_SetUp):
    def __init__(self, parent = None):
        QtWidgets.QMainWindow.__init__(self, parent)
        self.setupUi(self)

class Primary(QtWidgets.QMainWindow, Ui_Primary):
    def __init__(self, parent = None):
        QtWidgets.QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self.setupPush.clicked.connect(self.code)

        s = SetUp(self)

        self.nodePropPush.clicked.connect(s.show)

    def code(self):
        print('Finally, I work! :)')

完整代码:

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"))


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.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"))




import sys

class SetUp(QtWidgets.QMainWindow, Ui_SetUp):
    def __init__(self, parent = None):
        QtWidgets.QMainWindow.__init__(self, parent)
        self.setupUi(self)

class Primary(QtWidgets.QMainWindow, Ui_Primary):
    def __init__(self, parent = None):
        QtWidgets.QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self.setupPush.clicked.connect(self.code)

        s = SetUp(self)

        self.nodePropPush.clicked.connect(s.show)

    def code(self):
        print('Finally, I work! :)')


if __name__== '__main__':
    app = QtWidgets.QApplication(sys.argv)
    myapp = Primary()
    myapp.show()
    app.aboutToQuit.connect(app.deleteLater)
    app.exec_()

enter image description here