社团信息管理系统

代码语言: 

python

第三方库:

mysql

tkinter

PIL

datetime

这是一个demo,用于数据库练手,逻辑及功能不全,仍需要补充

import mysql.connector
import tkinter as tk
from tkinter import messagebox
from tkinter.ttk import Treeview, Scrollbar
from PIL import Image, ImageTk
from tkinter import IntVar
from datetime import datetimep_id = 2def CreateDatabase():db = mysql.connector.connect(host="localhost",user='root',password="*******")cursor = db.cursor()cursor.execute("CREATE DATABASE IF NOT EXISTS infsys")cursor.execute("USE infsys")cursor.execute("""CREATE TABLE IF NOT EXISTS 社团信息汇总(name varchar(255) comment '社团名称',num int comment '社团人数',type varchar(255) comment '社团类型',time datetime comment '社团成立时间',chairman varchar(255) comment '社团负责人',p_id int comment '对应的表')""")cursor.execute("""CREATE TABLE IF NOT EXISTS 文学社(name varchar(255) comment '成员姓名',posts varchar(255) comment '职位',gender varchar(1) comment '性别',age int comment '年龄',academy varchar(255) comment '学院',phone varchar(255) comment '电话')""")cursor.execute("""CREATE TABLE IF NOT EXISTS 体育社(name varchar(255) comment '成员姓名',posts varchar(255) comment '职位',gender varchar(1) comment '性别',age int comment '年龄',academy varchar(255) comment '学院',phone varchar(255) comment '电话')""")cursor.execute("""CREATE TABLE IF NOT EXISTS 管理员信息(name varchar(255) comment '管理员姓名',id varchar(255) comment '学号',password varchar(255) comment '密码')   """)cursor.execute("""CREATE TABLE IF NOT EXISTS 社长信息(name varchar(255) comment '社长姓名',id varchar(255) comment '学号',password varchar(255) comment '密码')""")cursor.close()db.close()def InsertData():db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()# 向社团信息汇总表中插入数据cursor.execute("""INSERT INTO 社团信息汇总 (name, num, type, time, chairman, p_id)VALUES ('文学社', 50, '文学', '2022-01-01 00:00:00', '张三', 1),('体育社', 60, '体育', '2021-01-01 00:00:00', '李四', 2)""")# 向文学社表中插入数据cursor.execute("""INSERT INTO 文学社 (name, posts, gender, age, academy, phone)VALUES ('张三', '社长', 'M', 22, '文学院', '1234567890'),('李四', '副社长', 'F', 21, '文学院', '0987654321')""")# 向体育社表中插入数据cursor.execute("""INSERT INTO 体育社 (name, posts, gender, age, academy, phone)VALUES ('王五', '社长', 'M', 23, '体育学院', '1231231234'),('赵六', '副社长', 'F', 22, '体育学院', '4321432143')""")cursor.execute("""INSERT INTO 管理员信息 (name, id, password)VALUES ('HNU', '20222022', '123456')""")cursor.execute("""INSERT INTO 社长信息 (name, id ,password)VALUES ('张三', '20221111', '123456'),('李四', '20221112', '123456'),('王五', '20221113', '123456'),('赵六', '20221114', '123456')    """)db.commit()  # 提交事务cursor.close()db.close()def login():username = entry_username.get()password = entry_password.get()role = role_var.get()# print(username, password, role)db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()if role == 1:cursor.execute(f"SELECT * FROM 管理员信息 WHERE name='{username}' AND password='{password}'")result = cursor.fetchone()if result:messagebox.showinfo("登录成功", "管理员登录成功!")root.destroy()admin_panel()else:messagebox.showerror("登录失败", "密码错误!")elif role == 2:cursor.execute(f"SELECT * FROM 社长信息 WHERE name='{username}' AND password='{password}'")result = cursor.fetchone()if result:messagebox.showinfo("登录成功", "社长登录成功!")root.destroy()president_panel(username)else:messagebox.showerror("登录失败", "密码错误!")cursor.close()db.close()def show_information(key):db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()cursor.execute("SELECT * FROM {}".format(key))results = cursor.fetchall()cursor.close()db.close()return resultsdef submit_club_information(entry_name, entry_num, entry_type, entry_chairman, entry_id, entry_password):global p_idclub_name = entry_name.get()num = entry_num.get()clubtype = entry_type.get()chairman = entry_chairman.get()time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")id = entry_id.get()password = entry_password.get()db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")p_id += 1cursor = db.cursor()cursor.execute("""CREATE TABLE IF NOT EXISTS club_name(name varchar(255) comment '成员姓名',posts varchar(255) comment '职位',gender varchar(1) comment '性别',age int comment '年龄',academy varchar(255) comment '学院',phone varchar(255) comment '电话')""")cursor.execute("""INSERT INTO 社团信息汇总 (name, num, type, time, chairman, p_id)VALUES (%s, %s, %s, %s, %s, %s)""", (club_name, num, clubtype, time, chairman, p_id))cursor.execute("""INSERT INTO 社长信息 (name, id, password)VALUES (%s, %s, %s)""", (chairman, id, password))db.commit()cursor.close()db.close()new_window.destroy()messagebox.showinfo("成功", "社团数据添加成功")admin.destroy()admin_panel()  # 重新加载管理员面板以刷新数据def new_club_information():global new_window, p_idnew_window = tk.Toplevel(master=admin)new_window.title("添加社团数据")new_window.geometry("500x500+500+200")new_window.resizable(False, False)new_club_image = Image.open('秋.jpg')new_club_image = new_club_image.resize((500, 500))new_club_photo = ImageTk.PhotoImage(new_club_image)new_club_background_label = tk.Label(new_window, image=new_club_photo)new_club_background_label.place(x=0, y=0)tk.Label(new_window, text="社团名称:").place(x=50, y=50)tk.Label(new_window, text="社团人数:").place(x=50, y=100)tk.Label(new_window, text="社团类型:").place(x=50, y=150)tk.Label(new_window, text="社长姓名:").place(x=50, y=200)tk.Label(new_window, text="社长学号:").place(x=50, y=250)tk.Label(new_window, text="密码:").place(x=50, y=300)entry_name = tk.Entry(new_window, width=20)entry_name.place(x=150, y=50)entry_num = tk.Entry(new_window, width=20)entry_num.place(x=150, y=100)entry_type = tk.Entry(new_window, width=20)entry_type.place(x=150, y=150)entry_chairman = tk.Entry(new_window, width=20)entry_chairman.place(x=150, y=200)entry_id = tk.Entry(new_window, width=20)entry_id.place(x=150, y=250)entry_password = tk.Entry(new_window, show='*', width=20)entry_password.place(x=150, y=300)tk.Button(new_window, text="提交",command=lambda: submit_club_information(entry_name, entry_num, entry_type,entry_chairman, entry_id, entry_password)).place(x=150, y=350)def delete_club_information(entry_name, entry_chairman):club_name = entry_name.get()chairman = entry_chairman.get()db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()try:# 删除社团表cursor.execute(f"DROP TABLE IF EXISTS {club_name}")# 删除社团信息汇总中的记录cursor.execute("DELETE FROM 社团信息汇总 WHERE name = %s", (club_name,))cursor.execute("DELETE FROM 社长信息 WHERE name = %s", (chairman,))db.commit()messagebox.showinfo("成功", "社团数据删除成功")except mysql.connector.Error as err:messagebox.showerror("错误", f"删除社团数据时发生错误: {err}")cursor.close()db.close()delete_window.destroy()admin.destroy()admin_panel()  # 重新加载管理员面板以刷新数据def remove_club_information():global delete_windowdelete_window = tk.Toplevel(master=admin)delete_window.title("删除社团数据")delete_window.geometry("500x500+500+200")delete_club_image = Image.open('秋.jpg')delete_club_image = delete_club_image.resize((500, 500))delete_club_photo = ImageTk.PhotoImage(delete_club_image)delete_club_background_label = tk.Label(delete_window, image=delete_club_photo)delete_club_background_label.place(x=0, y=0)tk.Label(delete_window, text="社团名称:").place(x=50, y=50)tk.Label(delete_window, text="社长姓名:").place(x=50, y=100)entry_name = tk.Entry(delete_window, width=20)entry_name.place(x=150, y=50)entry_chairman = tk.Entry(delete_window, width=20)entry_chairman.place(x=150, y=100)tk.Button(delete_window, text="提交",command=lambda: delete_club_information(entry_name, entry_chairman)).place(x=150, y=150)def search_club_information(entry_name, entry_chairman):club_name = entry_name.get()chair_name = entry_chairman.get()db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()try:cursor.execute("SELECT * FROM 社团信息汇总 WHERE name = %s", (club_name,))club_info = cursor.fetchone()cursor.execute("SELECT * FROM 社长信息 WHERE name = %s", (chair_name,))chair_info = cursor.fetchone()if club_info:info_text = f"社团名称: {club_info[0]}\n社团人数: {club_info[1]}\n社团类型: {club_info[2]}\n成立时间: {club_info[3]}\n负责人: {club_info[4]}\n学号: {chair_info[1]}\n密码: {chair_info[2]}"messagebox.showinfo("社团信息", info_text)else:messagebox.showinfo("无结果", "未找到相关社团信息")except mysql.connector.Error as err:messagebox.showerror("错误", f"查询社团信息时发生错误: {err}")cursor.close()db.close()def query_club_information():global query_windowquery_window = tk.Toplevel(master=admin)query_window.title("查询社团信息")query_window.geometry("500x500+500+200")query_club_image = Image.open('秋.jpg')query_club_image = query_club_image.resize((500, 500))query_club_photo = ImageTk.PhotoImage(query_club_image)query_club_background_label = tk.Label(query_window, image=query_club_photo)query_club_background_label.place(x=0, y=0)tk.Label(query_window, text="社团名称:").place(x=50, y=50)tk.Label(query_window, text="社长姓名:").place(x=50, y=100)entry_name = tk.Entry(query_window, width=20)entry_name.place(x=150, y=50)entry_chairman = tk.Entry(query_window, width=20)entry_chairman.place(x=150, y=100)tk.Button(query_window, text="查询", command=lambda: search_club_information(entry_name, entry_chairman)).place(x=150, y=150)query_window.mainloop()def update_club_information(entry_name, entry_num, entry_type, entry_time, entry_chairman, entry_id, entry_password):club_name = entry_name.get()club_num = entry_num.get()club_type = entry_type.get()club_time = entry_time.get()club_chairman = entry_chairman.get()chairman_id = entry_id.get()chairman_password = entry_password.get()db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()try:cursor.execute("""UPDATE 社团信息汇总SET num = %s, type = %s, time = %s, chairman = %sWHERE name = %s""",(club_num, club_type, club_time, club_chairman, club_name))cursor.execute("""UPDATE 社长信息SET id = %s, password = %sWHERE name = %s""",(chairman_id, chairman_password, club_chairman))db.commit()messagebox.showinfo("成功", "社团数据修改成功")except mysql.connector.Error as err:messagebox.showerror("错误", f"修改社团数据时发生错误: {err}")cursor.close()db.close()update_window.destroy()admin.destroy()admin_panel()  # 重新加载管理员面板以刷新数据def modify_club_information():global update_windowupdate_window = tk.Toplevel(master=admin)update_window.title("修改社团数据")update_window.geometry("500x500+500+200")update_window.resizable(False, False)modify_club_image = Image.open('秋.jpg')modify_club_image = modify_club_image.resize((500, 500))modify_club_photo = ImageTk.PhotoImage(modify_club_image)modify_club_background_label = tk.Label(update_window, image=modify_club_photo)modify_club_background_label.place(x=0, y=0)tk.Label(update_window, text="社团名称:").place(x=50, y=50)tk.Label(update_window, text="社团人数:").place(x=50, y=100)tk.Label(update_window, text="社团类型:").place(x=50, y=150)tk.Label(update_window, text="成立时间:").place(x=50, y=200)tk.Label(update_window, text="社长姓名:").place(x=50, y=250)tk.Label(update_window, text="社长学号:").place(x=50, y=300)tk.Label(update_window, text="密码:").place(x=50, y=350)entry_name = tk.Entry(update_window, width=20)entry_name.place(x=150, y=50)entry_num = tk.Entry(update_window, width=20)entry_num.place(x=150, y=100)entry_type = tk.Entry(update_window, width=20)entry_type.place(x=150, y=150)entry_time = tk.Entry(update_window, width=20)entry_time.place(x=150, y=200)entry_chairman = tk.Entry(update_window, width=20)entry_chairman.place(x=150, y=250)entry_id = tk.Entry(update_window, width=20)entry_id.place(x=150, y=300)entry_password = tk.Entry(update_window, width=20)entry_password.place(x=150, y=350)tk.Button(update_window, text="提交",command=lambda: update_club_information(entry_name, entry_num, entry_type, entry_time,entry_chairman, entry_id, entry_password)).place(x=150, y=400)update_window.mainloop()def add_admin_information(entry_name, entry_id, entry_password):admin_name = entry_name.get()admin_id = entry_id.get()admin_password = entry_password.get()db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()try:cursor.execute("""INSERT INTO 管理员信息 (name, id, password)VALUES (%s, %s, %s)""",(admin_name, admin_id, admin_password))db.commit()messagebox.showinfo("成功", "管理员信息添加成功")except mysql.connector.Error as err:messagebox.showerror("错误", f"添加管理员信息时发生错误: {err}")cursor.close()db.close()add_admin_window.destroy()admin.destroy()admin_panel()  # 重新加载管理员面板以刷新数据def add_admin():global add_admin_windowadd_admin_window = tk.Toplevel(master=admin)add_admin_window.title("增加管理员信息")add_admin_window.geometry("500x500+500+200")add_admin_window.resizable(False, False)add_admin_image = Image.open('秋.jpg')add_admin_image = add_admin_image.resize((500, 500))add_admin_photo = ImageTk.PhotoImage(add_admin_image)add_admin_background_label = tk.Label(add_admin_window, image=add_admin_photo)add_admin_background_label.place(x=0, y=0)tk.Label(add_admin_window, text="管理员姓名:").place(x=50, y=50)tk.Label(add_admin_window, text="学号:").place(x=50, y=100)tk.Label(add_admin_window, text="密码:").place(x=50, y=150)entry_name = tk.Entry(add_admin_window, width=20)entry_name.place(x=150, y=50)entry_id = tk.Entry(add_admin_window, width=20)entry_id.place(x=150, y=100)entry_password = tk.Entry(add_admin_window, show='*', width=20)entry_password.place(x=150, y=150)tk.Button(add_admin_window, text="提交",command=lambda: add_admin_information(entry_name, entry_id, entry_password)).place(x=150, y=200)add_admin_window.mainloop()# 管理员界面
def admin_panel():global adminadmin = tk.Tk()admin.geometry('1000x600+400+100')admin.resizable(False, False)admin.title('管理员管理系统')# 其他组件和功能实现admin_image = Image.open('实事求是.jpg')admin_image = admin_image.resize((1000, 600))admin_photo = ImageTk.PhotoImage(admin_image)admin_background_label = tk.Label(admin, image=admin_photo)admin_background_label.place(x=0, y=0)tk.Label(admin, text='社团信息', font=("KaiTi", 20)).place(x=50, y=50)tk.Button(admin, text='添加社团数据', command=new_club_information).place(x=50, y=100)tk.Button(admin, text='删除社团数据', command=remove_club_information).place(x=50, y=150)tk.Button(admin, text='修改社团数据', command=modify_club_information).place(x=50, y=200)tk.Button(admin, text='查询社团数据', command=query_club_information).place(x=50, y=250)tk.Button(admin, text='添加管理员', command=add_admin).place(x=50, y=300)tk.Button(admin, text='退出', command=admin.destroy).place(x=50, y=350)tree = Treeview(admin, columns=('name', 'num', 'type', 'time', 'chairman', 'p_id'), show='headings')tree.heading('name', text='社团名称')tree.heading('num', text='社团人数')tree.heading('type', text='社团类型')tree.heading('time', text='成立时间')tree.heading('chairman', text='负责人')tree.heading('p_id', text='对应表编号')tree.place(x=200, y=50)information = show_information('社团信息汇总')tree.column('name', width=100, anchor='center')tree.column('num', width=100, anchor='center')tree.column('type', width=100, anchor='center')tree.column('time', width=200, anchor='center')tree.column('chairman', width=100, anchor='center')tree.column('p_id', width=100, anchor='center')for i in information:tree.insert('', 'end', values=i)admin.mainloop()def submit_member_information(chairman, table_name, entry_name, entry_posts, entry_gender, entry_age, entry_academy,entry_phone):name = entry_name.get().strip()posts = entry_posts.get().strip()gender = entry_gender.get().strip()age = int(entry_age.get().strip())academy = entry_academy.get().strip()phone = entry_phone.get().strip()db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()query = f"""INSERT INTO {table_name} (name, posts, gender, age, academy, phone)VALUES (%s, %s, %s, %s, %s, %s)"""try:cursor.execute(query, (name, posts, gender, age, academy, phone))db.commit()messagebox.showinfo("成功", "成员数据添加成功")except mysql.connector.Error as err:messagebox.showerror("数据库错误", str(err))finally:cursor.close()db.close()new_member.destroy()president.destroy()president_panel(chairman)  # 重新加载社长面板以刷新数据def add_member_information(table_name, chair_man):global new_membernew_member = tk.Toplevel(master=president)new_member.title("添加社团成员")new_member.geometry("500x500+500+200")new_member.resizable(False, False)new_member_image = Image.open('秋.jpg')new_member_image = new_member_image.resize((500, 500))new_member_photo = ImageTk.PhotoImage(new_member_image)new_member_background_label = tk.Label(new_member, image=new_member_photo)new_member_background_label.place(x=0, y=0)tk.Label(new_member, text="成员姓名:").place(x=50, y=50)tk.Label(new_member, text="职位:").place(x=50, y=100)tk.Label(new_member, text="性别:").place(x=50, y=150)tk.Label(new_member, text="年龄:").place(x=50, y=200)tk.Label(new_member, text="学院:").place(x=50, y=250)tk.Label(new_member, text="电话:").place(x=50, y=300)entry_name = tk.Entry(new_member, width=20)entry_name.place(x=150, y=50)entry_posts = tk.Entry(new_member, width=20)entry_posts.place(x=150, y=100)entry_gender = tk.Entry(new_member, width=20)entry_gender.place(x=150, y=150)entry_age = tk.Entry(new_member, width=20)entry_age.place(x=150, y=200)entry_academy = tk.Entry(new_member, width=20)entry_academy.place(x=150, y=250)entry_phone = tk.Entry(new_member, width=20)entry_phone.place(x=150, y=300)tk.Button(new_member, text="提交",command=lambda: submit_member_information(chair_man, table_name, entry_name, entry_posts, entry_gender,entry_age, entry_academy, entry_phone)).place(x=150, y=350)new_member.mainloop()def delete_member_information(table_name, entry_name, chairman):name = entry_name.get().strip()db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()query = f"DELETE FROM {table_name} WHERE name = %s"try:cursor.execute(query, (name,))db.commit()messagebox.showinfo("成功", "成员数据删除成功")except mysql.connector.Error as err:messagebox.showerror("数据库错误", str(err))finally:cursor.close()db.close()delete_member.destroy()president.destroy()president_panel(chairman)  # 重新加载社长面板以刷新数据def remove_member_information(table_name, chairman):global delete_memberdelete_member = tk.Toplevel(master=president)delete_member.title("删除社团成员")delete_member.geometry("500x500+500+200")delete_member.resizable(False, False)delete_member_image = Image.open('秋.jpg')delete_member_image = delete_member_image.resize((500, 500))delete_member_photo = ImageTk.PhotoImage(delete_member_image)delete_member_background_label = tk.Label(delete_member, image=delete_member_photo)delete_member_background_label.place(x=0, y=0)tk.Label(delete_member, text="成员姓名:").place(x=50, y=50)entry_name = tk.Entry(delete_member, width=20)entry_name.place(x=150, y=50)tk.Button(delete_member, text="提交",command=lambda: delete_member_information(table_name, entry_name, chairman)).place(x=150, y=100)delete_member.mainloop()def update_member_information(chairman, table_name, entry_old_name, entry_new_name, entry_posts, entry_gender, entry_age, entry_academy, entry_phone):old_name = entry_old_name.get().strip()new_name = entry_new_name.get().strip()posts = entry_posts.get().strip()gender = entry_gender.get().strip()age = int(entry_age.get().strip())academy = entry_academy.get().strip()phone = entry_phone.get().strip()db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")cursor = db.cursor()query = f"""UPDATE {table_name}SET name = %s, posts = %s, gender = %s, age = %s, academy = %s, phone = %sWHERE name = %s"""try:cursor.execute(query, (new_name, posts, gender, age, academy, phone, old_name))db.commit()messagebox.showinfo("成功", "成员数据修改成功")except mysql.connector.Error as err:messagebox.showerror("数据库错误", str(err))finally:cursor.close()db.close()update_member.destroy()president.destroy()president_panel(chairman)  # 重新加载社长面板以刷新数据def modify_member_information(table_name, chairman):global update_memberupdate_member = tk.Toplevel(master=president)update_member.title("修改社团成员")update_member.geometry("500x500+500+200")update_member.resizable(False, False)update_member_image = Image.open('秋.jpg')update_member_image = update_member_image.resize((500, 500))update_member_photo = ImageTk.PhotoImage(update_member_image)update_member_background_label = tk.Label(update_member, image=update_member_photo)update_member_background_label.place(x=0, y=0)tk.Label(update_member, text="原成员姓名:").place(x=50, y=50)tk.Label(update_member, text="新成员姓名:").place(x=50, y=100)tk.Label(update_member, text="职位:").place(x=50, y=150)tk.Label(update_member, text="性别:").place(x=50, y=200)tk.Label(update_member, text="年龄:").place(x=50, y=250)tk.Label(update_member, text="学院:").place(x=50, y=300)tk.Label(update_member, text="电话:").place(x=50, y=350)entry_old_name = tk.Entry(update_member, width=20)entry_old_name.place(x=150, y=50)entry_new_name = tk.Entry(update_member, width=20)entry_new_name.place(x=150, y=100)entry_posts = tk.Entry(update_member, width=20)entry_posts.place(x=150, y=150)entry_gender = tk.Entry(update_member, width=20)entry_gender.place(x=150, y=200)entry_age = tk.Entry(update_member, width=20)entry_age.place(x=150, y=250)entry_academy = tk.Entry(update_member, width=20)entry_academy.place(x=150, y=300)entry_phone = tk.Entry(update_member, width=20)entry_phone.place(x=150, y=350)tk.Button(update_member, text="提交",command=lambda: update_member_information(chairman, table_name, entry_old_name, entry_new_name, entry_posts, entry_gender, entry_age, entry_academy, entry_phone)).place(x=150, y=400)update_member.mainloop()# 社长界面
def president_panel(chairman=None):global presidentpresident = tk.Tk()president.geometry('1000x600+400+100')president.resizable(False, False)president.title('社长管理系统')# 其他组件和功能实现president_image = Image.open('实事求是.jpg')president_image = president_image.resize((1000, 600))president_photo = ImageTk.PhotoImage(president_image)president_background_label = tk.Label(president, image=president_photo)president_background_label.place(x=0, y=0)tree = Treeview(president, columns=('name', 'posts', 'gender', 'age', 'academy', 'phone'), show='headings')tree.heading('name', text='成员姓名')tree.heading('posts', text='职位')tree.heading('gender', text='性别')tree.heading('age', text='年纪')tree.heading('academy', text='学院')tree.heading('phone', text='电话')tree.place(x=200, y=50)# 创建到数据库的连接db = mysql.connector.connect(host="localhost",user='root',password="*******",database="infsys")# 创建一个游标对象cursor = db.cursor()# 执行SQL查询cursor.execute("SELECT * FROM 社团信息汇总 WHERE chairman = %s", (chairman,))# 获取查询结果results = cursor.fetchall()# 关闭游标和连接cursor.close()db.close()club = results[0][0]information = show_information(club)tree.column('name', width=100, anchor='center')tree.column('posts', width=100, anchor='center')tree.column('gender', width=100, anchor='center')tree.column('age', width=100, anchor='center')tree.column('academy', width=100, anchor='center')tree.column('phone', width=100, anchor='center')for i in information:tree.insert('', 'end', values=i)tk.Label(president, text='社团信息', font=("KaiTi", 20)).place(x=50, y=50)tk.Button(president, text='添加成员数据', command=lambda: add_member_information(club, chairman)).place(x=50, y=100)tk.Button(president, text='删除成员数据', command=lambda: remove_member_information(club, chairman)).place(x=50,y=150)tk.Button(president, text='修改成员数据', command=lambda: modify_member_information(club, chairman)).place(x=50, y=200)tk.Button(president, text='退出', command=president.destroy).place(x=50, y=250)president.mainloop()if __name__ == '__main__':#CreateDatabase()  # 先创建数据库和表#InsertData()  # 然后插入数据root = tk.Tk()root.geometry('500x500+400+100')root.resizable(False, False)root.title('社团管理系统')image = Image.open("红楼.jpg")image = image.resize((500, 500))photo = ImageTk.PhotoImage(image)background_label = tk.Label(root, image=photo)background_label.place(x=0, y=0)Roles = [("管理员", 1),("社长", 2)]role_var = IntVar()for key, value in Roles:tk.Radiobutton(root, text=key, variable=role_var, value=value).place(x=160 + 120 * (value - 1), y=200)tk.Label(root, text="欢迎使用社团管理系统", font=("KaiTi", 30)).place(x=50, y=100)tk.Label(root, text="用户名:").place(x=100, y=250)tk.Label(root, text="学号:").place(x=100, y=290)tk.Label(root, text="密码:").place(x=100, y=330)entry_username = tk.Entry(root, width=25)entry_username.place(x=160, y=250)entry_school = tk.Entry(root, width=25)entry_school.place(x=160, y=290)entry_password = tk.Entry(root, show='*', width=25)entry_password.place(x=160, y=330)tk.Button(root, text="登录", command=login, width=10, height=1).place(x=160, y=370)tk.Button(root, text="退出", command=root.destroy, width=10, height=1).place(x=260, y=370)root.mainloop()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/46174.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

