PyQt5-界面跳转
代码
import pymysql
import sys
from single_insert import Ui_MainWindow
from Register import Ui_Form
from PyQt5.QtWidgets import QApplication,QMainWindow,QMessageBox,QWidget
class Run_MainWindow(Ui_MainWindow, QMainWindow):
def __init__(self):
super(Run_MainWindow, self).__init__()
self.setupUi(self)
self.lineEdit=self.lineEdit
self.label_3=self.label_3
self.label_2=self.label_2
self.lineEdit_2 = self.lineEdit_2
self.label = self.label
self.lineEdit_3 = self.lineEdit_3
self.pushButton.clicked.connect(self.insertTBuarea)
self.pushButton_2=self.pushButton_2
self.pushButton_3=self.pushButton_3
def insertTBuarea(self):
print("面积:{0},功能:{1}".format(self.lineEdit_2.text(),self.lineEdit_3.text()))
global a, b
a=self.lineEdit_2.text()
b=self.lineEdit_3.text()
db = pymysql.connect(host='localhost',
user='root',
password='123456',
database='sportsarear&b')
sql = "INSERT INTO uarea(asqure,afuncation) VALUES ('{0}','{1}')".format(a, b)
print(sql)
cursor = db.cursor()
try:
cursor.execute(sql)
db.commit()
self.show_messages()
except:
print("数据提交失败!")
db.rollback()
db.close()
def show_messages(self):
QMessageBox.information(self,"增添数据","任务完成",QMessageBox.Yes)
class Run_register(Ui_Form,QWidget):
def __init__(self):
super(Run_register, self).__init__()
if __name__ == '__main__':
app = QApplication(sys.argv)
MainWindow = Run_MainWindow()
Register=Run_register()
btn = MainWindow.pushButton_3
btn.clicked.connect(Register.show)
MainWindow.show()
sys.exit(app.exec())
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix