一、第一种
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from qyjs import * # 导入添加的资源(根据实际情况填写文件名)
from functools import partial
def button_run(ui):
search_content = ui.lineEdit.text()
start_num = ui.spinBox_2.text()
end_num = ui.spinBox.text()
print(end_num)
if __name__ == '__main__':
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
# ui.download.clicked.connect(partial(button_run,ui))
sys.exit(app.exec_())
二、第二种
import sys
from PyQt5 import QtWidgets
from PyQT_Form import Ui_Form
class MyPyQT_Form(QtWidgets.QWidget,Ui_Form):
def __init__(self):
super(MyPyQT_Form,self).__init__()
self.setupUi(self)
#实现pushButton_click()函数,textEdit是我们放上去的文本框的id
def pushButton_click(self):
self.textEdit.setText("你点击了按钮")
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
my_pyqt_form = MyPyQT_Form()
my_pyqt_form.show()
sys.exit(app.exec_())
|