邮箱表单系统源码

邮箱表单简介 我们的邮箱表单系统是一个简洁高效的工具,旨在为用户提供一种便捷的方式来提交他们的邮箱地址。该系统可以用于订阅新闻通讯、注册活动、获取用户反馈等多种场景。 功能特点: 用户友好的界面: 表单设计简洁直观,用…

t-SNE降维可视化并生成excel文件使用其他画图软件美化

t-sne t-SNE(t-分布随机邻域嵌入,t-distributed Stochastic Neighbor Embedding)是由 Laurens van der Maaten 和 Geoffrey Hinton 于 2008 年提出的一种非线性降维技术。它特别适合用于高维数据的可视化。t-SNE 的主要目标是将高维数据映射…

修改vscode的字体为等宽字符

在文件——首选项——设置 中 搜索 Editor: Font Family 将内容改为下面的 Consolas, Courier New, monospace 之后重启Vscode就行了

初步探究Rust生态与图形界面编程

引言 Rust作为一种现代的、安全的系统编程语言,自2010年问世以来,逐渐在开发社区中崭露头角。它的内存安全保证、并发处理能力、以及无需垃圾回收机制的高性能特性,使得它成为了开发系统工具、网络服务、以及嵌入式系统的热门选择。然而&…

(五十三)第 8 章 动态存储管理(伙伴系统)

