转到 cnx2010.tk

虽然没人气, 但也要说明下, 这个博客停止维护了(其实早就没动过了), 已经转到 cnx2010.tk, 近期内会整理

转载于:https://www.cnblogs.com/cnxyang/articles/2248726.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import tkinter as tk import mysql.connector # 连接 MySQL 数据库 cnx = mysql.connector.connect(user='sa', password='sa', host='localhost', db='Student') cursor = cnx.cursor() # 创建 GUI 界面 def create_student_info_window(): tk.Label(root, text="添加学生信息").pack() tk.Entry(root, textvariable=tk.StringVar(value='请输入学生信息')).pack() tk.Button(root, text="添加", command=lambda: add_student_info(cursor, cnx)).pack() def update_student_info_window(): tk.Label(root, text="更新学生信息").pack() tk.Entry(root, textvariable=tk.StringVar(value='请输入学生信息')).pack() tk.Button(root, text="更新", command=lambda: update_student_info(cursor, cnx)).pack() def delete_student_info_window(): tk.Label(root, text="删除学生信息").pack() tk.Entry(root, textvariable=tk.StringVar(value='请输入学生 ID')).pack() tk.Button(root, text="删除", command=lambda: delete_student_info(cursor, cnx)).pack() def query_student_info_window(): tk.Label(root, text="查询学生信息").pack() tk.Entry(root, textvariable=tk.StringVar(value='请输入学生 ID')).pack() tk.Button(root, text="查询", command=lambda: query_student_info(cursor, cnx)).pack() root = tk.Tk() root.geometry('300x300') root.title("学生信息系统") # 创建 GUI 界面 window = tk.Frame(root) window.pack() # 添加学生信息按钮 add_button = tk.Button(window, text="添加", command=create_student_info_window) add_button.pack() # 更新学生信息按钮 update_button = tk.Button(window, text="更新", command=update_student_info_window) update_button.pack() # 删除学生信息按钮 delete_button = tk.Button(window, text="删除", command=delete_student_info_window) delete_button.pack() # 查询学生信息按钮 query_button = tk.Button(window, text="查询", command=query_student_info_window) query_button.pack() # 连接到 MySQL 数据库 cursor.execute("SELECT * FROM student_info") result = cursor.fetchall() for row in result: tk.Label(root, text=row[0]).pack() # 运行 GUI 应用程序 root.mainloop()
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值