pyqt5:Button的信号槽处理机制

  • Post author:
  • Post category:其他




模板如下:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super(Ui_MainWindow,self).__init__()
        self.setupUi(self)
        self.retranslateUi(self)
        self.set_myUi()
    def setupUi(self, MainWindow):
		根据自己的界面,使用PYUIC会自动生成这个函数
    def set_myUi(self):
        # 这里的start_btn是你要点击的Button名字(ui里确定了),pushButton_start是触发函数
        self.start_btn.clicked.connect(self.pushButton_start)
    def pushButton_start(self):
		# 根据需求,个性化选择后续操作

参考:

https://blog.csdn.net/qq_38113006/article/details/119598504



版权声明:本文为gls_nuaa原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。