1. 背景说明 2. 示例代码 buddySystem.h // 伙伴系统实现头文件#ifndef BUDDY_SYSTEM_H #define BUDDY_SYSTEM_H#include "errorRecord.h"#define POWER_TIME 10 // 可利用空间总容量的 2 的幂次,子表的个数为 POWER_TIME + 1 #define MAX_USED_BLOCK_NUM 100 //…

我的 Java 面试“打怪升级”之路01

前言 在当今的科技行业,Java 作为一门广泛应用的编程语言,其相关的岗位竞争可谓十分激烈。作为一名求职者,经历 Java 面试就如同一场充满挑战的“打怪升级”游戏。在这里,我想和大家分享一下我在 Java 面试中的一些经历和感悟。 …

python求回文数

给你一个整数 x ,如果 x 是一个回文整数,返回 true ;否则,返回 false 。 回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 例如,121 是回文,而…

SwiftUI 截图(snapshot)视频画面的极简方法

功能需求 在 万物皆可截图:SwiftUI 中任意视图(包括List和ScrollView)截图的通用实现 这篇博文中,我们实现了在 SwiftUI 中截图几乎任何视图的功能,不幸的是它对视频截图却无能为力。不过别着急,我们还有妙招。 在上面的演示图片中,我们在 SwiftUI 中可以随心所欲的截图…

