• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

PyQt5-界面跳转

代码

导入已安装

导入系统

从单一_插入导入Ui _主窗口

从注册导入Ui _表单

来自PyQt5 .QtWidgets导入QApplication,QMainWindow,QMessageBox,QWidget

类Run_MainWindow(Ui_MainWindow,QMainWindow):

def __init__(self):

超级(运行主窗口,自我).__init__()

self.setupUi(self)

self.lineEdit=self.lineEdit

self.label_3=self.label_3

self.label_2=self.label_2

自我。line edit _ 2=self。行编辑_ 2

自我标签=自我标签

自我。line edit _ 3=self。行编辑_ 3

自我。按钮。点击了。连接(自我。插入区域)

自我。button _ 2=自身。按钮_ 2

自我。button _ 3=自己。按钮_ 3

# 数据库——增一条数据功能

def insertTBuarea(self):

打印('面积:{0},功能:{1}'.格式(self.lineEdit_2.text()、self.lineEdit_3.text())

全球甲、乙

a=self.lineEdit_2.text()

b=self.lineEdit_3.text()

#甲,乙格式错误则弹出对话框,先省略

# 打开数据库连接

db=pymysql。connect(host=' localhost ',

user='root ',

密码='123456 ',

database='sportsarearb ')

sql='INSERT INTO uarea(asqure,afuncation)值(' {0} ',' {1} ')'。格式(甲、乙)

打印(sql)

# 使用光标()方法获取操作游标

cursor=db.cursor()

尝试:

# 执行结构化查询语言语句

游标。执行(sql)

# 提交到数据库执行

数据库提交()

# 提交成功显示一个对话框

self.show_messages()

例外:

# 如果发生错误则回滚

打印('数据提交失败!')

db.rollback()

# 关闭数据库连接

db.close()

def show_messages(self):

QMessageBox.information(self,'增添数据','任务完成,QMessageBox .是)

类Run_register(Ui_Form,QWidget):

def __init__(self):

超级(Run_register,self).__init__()

if __name__=='__main__':

app=QA应用程序(sys。argv)

主窗口=运行_主窗口()

寄存器=运行寄存器()

#通过按钮将两个窗体关联

btn=MainWindow.pushButton _ 3

BTN。点击了。连接(注册。展示)

MainWindow.show()

sys.exit(app.exec())

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now