pyqt5 qt designer 汇率转换器 从UI 按钮 输出到命令行,单线程

```

from PySide2.QtCore import * 

from PySide2.QtGui import *

from PySide2.QtWidgets import *

import sys

class Ui_MainWindow(object): # 这个类是 qt designber 生成的

    def setupUi(self, MainWindow):

        if not MainWindow.objectName():

            MainWindow.setObjectName(u"MainWindow")

        MainWindow.resize(302, 252)

        self.actionsave = QAction(MainWindow)

        self.actionsave.setObjectName(u"actionsave")

        self.action = QAction(MainWindow)

        self.action.setObjectName(u"action")

        self.centralwidget = QWidget(MainWindow)

        self.centralwidget.setObjectName(u"centralwidget")

        self.verticalLayout_2 = QVBoxLayout(self.centralwidget)

        self.verticalLayout_2.setObjectName(u"verticalLayout_2")

        self.verticalLayout = QVBoxLayout()

        self.verticalLayout.setObjectName(u"verticalLayout")

        self.label = QLabel(self.centralwidget)

        self.label.setObjectName(u"label")

        self.verticalLayout.addWidget(self.label)

        self.lineEdit = QLineEdit(self.centralwidget)

        self.lineEdit.setObjectName(u"lineEdit")

        self.verticalLayout.addWidget(self.lineEdit)

        self.pushButton = QPushButton(self.centralwidget)

        self.pushButton.setObjectName(u"pushButton")

        self.verticalLayout.addWidget(self.pushButton)

        self.label_2 = QLabel(self.centralwidget)

        self.label_2.setObjectName(u"label_2")

        self.verticalLayout.addWidget(self.label_2)

        self.lineEdit_2 = QLineEdit(self.centralwidget)

        self.lineEdit_2.setObjectName(u"lineEdit_2")

        self.verticalLayout.addWidget(self.lineEdit_2)

        self.verticalLayout_2.addLayout(self.verticalLayout)

        MainWindow.setCentralWidget(self.centralwidget)

        self.menubar = QMenuBar(MainWindow)

        self.menubar.setObjectName(u"menubar")

        self.menubar.setGeometry(QRect(0, 0, 302, 23))

        self.menu = QMenu(self.menubar)

        self.menu.setObjectName(u"menu")

        self.menu_2 = QMenu(self.menubar)

        self.menu_2.setObjectName(u"menu_2")

        MainWindow.setMenuBar(self.menubar)

        self.statusbar = QStatusBar(MainWindow)

        self.statusbar.setObjectName(u"statusbar")

        MainWindow.setStatusBar(self.statusbar)

        self.menubar.addAction(self.menu.menuAction())

        self.menubar.addAction(self.menu_2.menuAction())

        self.menu.addAction(self.actionsave)

        self.menu.addAction(self.action)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)

    # setupUi

    def retranslateUi(self, MainWindow):

        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"\u6c47\u7387\u6362\u7b97\u5668", None))

        self.actionsave.setText(QCoreApplication.translate("MainWindow", u"save", None))

        self.action.setText(QCoreApplication.translate("MainWindow", u"\u4fdd\u5b58", None))

        self.label.setText(QCoreApplication.translate("MainWindow", u"USD", None))

        self.pushButton.setText(QCoreApplication.translate("MainWindow", u"\u8f6c\u6362", None))

        self.label_2.setText(QCoreApplication.translate("MainWindow", u"RMB", None))

        self.menu.setTitle(QCoreApplication.translate("MainWindow", u"\u83dc\u5355", None))

        self.menu_2.setTitle(QCoreApplication.translate("MainWindow", u"\u5e2e\u52a9", None))

    # retranslateUi

def click_success():

    print("well done log")

app = QApplication(sys.argv)

MainWindow = QMainWindow()

ui = Ui_MainWindow()

ui.setupUi(MainWindow)

MainWindow.show()

ui.pushButton.clicked.connect(click_success)  # 这是单线程的情况

# 在不是多线程的时候,是它在运行

# 如果 convert 函数中的运算量很大,就会卡死

sys.exit(app.exec_())

```

你可能感兴趣的:(pyqt5 qt designer 汇率转换器 从UI 按钮 输出到命令行,单线程)