智能车的网络安全隐患及其防护技术

**题目:智能车的网络安全隐患及其防护技术** **摘要** 智能车的发展为人们的出行方式带来了革命性的变化,但也带来了网络安全隐患。本文分析了智能车的主要网络安全威胁,包括车辆通信系统、自动驾驶系统、以及车载娱乐系统的潜在风险。在此…

前端Vue组件化实践:打造灵活可维护的地址管理组件

随着前端技术的不断演进,复杂度和开发难度也随之上升。传统的一体化开发模式使得每次小小的修改或功能增加都可能牵一发而动全身,严重影响了开发效率和维护成本。组件化开发作为一种解决方案,通过模块化、独立化的开发方式,实现了…

【java算法专场】滑动窗口(下)

目录 水果成篮 算法分析 算法步骤 示例 算法代码 找到字符串中所有字母异位词 算法分析 算法步骤 示例 算法代码 优化 算法代码 串联所有单词的子串 算法分析 算法步骤 示例 算法代码 最小覆盖子串 算法分析 算法步骤 示例 算法代码 算法分析 这道题其实…

AI绘画Stable Diffusion 自制素材工具: layerdiffusion插件—透明背景生成工具

大家好,我是设计师阿威 今天给大家分享一款AI绘画的神级插件—LayerDiffusion。 Layerdiffusion是一个用于stable-diffusion-webui 的透明背景生成(不是生成图再工具扣图,是直接生成透明背景透明图像)插件扩展,它可以…

