From 503b9dc12b0b2b4cc2d9507dff31412993a463c2 Mon Sep 17 00:00:00 2001 From: Billts-noo <141442230+Billts-noo@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:54:29 +0800 Subject: [PATCH] Add files via upload --- __pycache__/functions.cpython-311.pyc | Bin 0 -> 1607 bytes __pycache__/functions.cpython-312.pyc | Bin 0 -> 1412 bytes __pycache__/lists.cpython-311.pyc | Bin 0 -> 192 bytes __pycache__/main.cpython-311.pyc | Bin 0 -> 6624 bytes __pycache__/main.cpython-312.pyc | Bin 0 -> 5550 bytes __pycache__/sb.cpython-311.pyc | Bin 0 -> 159 bytes __pycache__/student.cpython-311.pyc | Bin 0 -> 1080 bytes __pycache__/student.cpython-312.pyc | Bin 0 -> 984 bytes functions.py | 38 ++++++ gui.py | 138 ++++++++++++++++++++++ main.py | 164 ++++++++++++++++++++++++++ students info.json | Bin 0 -> 79 bytes students names.json | Bin 0 -> 27 bytes 13 files changed, 340 insertions(+) create mode 100644 __pycache__/functions.cpython-311.pyc create mode 100644 __pycache__/functions.cpython-312.pyc create mode 100644 __pycache__/lists.cpython-311.pyc create mode 100644 __pycache__/main.cpython-311.pyc create mode 100644 __pycache__/main.cpython-312.pyc create mode 100644 __pycache__/sb.cpython-311.pyc create mode 100644 __pycache__/student.cpython-311.pyc create mode 100644 __pycache__/student.cpython-312.pyc create mode 100644 functions.py create mode 100644 gui.py create mode 100644 main.py create mode 100644 students info.json create mode 100644 students names.json diff --git a/__pycache__/functions.cpython-311.pyc b/__pycache__/functions.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4a7fb4b6f7ad63181611e1a5f19f69a60138368 GIT binary patch literal 1607 zcmZ`(&ube;6n?WBNtRWqiS5R5Wy>n@MIy94^iWFZq4XMIF!bQMh()t@?Aj}LcGVJ4 zK!(tYG-*t6k^6&MF0Jd5It}#Dv`+B9urh*}1w)})$%aA&zU9<6v)aY3nzuV|XXeeD zeee6;%#X2HKcFo9{qF2{0f4{6z!Rn0Ie8sBRbVg;j4)-9EGg3pfjNBgiW*QU3*3b1 zAfu>5EQmVHLa6&#cnZ>e#R+t8-`{Mne%$_bx4pY@{7w02Yo+;kuf4YIR35ayy6JrK zxb?+@WAVQPqSE@&w+u5{Y#|^WX)72%-$SuwrrX3UGd40AZhq$2slriEP3=u~v z_4F0?#?0h(^IAclndF59EpN_rBQ;W2Rb8Fa_{?lk&ztiF-FSKVx*avHsa%tr8(iQV z!DbAgDnsWvxR5Gm4~E9dSH*LJvyc~AdLpuw8N2YC-aLNahWF0jASJTkuP?#-5-m+5*wlV+-MR0q-f?!SM|*3|*WWrjTkW-t=H6y&g$dvDOXP-P`h9@fsXjV)rKD`( z9{2ox2$&-6t~|pBdVB;BU18+ER;FM<28u7>g4S=l&aIjYG}gIWheZLFYiU(hom(6K zJX*=7gIpx)k`Pjtmo=U7AkNsqWj?Q)>3~Z~Xbue;x6kR?M`tK7gnKHLa!HD+jCp1* zB1vE~CQ%_d!^w5C_D+5Ha%1?iMTZXQ`6u+^KD}s-r0X=(pc#v14(Y%XIh()`MryL^Wl!T4P@PC5m8z3A+9YIKGY=GcmYsx=q1)?sy@!NMa|TFOh@oH zm#`VHqC!kP4A+P1G})j@izfdMLPQZ?iCH!svBS9>E97%IF0M4U00ieUFnL|bgCz;% z;*URpbd?-G?Ypv6V8uo4O+JbyfvoWXDm+w#96-i`%%703&c2-xymYDdmIY(w_-d>Z e3X^09e06~mJhHxu2gz6me045B@KpCI8PdPBo0n$* literal 0 HcmV?d00001 diff --git a/__pycache__/functions.cpython-312.pyc b/__pycache__/functions.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cf77a2ccb687ba6bfbbc0fc83d2c81d5f05eac50 GIT binary patch literal 1412 zcmZvc-D?v|6u{4HCP~|v_|f`NW7}2x;L25B)CVaSx!hNSAc)jTShCyN*lx<~t`dll zf@rKCEtg8_2R0Rzic|$3tXAnC;7i4db?KYgq=gH&wr@V&Gn1sI>Irk0Ip^%moZmT< z_rYKtpv3<@-TA-+@RctrB9$jAhjEex4cb8?n$$yjrFMxx7ye?B>QSlYxdiQAjiUBx zUetcghq@-|S8D85{J8jRtT=SJ_;RW^HM)2&z3{j{|8BZCJnm**6z^Peue>YVda=k) zQ;6d~VcD8)Sh33S+)i-d^hhjHbfPNA6%YKRHz#zvjLf%)iYo zrvKqvXR-@p;}J!2LZ)R$4YgM{qdncG1*3oGjF{?XanEU&ZPQW~?GF@zLGS0XbhZ#bZhNX3| zMNUWN8k+i#t)K;BJim(YJVmZYagqhAVu!!s%w~X#Bt_!YY|8!=oZEvZkn8m+62tPG z017|&0$ToeRtwmAVL>U3& z2{`pkw`^ua%RWJntw&D-4s#c(H00~$Wstn#jDIe$X|U~T+sMI>ftI=Y?E{f-UbM3S zhOH?tMT1EBGEOk%RU9cS^V4#&7bR;o?YI{Mf0C5+wEP_bi>D*xw~|kssEi zqm-u6cnFXJhcK>F0aKHbn5zoz5uW8H?O zcuH7(UFgu6v%%0WtifpV&t+LIfexseR&g_alQ0hR5Gn+`wRyzKo&31$e(8`h8C*Y&&}i(Z$B)7%ui16M=Dw|f`CL5`k3CEIIjzK_%11bivr!6Mht0s zk8bI!h#K*j-8fACcYug0R7M(RX>%2nPqam_h$yv=KN{5%v1pX>XIZKqFPON7c(bCj z1%1Z%e*)rDQK0WNZM_N2?$Q5bJJ7{D&)kP<$wLVF0()HuFZp2S?%ZE9(3B1h1($t( V(!9KdlJIiKOPW?Tc!(^v`yY)}Yl;8> literal 0 HcmV?d00001 diff --git a/__pycache__/lists.cpython-311.pyc b/__pycache__/lists.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a15f43c7d3789dfcd3c68d548809b82f1800e8f6 GIT binary patch literal 192 zcmZ3^%ge<81c$c%PSpg`k3k$5V1zP0^8p#t8PXY|K$tOwA(%mv(NB}<7H@G$X?$j0 zT7G;^W^u_aJ`guAF*mgs%wNgy8DzjOZ5OMUfXb4L{JfZeqWrAXcwRe?g6XLs8WAkZJpri~2aKv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NmDGQ2bo^AZVqR$kgVvWYL-DxU(=CNgb2)0SS0yJIFV zVRVyaRf2*t@ymah2+`1(ISOY?Azu`Ka`;*`W9}AkO@VLn5mI)p@LlkUuh{nt&jmC6 zv01&O+PecXa=NSA?+aJJ1L1pD>d3{(Tc?s2hI7ydnB(t763vG9^vU@=4v@nOKZp0C z9DWwT{+Eb!XD+Arz9DaeIm`k*a0S~yK#oNl54?2DG`jwR^C~UWtrF{2@$_neUMus*O+agS5R%uv&+wT{X2E<6g;s?R#U8*jNzr8; zTm!i{$&K4m*)$x_84fR71THc%@a|92dO`mUABUM(MhyWBCU(Mv9L~TwoXT*Ru?Sf3V3MyW zol;3~x0mygy7U!v%ZB~F)!as?!_zGIUy!g3 zq^LNmBHhH(O=&IC7$Y0fDwV-;PfcsI4-g38M-XOI zVof8rW^UZ(h%HO2Xp;>{T2-1h;1U9HPpvJ7&ov;T`gA#BFn>QEeLl`qMqiW}7giBd zRlIU;%$HVaD{N^7+naC+fw-sE+shsx5HWSS5|!JBYyY_-wjy5cinV;yI@B6#{l!-K zq`I2erjIrcZH~bY-lU=mSlU#TZp=mUOFoicDypIz)7z-*OOZE|#T-OeL06?6@UEnW GK;wTJ>nNZA literal 0 HcmV?d00001 diff --git a/__pycache__/main.cpython-312.pyc b/__pycache__/main.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4ce31e2a5aeae057d3926b7a4f4087ac45e31e77 GIT binary patch literal 5550 zcmb_gZ*Wsp7QZif`S<#grb*hg(A3b@Vsz_ewkH z2QTDu-?`_Uci+9g^E>DAAG4W3(DuCeY)g$Dp&#&r-00lk)@u|(BZxyBGq<%s9EFF`wX16$;i=7CQjGHaQdbK&Ts%Vv78ZlGiQR{!ZFYn zas|*^ITrdN-o}|D=on1W#03jl3-7-w-R0Ll${-S|g2!m4maKhPC5H zA>JtL22aIYA#ZvQ9n;7&O(lE@XC?350P|+$y(awTVy@^eeJAhC=^J3)qUeL%M*LuT z;Uc-6$c-SkD)Imop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pyc b/__pycache__/student.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..916dc35c630191887589050f397f7f7dfa4187e3 GIT binary patch literal 1080 zcmbVJ&ubGw6n?Y2`O%~?VyaZAuzC<8*pncN?bVa9w6_o#LS~b;q?6=KDISR07cU_vgzG z7{FIbLNkWJz{H>p8r%i}O%QBH1K7jAvOEZF0kV22EYKS64z6I*1`F~`Kwc9puM4dS zc|+({q^t>}Y2>3Kf|ZzvVwad7TW~#L*{(N+H+ye(j-I_bdjGMcQ`ezUbIJ#o(6yn? z>cEFv0Cf#Be2Ox`u&L&q#jMxb?sXpZHlC}d-#))SeE2rEtNDgqT(SIU#j=GZv$}6M zR<$gnctyt0IW)>N&Eu=(n}xYGcd=#{=45TzD!GLrR>!790hBdUef@bG~FR zxty<`9v+(xE5xibfvy2xCMH|P##r~<6fVgYegmw7AC;EtNxL+92^Q&E@b1ePv{8sU zEMuf>3uVB3bbbrA4U#3Ni0nM=J$d~7(+iLEHV+$}UTY6i8NoEmWE>ZV?wXQ#_hXzp zu0-tV-`Il!?K)HF8qiJ8Y+ieL;~+hQzjwxmq>2vWGct(>{#!CY*es`z=>al7Zd>VlLYyou7VV0KoR@3snGp3K#c@KeNbgP%+eo?@k{%$=W#gn8&EecnaK2I# zUX|i;&hL4}>Tn0i5w#NMlDPDBx{9! SmSWiUr29d&pa0kh8vg=sp#DGr literal 0 HcmV?d00001 diff --git a/__pycache__/student.cpython-312.pyc b/__pycache__/student.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..27626c9c38b163cb11014bd048672461216ce68f GIT binary patch literal 984 zcmbVL&1(}u6o31XO`0^Onkx09u)Vp6J$Y%dy?Qbfds_lS$V}3PcB8YqNJ_*AIRtD$ zP)xLx>cv=!XipXt`~$r7822RTwnt0%AoS#$-NY7;zQddMG4IXqy&v;6olXME?(Ut^ zLkZxAa0a6GjbIFoHpp-bC^Uge+j5jKp(Yzjad2Op{R{+G(P;w%Q=(wXR5BGRH^Ee? z!eS+vs!i3@XbdCqnr6hk_`Ks%W;yN<*7@(=96Z}R*!fgcM9;p6*1`{TRBfnBbs%U( zQkT)g0V1hMhU}h4+iz|7-N*jw^Qh&|FR%9>z0YmQo@y1AnWvSRMHx2~Pqo=niECKG z7mgMjIDjhYDK%$~sV- zzA{+-sq{K*sPkYbxoEB3r~Z?*U!PyPf^&Vp(e+!~=<*o4hQt$i*y4Si3l_XMA-2PD zmdwd4VL)WT-uQ0@5l}7yri8$} zgvIWYkhP?+BIX7>MSxSqg@RRPNI|K(k{y6P6&x18BMy3_xO~BZE;tCW=8S|OP`p8i zmn3AlO5G)44-<0FEiCmjxEES262iqAJq1_7&!EN6q1uA5RfvZR?m{J&YF|dxgl}s0 zNL6Cvhe;_m+sOuiN1(~EiKtGLcE^dE5ujOq5ffq03>t@uBuT&Jv@~%9 HsKSCjZRq7b literal 0 HcmV?d00001 diff --git a/functions.py b/functions.py new file mode 100644 index 0000000..0ddc8c4 --- /dev/null +++ b/functions.py @@ -0,0 +1,38 @@ +"""管理系统需要使用到的函数""" + +from student import Student + +# 获得主程序的列表供函数使用 +stu_names_list, stu_info_list = [], [] + + +def share_lists( + names_list, + info_list, +): + """接受主程序传递的列表""" + global stu_names_list, stu_info_list + stu_names_list = names_list + stu_info_list = info_list + + +# 功能函数 +def return_student_info(name): + """根据名字返回学生信息""" + for student in stu_info_list: + if student.name == name: + return student + + +def add_student(name, gender): + """添加学生到列表""" + new_student_info = Student(name, gender) + stu_info_list.append(new_student_info) + stu_names_list.append(name) + print("添加成功!") + + +def delete_student(info, name): + """根据名字删除列表中的学生""" + stu_info_list.remove(info) + stu_names_list.remove(name) diff --git a/gui.py b/gui.py new file mode 100644 index 0000000..f5ec469 --- /dev/null +++ b/gui.py @@ -0,0 +1,138 @@ +import tkinter as tk +import ttkbootstrap as ttk +import functions as fc +import main + + +class StudentManagementGUI: + def __init__(self, root): + global screen_height, screen_width, root_width, root_height, add_width, add_height + self.root = root + self.root.title("学生管理系统") + screen_width = root.winfo_screenwidth() + screen_height = root.winfo_screenheight() + root_width = 600 + root_height = 500 + add_width = 400 + add_height = 150 + self.root.geometry( + f"{root_width}x{root_height}+{int((screen_width-root_width)/2)}+{int((screen_height-root_height)/2)}" + ) + # Student List Label + self.list_label = ttk.Label(root, text="学生列表:") + self.list_label.pack() + # Frame for student list + self.list_box = tk.Listbox(root) + self.list_box.pack(pady=10, fill=tk.BOTH, expand=False) + + # Buttons Frame + self.buttons_frame = ttk.Frame(root) + self.buttons_frame.pack(pady=10) + # “添加学生”按钮 + self.add_button = ttk.Button( + self.buttons_frame, text="添加学生", command=self.add_student + ) + self.add_button.grid(row=0, column=0, padx=5) + + # “删除学生”按钮 + self.del_button = ttk.Button( + self.buttons_frame, text="删除学生", command=self.del_student + ) + self.del_button.grid(row=0, column=1, padx=5) + + # Find Student Button + # self.find_button = ttk.Button( + # self.buttons_frame, text="查找学生", command=self.find_student + # ) + # self.find_button.grid(row=0, column=2, padx=5) + + # “保存并退出”按钮 + self.save_quit_button = ttk.Button( + self.root, text="保存并退出", command=self.save_and_quit + ) + self.save_quit_button.pack() + + # 导入学生数据 + main._load_data() + fc.share_lists(main.stu_names_list, main.stu_info_list) # 向模块传递列表 + self.update_student_list() + + def add_student(self): + def add(): + name = name_var.get() + gender = gender_var.get() + fc.add_student(name, gender) + self.update_student_list() + window.destroy() + + window = ttk.Toplevel() + window.title("添加学生") + window.geometry( + f"{add_width}x{add_height}+{int((screen_width-add_width)/2)}+{int((screen_height-add_height)/2)}" + ) + window.resizable(0, 0) + name_var = ttk.StringVar(window) + gender_var = ttk.StringVar(window) + label1 = ttk.Label(window, text="学生姓名:") + entry1 = ttk.Entry(window, textvariable=name_var) + button1 = ttk.Button(window, text="添加", command=add) + c1 = ttk.Checkbutton( + window, width=4, variable=gender_var, onvalue="男", text="男" + ) + c2 = ttk.Checkbutton( + window, width=4, variable=gender_var, onvalue="女", text="女" + ) + label1.grid(row=1, column=1) + entry1.grid(row=1, column=2, pady=10) + c1.place(x=150, y=60) + c2.place(x=250, y=60) + button1.grid(row=2, column=1) + window.mainloop() + + def del_student(self): + stu_name = main.stu_names_list[self.list_box.index("active")] + stu_info = main.stu_info_list[self.list_box.index("active")] + + def _del(): + fc.delete_student(stu_info, stu_name) + window.destroy() + self.update_student_list() + + window = ttk.Toplevel() + label = ttk.Label(window, text=f"确定要删除{stu_name}吗?") + button = ttk.Button(window, text="确定", command=_del) + label.pack() + button.pack() + window.mainloop() + + # def find_student(self): + # window = ttk.Toplevel() + # str_var = ttk.StringVar(window) + # l1 = ttk.Label(window,text="要查找的学生姓名:") + # e1 = ttk.Entry(window,textvariable=str_var) + # window.mainloop() + + def save_and_quit(self): + main._save_data() + self.root.destroy() + + def update_student_list(self): + self.list_box.delete(0, tk.END) + if main.stu_info_list: + for stu_info in main.stu_info_list: + self.list_box.insert(tk.END, str(stu_info)) + else: + self.list_box.insert(tk.END, "无学生") + + # self.list_text.delete(1.0, tk.END) + # if main.stu_info_list: + # for stu_info in main.stu_info_list: + # self.list_text.insert(tk.END, str(stu_info) + "\n") + # else: + # self.list_text.insert(tk.END, "无学生") + + +if __name__ == "__main__": + root = ttk.Window(themename="darkly") + app = StudentManagementGUI(root) + root.mainloop() diff --git a/main.py b/main.py new file mode 100644 index 0000000..ca2c69d --- /dev/null +++ b/main.py @@ -0,0 +1,164 @@ +import functions as fc +from student import Student +import os +import pickle + +# 变量名缩写: +# stu(s) = student(s) +# info = information +stu_names_list, stu_info_list = [], [] +active = True +input_message = "输入数字以执行对应操作:" +stu_info_data = "students info.json" +stu_names_data = "students names.json" + + +def _load_data(): + global stu_info_list, stu_names_list + if os.path.exists(stu_info_data): # 判断数据文件是否存在 + with open(stu_info_data, "rb") as info_data: + stu_info_list = pickle.load(info_data) # 如果存在则导入数据 + print("已找到文件students info.json!") + else: + print( + """找不到文件students info.json! + 不过这不影响系统的正常运行,系统退出后会自动生成""" + ) + + if os.path.exists(stu_names_data): + with open(stu_names_data, "rb") as name_data: + stu_names_list = pickle.load(name_data) + print("已找到文件students names.json!") + else: + print( + """找不到文件students names.json! + 不过这不影响系统的正常运行,系统退出后会自动生成""" + ) + + +def _show_list(): + if stu_info_list: + print(f"\n学生列表共 {len(stu_info_list)} 名学生:") + for stu_info in stu_info_list: + print(stu_info) + else: + print("\n无学生") + + +def _add_student(): + new_stu_name = input("请输入要添加的学生的姓名:") + if new_stu_name: + while True: + new_stu_gender = input("0 男\n1 女\n请选择新学生的性别:") + if new_stu_gender == "0": + fc.add_student(new_stu_name, "男") + break + elif new_stu_gender == "1": + fc.add_student(new_stu_name, "女") + break + else: + print("别瞎jb乱搞") + else: + print("别瞎jb乱搞") + + +def _del_student(): + while True: + del_stu_name = input("请输入要删除的学生的姓名:") + del_stu_info = fc.return_student_info(del_stu_name) + if del_stu_info: + fc.delete_student(del_stu_info, del_stu_name) + print(f"学生{del_stu_name}已被删除!") + break + elif not del_stu_name: + print("已退出!") + break + else: + print(f"未找到学生{del_stu_name}!请检查输入是否正确") + + +def _find_student(): + while True: + find_stu_name = input("请输入要查找的学生的姓名:(按回车退出)") + find_stu_info = fc.return_student_info(find_stu_name) + if find_stu_info: + print("\n查询结果如下:") + print(find_stu_info) + way1 = input(f''' +0 修改信息 1 退出 +{input_message} +''') + if way1 == '0': + changed_name,changed_gender = input('请依次输入修改后的姓名、性别:\n').split() + find_stu_info.change_info(changed_name,changed_gender) + print('修改成功!') + if way1 == '1': + None + _show_list() + break + elif not find_stu_name: + print("已退出!") + break + else: + print(f"未找到学生{find_stu_name}!请检查输入是否正确") + + +def _save_data(): + pickle.dump(stu_info_list, file=open(stu_info_data, "wb")) + pickle.dump(stu_names_list, open(stu_names_data, "wb")) + print("数据保存成功!") + +if __name__ == "__main__": + _load_data() + fc.share_lists(stu_names_list, stu_info_list) # 向模块传递列表 + + # 简介 + print( + """ +——————学生管理系统Beta—————— + By Billts_noo""" + ) + + # 主程序 + while active: + main_way = input( + f""" +——————————主菜单—————————— + 0 显示学生列表 + 1 保存并退出 +{input_message}""" + ) + + # 主菜单 + # 显示学生列表 + if main_way == "0": + _show_list() + while True: + way = input( + f""" +——学生列表菜单—— + 0 添加学生 + 1 删除学生 + 2 查找学生 +任意输入 回到主菜单 +{input_message}""" + ) + + # 学生列表菜单 + if way == "0": + _add_student() + + if way == "1": + _del_student() + + if way == "2": + _find_student() + + else: + break + # 退出 + if main_way == "1": + # 保存数据 + _save_data() + + active = False diff --git a/students info.json b/students info.json new file mode 100644 index 0000000000000000000000000000000000000000..ecec64b0a8140329dbbb4bc9c866a15491d10840 GIT binary patch literal 79 zcmZo*nd-s-0kKnh*o#X_Q&RIvfUICBYw{G$#woQ^G1ES~R7H`T3OXQ%aK(^#Fz{ApHOU literal 0 HcmV?d00001 diff --git a/students names.json b/students names.json new file mode 100644 index 0000000000000000000000000000000000000000..8c7394a97b1cbf15da3ac7a4f71190896c5c609b GIT binary patch literal 27 fcmZo*nJT~l0kKnhIG@d%{&e@Qmvg2~Nz?-XY@!Nd literal 0 HcmV?d00001