NSIS 之 NsDialogs 常见问题解答

如何启用/禁用控件 使用标准 NSIS EnableWindow 命令。 NSDialogs 允许您弹出通过 ${NSD_Create*} 创建的控件的 hwnd (句柄)。EnableWindow 将 hwnd 作为其参数之一。通过它,您可以轻松启用/禁用控件。 !include "nsDialogs.nsh" !include "winm…

代码随想录:图论_01基础

图论基础 图的存储 邻接矩阵 使用 二维数组 来表示图结构。 邻接矩阵是从节点的角度来表示图&#xff0c;有多少节点就申请多大的二维数组。为了节点标号和下标对齐&#xff0c;我们申请 n 1 * n 1 这么大的二维数组。 vector<vector<int>> graph(n 1, vector…

特斯拉的选择:.NET技术栈的工业级魅力

简述 在全球科技巨头的竞技场上&#xff0c;特斯拉以其创新精神和卓越技术引领着电动汽车和可再生能源行业。而在这场技术革命的背后&#xff0c;特斯拉的技术栈选择尤为引人注目。本文将深入探讨特斯拉为何青睐.NET技术栈&#xff0c;并分析这一选择背后的战略考量。 技术栈的…

【Linux 文件读写描述符重定向 Linux 一切皆文件缓冲区】

文章目录 一、文件的读写操作二、文件描述符三、文件重定向四、理解 Linux 一切皆文件五、文件缓冲区 一、文件的读写操作 文件内容属性 当文件没有被操作的时候&#xff0c;一般文件还是在磁盘当中 文件操作文件内容的操作文件属性的操作&#xff0c;文件操作有可能即改变内容…

二叉树---后序遍历(递归与迭代)

题目&#xff1a;给你一棵二叉树的根节点 root &#xff0c;返回其节点值的 后序遍历 。 思路一&#xff1a;递归法。 代码&#xff1a; public List<Integer> postorderTraversal(TreeNode root) {List<Integer> resultnew ArrayList<>();postOrder(root,…

如何利用Gunicorn的日志记录监控Web应用

如何利用Gunicorn的日志记录监控Web应用 引言 在构建和维护Web应用时&#xff0c;日志记录是一个至关重要的工具。它不仅可以帮助开发者了解应用的运行状态&#xff0c;还能迅速定位和解决问题。Gunicorn作为一个流行的Python WSGI HTTP服务器&#xff0c;提供了丰富的日志记…

代码运行故障排除:PyCharm中的问题解决指南

代码运行故障排除&#xff1a;PyCharm中的问题解决指南 引言 PyCharm&#xff0c;作为一款流行的集成开发环境&#xff08;IDE&#xff09;&#xff0c;提供了强大的工具来支持Python开发。然而&#xff0c;即使是最先进的IDE也可能遇到代码无法运行的问题。这些问题可能由多…

《python程序语言设计》2018版第5章第55题利用turtle黑白棋盘。可读性还是最重要的。

今天是我从2024年2月21日开始第9次做《python程序语言设计》作者梁勇 第5章 从2019年夏天的偶然了解python到2020年第一次碰到第5章第一题。彻底放弃。再到半年后重新从第一章跑到第五章&#xff0c;一遍一遍一直到今天2024.7.14日第9次刷第五章。 真的每次刷完第五章感觉好像…