python tk窗口学生宿舍管理系统

2024-01-20 20:59

本文主要是介绍python tk窗口学生宿舍管理系统,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Python 图形化编辑常用的工具有很多,例如:
Tkinter:Tkinter 是 Python 的标准 GUI(图形用户界面)库,它提供了一个快速简便的方法来创建 GUI 应用程序。Tkinter 是面向对象的,封装了Tk GUI工具包的Python接口。使用 Tkinter,可以创建简单的图形化界面,例如窗口、按钮、标签等。它非常适合初学者和中小学生的信息技术教育。
PyQt:PyQt 是一个功能强大的图形用户界面库,基于 Qt 库,为 Python 提供了丰富的 GUI 组件和功能。PyQt 适合开发复杂的应用程序,支持跨平台操作,可以在 Windows、MacOS 和 Linux 上运行。
wxPython:wxPython 是一个开源的 Python GUI 工具包,用于创建跨平台的图形用户界面。wxPython 支持多种操作系统,如 Windows、MacOS 和 Linux。它提供了丰富的控件,可以创建复杂的 GUI 应用程序。
Kivy:Kivy 是一个开源的 Python GUI 工具包,用于开发多点触摸应用程序。它可以运行在 Windows、Linux、OS X、Android 和 iOS 等平台上。Kivy 提供了丰富的控件,使得开发人员可以轻松地创建出美观且功能强大的应用程序。等等

虽然Tkinter窗口已经存在很长时间,界面设计也没有其他工具精细,但仍然是各大学校教学常用工具,对于初学者也非常友好,本文将通过Tkinter设计一个学生住宿系统。

主要实现如下功能:

1.管理系统要实现学生信息的录入,删除,检索。
2.使用一个二阶列表来模拟数据库储存学生信息(感兴趣的朋友可以试着外链数据库实现,这里不再做赘述。)
3.宿舍管理系统录入信息时,需要避免错误信息和重复信息并给予提示。
4.在检索宿舍信息的时候,使用学生的姓名,班级和住址作为主码。
5.学生的录入和检索应该区分男女生宿舍其信息分别储存,以便于检索方便。
6.点击相应功能按钮时打开新的窗口并关闭原来窗口。
7.灵活操作,每集页面需添加返回上级菜单功能和返回主菜单功能。

废话少说,上代码:

import tkinter as Tk
def f1():app.destroy()global app1app1 = Tk.Tk()app1.update()app1.geometry('800x600')app1.title("学生查询系统")app1.config(bg="gray")m = Tk.Message(app1, text="学生查询系统", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)t1 = " 寝室公约1\n  1、早晨起床轻手轻脚,不要制造声响。\n  2、每天的值日生必须按时将宿舍打扫干净,及时处理垃圾。\n\3、电脑音响开到自己能听见即可,戴上耳机更好。\n  4、个人物品放在各自的橱柜里,不得乱扔,更不要随便占领别人的地盘。\n\5、卧谈会时间不宜过长,适可而止,最晚12点睡觉。\n  6、进出请随手关门。\n  7、未经允许,不要乱拿他人的东西。\n\8、搞好个人卫生,勤洗衣服勤洗澡。\n  9、在宿舍有大声唱歌、抽烟、打呼噜等特殊嗜好者,除非其他人都欣赏,否则请慢慢改掉。\n\10、最后一个离开宿舍者,关好窗子锁好门。\n"m2 = Tk.Message(app1, text=t1, font=("SimKai", 15, "bold"))m2.config(bg="gray", width=400)m2.place(x=380, y=70, width=400, height=520)b1 = Tk.Button(app1, text="男生宿舍", font=("SimKai", 15, "bold"), command=f1_1)b1.config(bg="gray", width=200)b1.place(x=40, y=150, width=200, height=90)b2 = Tk.Button(app1, text="女生宿舍", font=("SimKai", 15, "bold"), command=f1_2)b2.config(bg="gray", width=200)b2.place(x=40, y=260, width=200, height=90)b3 = Tk.Button(app1, text="请假学生", font=("SimKai", 15, "bold"), command=f1_4)b3.config(bg="gray", width=200)b3.place(x=40, y=370, width=200, height=90)b4 = Tk.Button(app1, text="主菜单", font=("SimKai", 15, "bold"), command=f1_31)b4.config(bg="gray", width=200)b4.place(x=40, y=480, width=200, height=90)def f1_1():app1.destroy()global app1_1app1_1 = Tk.Tk()app1_1.update()app1_1.geometry('800x600')app1_1.title("男生宿舍")app1_1.config(bg="gray")m = Tk.Message(app1_1, text="男生宿舍", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)b1 = Tk.Button(app1_1, text="一号宿舍", font=("SimKai", 15, "bold"), command=f1_111)b1.config(bg="gray", width=200)b1.place(x=50, y=150, width=200, height=90)b2 = Tk.Button(app1_1, text="二号宿舍", font=("SimKai", 15, "bold"), command=f1_112)b2.config(bg="gray", width=200)b2.place(x=300, y=150, width=200, height=90)b3 = Tk.Button(app1_1, text="三号宿舍", font=("SimKai", 15, "bold"), command=f1_113)b3.config(bg="gray", width=200)b3.place(x=550, y=150, width=200, height=90)b4 = Tk.Button(app1_1, text="四号宿舍", font=("SimKai", 15, "bold"), command=f1_114)b4.config(bg="gray", width=200)b4.place(x=50, y=260, width=200, height=90)b5 = Tk.Button(app1_1, text="五号宿舍", font=("SimKai", 15, "bold"), command=f1_115)b5.config(bg="gray", width=200)b5.place(x=300, y=260, width=200, height=90)b6 = Tk.Button(app1_1, text="六号宿舍", font=("SimKai", 15, "bold"), command=f1_116)b6.config(bg="gray", width=200)b6.place(x=550, y=260, width=200, height=90)b7 = Tk.Button(app1_1, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_12_1)b7.config(bg="gray", width=200)b7.place(x=560, y=560, width=200, height=35)b8 = Tk.Button(app1_1, text="主菜单", font=("SimKai", 15, "bold"), command=f1_32_1)b8.config(bg="gray", width=200)b8.place(x=40, y=560, width=200, height=35)b9 = Tk.Button(app1_1, text="学生搜索", font=("SimKai", 15, "bold"), command=f41)b9.config(bg="gray", width=200)b9.place(x=50, y=400, width=700, height=90)
def f1_2():app1.destroy()global app1_2app1_2 = Tk.Tk()app1_2.update()app1_2.geometry('800x600')app1_2.title("女生宿舍")app1_2.config(bg="gray")m = Tk.Message(app1_2, text="女生宿舍", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)b1 = Tk.Button(app1_2, text="一号宿舍", font=("SimKai", 15, "bold"), command=f1_121)b1.config(bg="gray", width=200)b1.place(x=50, y=150, width=200, height=90)b2 = Tk.Button(app1_2, text="二号宿舍", font=("SimKai", 15, "bold"), command=f1_122)b2.config(bg="gray", width=200)b2.place(x=300, y=150, width=200, height=90)b3 = Tk.Button(app1_2, text="三号宿舍", font=("SimKai", 15, "bold"), command=f1_123)b3.config(bg="gray", width=200)b3.place(x=550, y=150, width=200, height=90)b4 = Tk.Button(app1_2, text="四号宿舍", font=("SimKai", 15, "bold"), command=f1_124)b4.config(bg="gray", width=200)b4.place(x=50, y=260, width=200, height=90)b5 = Tk.Button(app1_2, text="五号宿舍", font=("SimKai", 15, "bold"), command=f1_125)b5.config(bg="gray", width=200)b5.place(x=300, y=260, width=200, height=90)b6 = Tk.Button(app1_2, text="六号宿舍", font=("SimKai", 15, "bold"), command=f1_126)b6.config(bg="gray", width=200)b6.place(x=550, y=260, width=200, height=90)b7 = Tk.Button(app1_2, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_12_2)b7.config(bg="gray", width=200)b7.place(x=560, y=560, width=200, height=35)b8 = Tk.Button(app1_2, text="主菜单", font=("SimKai", 15, "bold"), command=f1_32_2)b8.config(bg="gray", width=200)b8.place(x=40, y=560, width=200, height=35)b9 = Tk.Button(app1_2, text="学生搜索", font=("SimKai", 15, "bold"), command=f42)b9.config(bg="gray", width=200)b9.place(x=50, y=400, width=700, height=90)
def f1_3(t):t.destroy()global app;app = Tk.Tk()app.geometry('800x600')app.title("宿舍管理系统")app.config(bg="gray")m = Tk.Message(app, text="学生公寓", font=("SimKai", 30, "bold"))m.config(bg="gray", width=200)m.place(x=0, y=20, width=800, height=60)t1 = " 寝室公约1\n  1、早晨起床轻手轻脚,不要制造声响。\n  2、每天的值日生必须按时将宿舍打扫干净,及时处理垃圾。\n\3、电脑音响开到自己能听见即可,戴上耳机更好。\n  4、个人物品放在各自的橱柜里,不得乱扔,更不要随便占领别人的地盘。\n\5、卧谈会时间不宜过长,适可而止,最晚12点睡觉。\n  6、进出请随手关门。\n  7、未经允许,不要乱拿他人的东西。\n\8、搞好个人卫生,勤洗衣服勤洗澡。\n  9、在宿舍有大声唱歌、抽烟、打呼噜等特殊嗜好者,除非其他人都欣赏,否则请慢慢改掉。\n\10、最后一个离开宿舍者,关好窗子锁好门。\n"m2 = Tk.Message(app, text=t1, font=("SimKai", 15, "bold"))m2.config(bg="gray", width=400)m2.place(x=380, y=70, width=400, height=520)b1 = Tk.Button(app, text="学生查询", font=("SimKai", 15, "bold"), command=f1)b1.config(bg="gray", width=200)b1.place(x=40, y=150, width=200, height=90)b2 = Tk.Button(app, text="学生入住", font=("SimKai", 15, "bold"), command=f2)b2.config(bg="gray", width=200)b2.place(x=40, y=260, width=200, height=90)b3 = Tk.Button(app, text="学生退宿", font=("SimKai", 15, "bold"), command=f3)b3.config(bg="gray", width=200)b3.place(x=40, y=370, width=200, height=90)b4 = Tk.Button(app, text="退出系统", font=("SimKai", 15, "bold"), command=f)b4.config(bg="gray", width=200)b4.place(x=40, y=480, width=200, height=90)
def f1_4():app1.destroy()global app1_3,l1,s1app1_3 = Tk.Tk()app1_3.update()app1_3.geometry('800x600')app1_3.title("请假学生")app1_3.config(bg="gray")m = Tk.Message(app1_3, text="请假学生", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)b1 = Tk.Button(app1_3, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_41)b1.config(bg="gray", width=200)b1.place(x=560, y=530, width=200, height=35)b2 = Tk.Button(app1_3, text="主菜单", font=("SimKai", 15, "bold"), command=f1_42)b2.config(bg="gray", width=200)b2.place(x=40, y=530, width=200, height=35)b3 = Tk.Button(app1_3, text="开始检索", font=("SimKai", 15, "bold"), command=f1_43)b3.config(bg="gray", width=200)b3.place(x=300, y=530, width=200, height=35)s1 = Tk.Scrollbar(app1_3)l1 = Tk.Listbox(app1_3, yscrollcommand=s1.set)l1.config(bg="gray", font=("SimKai", 20, "bold"), width=700)s1.config(command=l1.yview)l1.place(x=50, y=120, width=700, height=360)s1.place(x=50, y=120, width=700, height=360)def f1_41():app1_3.destroy()global app1app1 = Tk.Tk()app1.update()app1.geometry('800x600')app1.title("学生查询系统")app1.config(bg="gray")m = Tk.Message(app1, text="学生查询系统", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)t1 = " 寝室公约1\n  1、早晨起床轻手轻脚,不要制造声响。\n  2、每天的值日生必须按时将宿舍打扫干净,及时处理垃圾。\n\3、电脑音响开到自己能听见即可,戴上耳机更好。\n  4、个人物品放在各自的橱柜里,不得乱扔,更不要随便占领别人的地盘。\n\5、卧谈会时间不宜过长,适可而止,最晚12点睡觉。\n  6、进出请随手关门。\n  7、未经允许,不要乱拿他人的东西。\n\8、搞好个人卫生,勤洗衣服勤洗澡。\n  9、在宿舍有大声唱歌、抽烟、打呼噜等特殊嗜好者,除非其他人都欣赏,否则请慢慢改掉。\n\10、最后一个离开宿舍者,关好窗子锁好门。\n"m2 = Tk.Message(app1, text=t1, font=("SimKai", 15, "bold"))m2.config(bg="gray", width=400)m2.place(x=380, y=70, width=400, height=520)b1 = Tk.Button(app1, text="男生宿舍", font=("SimKai", 15, "bold"), command=f1_1)b1.config(bg="gray", width=200)b1.place(x=40, y=150, width=200, height=90)b2 = Tk.Button(app1, text="女生宿舍", font=("SimKai", 15, "bold"), command=f1_2)b2.config(bg="gray", width=200)b2.place(x=40, y=260, width=200, height=90)b3 = Tk.Button(app1, text="请假学生", font=("SimKai", 15, "bold"), command=f1_4)b3.config(bg="gray", width=200)b3.place(x=40, y=370, width=200, height=90)b4 = Tk.Button(app1, text="主菜单", font=("SimKai", 15, "bold"), command=f1_31)b4.config(bg="gray", width=200)b4.place(x=40, y=480, width=200, height=90)
def f1_42():f1_3(app1_3)
def f1_43():text = ["姓名  性别 住址 班级 入住情况\n"]text1 = ""h = 1for i in Boydormitory:for j in i:if "请假" in j:text.append(j)h = 0for i2 in Femaledormitory:for j2 in i2:if "请假" in j2:text.append(j2)h = 0if h == 1:l1.delete(0, Tk.END)text1 = "该公寓查无人请假!!!!!!!!"l1.insert(Tk.END, text1)l1.place(x=50, y=120, width=700, height=360)s1.place(x=50, y=120, width=700, height=360)else:l1.delete(0, Tk.END)for g in text:l1.insert(Tk.END, g)l1.place(x=50, y=120, width=700, height=360)s1.place(x=50, y=120, width=700, height=360)
#***********************************************************************************************************************
def f1_31():f1_3(app1)
def f1_32_1():f1_3(app1_1)
def f1_32_2():f1_3(app1_2)
def f1_33():f1_3(app1_11)
def f1_12_1():f1_12_(app1_1)
def f1_12_2():f1_12_(app1_2)
def f1_32_21():f1_3(app1_11)
def f1_12_21():app1_11.destroy()global app1_1app1_1 = Tk.Tk()app1_1.update()app1_1.geometry('800x600')app1_1.title("男生宿舍")app1_1.config(bg="gray")m = Tk.Message(app1_1, text="男生宿舍", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)b1 = Tk.Button(app1_1, text="一号宿舍", font=("SimKai", 15, "bold"), command=f1_111)b1.config(bg="gray", width=200)b1.place(x=50, y=150, width=200, height=90)b2 = Tk.Button(app1_1, text="二号宿舍", font=("SimKai", 15, "bold"), command=f1_112)b2.config(bg="gray", width=200)b2.place(x=300, y=150, width=200, height=90)b3 = Tk.Button(app1_1, text="三号宿舍", font=("SimKai", 15, "bold"), command=f1_113)b3.config(bg="gray", width=200)b3.place(x=550, y=150, width=200, height=90)b4 = Tk.Button(app1_1, text="四号宿舍", font=("SimKai", 15, "bold"), command=f1_114)b4.config(bg="gray", width=200)b4.place(x=50, y=260, width=200, height=90)b5 = Tk.Button(app1_1, text="五号宿舍", font=("SimKai", 15, "bold"), command=f1_115)b5.config(bg="gray", width=200)b5.place(x=300, y=260, width=200, height=90)b6 = Tk.Button(app1_1, text="六号宿舍", font=("SimKai", 15, "bold"), command=f1_116)b6.config(bg="gray", width=200)b6.place(x=550, y=260, width=200, height=90)b7 = Tk.Button(app1_1, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_12_1)b7.config(bg="gray", width=200)b7.place(x=560, y=560, width=200, height=35)b8 = Tk.Button(app1_1, text="主菜单", font=("SimKai", 15, "bold"), command=f1_32_1)b8.config(bg="gray", width=200)b8.place(x=40, y=560, width=200, height=35)b9 = Tk.Button(app1_1, text="学生搜索", font=("SimKai", 15, "bold"), command=f41)b9.config(bg="gray", width=200)b9.place(x=50, y=400, width=700, height=90)
def f1_12_22():app1_11.destroy()global app1_2app1_2 = Tk.Tk()app1_2.update()app1_2.geometry('800x600')app1_2.title("女生宿舍")app1_2.config(bg="gray")m = Tk.Message(app1_2, text="女生宿舍", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)b1 = Tk.Button(app1_2, text="一号宿舍", font=("SimKai", 15, "bold"), command=f1_121)b1.config(bg="gray", width=200)b1.place(x=50, y=150, width=200, height=90)b2 = Tk.Button(app1_2, text="二号宿舍", font=("SimKai", 15, "bold"), command=f1_122)b2.config(bg="gray", width=200)b2.place(x=300, y=150, width=200, height=90)b3 = Tk.Button(app1_2, text="三号宿舍", font=("SimKai", 15, "bold"), command=f1_123)b3.config(bg="gray", width=200)b3.place(x=550, y=150, width=200, height=90)b4 = Tk.Button(app1_2, text="四号宿舍", font=("SimKai", 15, "bold"), command=f1_124)b4.config(bg="gray", width=200)b4.place(x=50, y=260, width=200, height=90)b5 = Tk.Button(app1_2, text="五号宿舍", font=("SimKai", 15, "bold"), command=f1_125)b5.config(bg="gray", width=200)b5.place(x=300, y=260, width=200, height=90)b6 = Tk.Button(app1_2, text="六号宿舍", font=("SimKai", 15, "bold"), command=f1_126)b6.config(bg="gray", width=200)b6.place(x=550, y=260, width=200, height=90)b7 = Tk.Button(app1_2, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_12_2)b7.config(bg="gray", width=200)b7.place(x=560, y=560, width=200, height=35)b8 = Tk.Button(app1_2, text="主菜单", font=("SimKai", 15, "bold"), command=f1_32_2)b8.config(bg="gray", width=200)b8.place(x=40, y=560, width=200, height=35)b9 = Tk.Button(app1_2, text="学生搜索", font=("SimKai", 15, "bold"), command=f42)b9.config(bg="gray", width=200)b9.place(x=50, y=400, width=700, height=90)
#***********************************************************************************************************************
def f1_111():f1_11(1,1)
def f1_112():f1_11(2,1)
def f1_113():f1_11(3,1)
def f1_114():f1_11(4,1)
def f1_115():f1_11(5,1)
def f1_116():f1_11(6,1)
def f1_121():f1_11(1,2)
def f1_122():f1_11(2,2)
def f1_123():f1_11(3,2)
def f1_124():f1_11(4,2)
def f1_125():f1_11(5,2)
def f1_126():f1_11(6,2)
#***********************************************************************************************************************
def f41():f4(1)
def f42():f4(2)
#***********************************************************************************************************************
def f4(t):if t==1:app1_1.destroy()text1="男生宿舍检索"else:app1_2.destroy()text1 = "女生宿舍检索"global  app1_11,m3,l1,s1,e1app1_11 = Tk.Tk()app1_11.update()app1_11.geometry('800x600')app1_11.title(text1)app1_11.config(bg="gray")m = Tk.Message(app1_11, text=text1, font=("SimKai", 30, "bold"))m.config(bg="gray", width=600)m.place(x=0, y=20, width=800, height=60)m1 = Tk.Message(app1_11, text="输入姓名或信息", font=("SimKai", 15, "bold"))m1.config(bg="gray", width=200)m1.place(x=50, y=150, width=200, height=90)m2 = Tk.Message(app1_11, text="检索结果", font=("SimKai",15,"bold"))m2.config(bg="gray", width=400)m2.place(x=380, y=150, width=400, height=90)e1=Tk.Entry(app1_11, font=("SimKai", 11))e1.config(bg="gray",width=200)e1.place(x=50,y=280,width=200,height=100)s1=Tk.Scrollbar(app1_11)l1=Tk.Listbox(app1_11,yscrollcommand=s1.set)l1.config(bg="gray", font=("SimKai",15,"bold"),width=400)s1.config(command=l1.yview)l1.place(x=380, y=260, width=400, height=260)s1.place(x=380, y=260, width=400, height=260)if t == 1:b1 = Tk.Button(app1_11, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_12_21)b1.config(bg="gray", width=200)b1.place(x=560, y=560, width=200, height=35)b3 = Tk.Button(app1_11, text="OK", font=("SimKai", 15, "bold"), command=f1_12_21l1)b3.config(bg="gray", width=200)b3.place(x=50, y=440, width=200, height=35)else:b1 = Tk.Button(app1_11, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_12_22)b1.config(bg="gray", width=200)b1.place(x=560, y=560, width=200, height=35)b3 = Tk.Button(app1_11, text="OK", font=("SimKai", 15, "bold"), command=f1_12_21l2)b3.config(bg="gray", width=200)b3.place(x=50, y=440, width=200, height=35)b2 = Tk.Button(app1_11, text="主菜单", font=("SimKai", 15, "bold"), command=f1_32_21)b2.config(bg="gray", width=200)b2.place(x=40, y=560, width=200, height=35)
#***********************************************************************************************************************
def f1_11(t,n):if n==1:app1_1.destroy()else:app1_2.destroy()global app1_11if n==1:if t == 1:text1 = "男生一号宿舍"elif t == 2:text1 = "男生二号宿舍"elif t == 3:text1 = "男生三号宿舍"elif t == 4:text1 = "男生四号宿舍"elif t == 5:text1 = "男生五号宿舍"else:text1 = "男生六号宿舍"else:if t == 1:text1 = "女生一号宿舍"elif t == 2:text1 = "女生二号宿舍"elif t == 3:text1 = "女生三号宿舍"elif t == 4:text1 = "女生四号宿舍"elif t == 5:text1 = "女生五号宿舍"else:text1 = "女生六号宿舍"app1_11 = Tk.Tk()app1_11.update()app1_11.geometry('800x600')app1_11.title(text1)app1_11.config(bg="gray")m = Tk.Message(app1_11, text=text1, font=("SimKai", 30, "bold"))m.config(bg="gray", width=600)m.place(x=0, y=20, width=800, height=60)text2=""if n==1:for i in Boydormitory[t - 1]:text2 = text2 + ielse:for i in Femaledormitory[t - 1]:text2 = text2 + im2 = Tk.Message(app1_11, text=text2, font=("SimKai", 15, "bold"))m2.config(bg="gray", width=800)m2.place(x=0, y=80, width=800, height=250)if n==1:b1 = Tk.Button(app1_11, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_11_1)else:b1 = Tk.Button(app1_11, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_11_2)b1.config(bg="gray", width=200)b1.place(x=560, y=560, width=200, height=35)b2 = Tk.Button(app1_11, text="主菜单", font=("SimKai", 15, "bold"), command=f1_33)b2.config(bg="gray", width=200)b2.place(x=40, y=560, width=200, height=35)#**********************************************************************************************************************def f1_11_1():app1_11.destroy()global app1_1app1_1 = Tk.Tk()app1_1.update()app1_1.geometry('800x600')app1_1.title("男生宿舍")app1_1.config(bg="gray")m = Tk.Message(app1_1, text="男生宿舍", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)b1 = Tk.Button(app1_1, text="一号宿舍", font=("SimKai", 15, "bold"), command=f1_111)b1.config(bg="gray", width=200)b1.place(x=50, y=150, width=200, height=90)b2 = Tk.Button(app1_1, text="二号宿舍", font=("SimKai", 15, "bold"), command=f1_112)b2.config(bg="gray", width=200)b2.place(x=300, y=150, width=200, height=90)b3 = Tk.Button(app1_1, text="三号宿舍", font=("SimKai", 15, "bold"), command=f1_113)b3.config(bg="gray", width=200)b3.place(x=550, y=150, width=200, height=90)b4 = Tk.Button(app1_1, text="四号宿舍", font=("SimKai", 15, "bold"), command=f1_114)b4.config(bg="gray", width=200)b4.place(x=50, y=260, width=200, height=90)b5 = Tk.Button(app1_1, text="五号宿舍", font=("SimKai", 15, "bold"), command=f1_115)b5.config(bg="gray", width=200)b5.place(x=300, y=260, width=200, height=90)b6 = Tk.Button(app1_1, text="六号宿舍", font=("SimKai", 15, "bold"), command=f1_116)b6.config(bg="gray", width=200)b6.place(x=550, y=260, width=200, height=90)b6.place(x=550, y=260, width=200, height=90)b7 = Tk.Button(app1_1, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_12_1)b7.config(bg="gray", width=200)b7.place(x=560, y=560, width=200, height=35)b8 = Tk.Button(app1_1, text="主菜单", font=("SimKai", 15, "bold"), command=f1_32_1)b8.config(bg="gray", width=200)b8.place(x=40, y=560, width=200, height=35)b9 = Tk.Button(app1_1, text="姓名搜索", font=("SimKai", 15, "bold"), command=f41)b9.config(bg="gray", width=200)b9.place(x=50, y=400, width=700, height=90)
def f1_11_2():app1_11.destroy()global app1_2app1_2 = Tk.Tk()app1_2.update()app1_2.geometry('800x600')app1_2.title("女生宿舍")app1_2.config(bg="gray")m = Tk.Message(app1_2, text="女生宿舍", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)b1 = Tk.Button(app1_2, text="一号宿舍", font=("SimKai", 15, "bold"), command=f1_121)b1.config(bg="gray", width=200)b1.place(x=50, y=150, width=200, height=90)b2 = Tk.Button(app1_2, text="二号宿舍", font=("SimKai", 15, "bold"), command=f1_122)b2.config(bg="gray", width=200)b2.place(x=300, y=150, width=200, height=90)b3 = Tk.Button(app1_2, text="三号宿舍", font=("SimKai", 15, "bold"), command=f1_123)b3.config(bg="gray", width=200)b3.place(x=550, y=150, width=200, height=90)b4 = Tk.Button(app1_2, text="四号宿舍", font=("SimKai", 15, "bold"), command=f1_124)b4.config(bg="gray", width=200)b4.place(x=50, y=260, width=200, height=90)b5 = Tk.Button(app1_2, text="五号宿舍", font=("SimKai", 15, "bold"), command=f1_125)b5.config(bg="gray", width=200)b5.place(x=300, y=260, width=200, height=90)b6 = Tk.Button(app1_2, text="六号宿舍", font=("SimKai", 15, "bold"), command=f1_126)b6.config(bg="gray", width=200)b6.place(x=550, y=260, width=200, height=90)b7 = Tk.Button(app1_2, text="上级菜单", font=("SimKai", 15, "bold"), command=f1_12_2)b7.config(bg="gray", width=200)b7.place(x=560, y=560, width=200, height=35)b8 = Tk.Button(app1_2, text="主菜单", font=("SimKai", 15, "bold"), command=f1_32_2)b8.config(bg="gray", width=200)b8.place(x=40, y=560, width=200, height=35)b9 = Tk.Button(app1_2, text="姓名搜索", font=("SimKai", 15, "bold"), command=f42)b9.config(bg="gray", width=200)b9.place(x=50, y=400, width=700, height=90)
def f1_12_(t):t.destroy()global app1app1 = Tk.Tk()app1.update()app1.geometry('800x600')app1.title("学生查询系统")app1.config(bg="gray")m = Tk.Message(app1, text="学生查询系统", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)t1 = " 寝室公约1\n  1、早晨起床轻手轻脚,不要制造声响。\n  2、每天的值日生必须按时将宿舍打扫干净,及时处理垃圾。\n\3、电脑音响开到自己能听见即可,戴上耳机更好。\n  4、个人物品放在各自的橱柜里,不得乱扔,更不要随便占领别人的地盘。\n\5、卧谈会时间不宜过长,适可而止,最晚12点睡觉。\n  6、进出请随手关门。\n  7、未经允许,不要乱拿他人的东西。\n\8、搞好个人卫生,勤洗衣服勤洗澡。\n  9、在宿舍有大声唱歌、抽烟、打呼噜等特殊嗜好者,除非其他人都欣赏,否则请慢慢改掉。\n\10、最后一个离开宿舍者,关好窗子锁好门。\n"m2 = Tk.Message(app1, text=t1, font=("SimKai", 15, "bold"))m2.config(bg="gray", width=400)m2.place(x=380, y=70, width=400, height=520)b1 = Tk.Button(app1, text="男生宿舍", font=("SimKai", 15, "bold"), command=f1_1)b1.config(bg="gray", width=200)b1.place(x=40, y=150, width=200, height=90)b2 = Tk.Button(app1, text="女生宿舍", font=("SimKai", 15, "bold"), command=f1_2)b2.config(bg="gray", width=200)b2.place(x=40, y=260, width=200, height=90)b3 = Tk.Button(app1, text="请假学生", font=("SimKai", 15, "bold"), command=f1_4)b3.config(bg="gray", width=200)b3.place(x=40, y=370, width=200, height=90)b4 = Tk.Button(app1, text="主菜单", font=("SimKai", 15, "bold"), command=f1_31)b4.config(bg="gray", width=200)b4.place(x=40, y=480, width=200, height=90)
def f1_12_21l1():f1_12_21l(1)
def f1_12_21l2():f1_12_21l(2)
def f1_12_21l(t):tt=""+e1.get()text=["姓名  性别 住址 班级 入住情况\n"]text1=""h=1if(t==1):for i in Boydormitory:for j in i:if tt in j and len(tt)>0:text.append(j)h=0if h==1:l1.delete(0, Tk.END)text1="该座公寓查无此人!!!!!!!!"l1.insert(Tk.END,text1)l1.place(x=380, y=260, width=400, height=260)s1.place(x=380, y=260, width=400, height=260)else:l1.delete(0,Tk.END)for g in text:l1.insert(Tk.END,g)l1.place(x=380, y=260, width=400, height=260)s1.place(x=380, y=260, width=400, height=260)else:for i in Femaledormitory:for j in i:if tt in j and len(tt)>0:text.append(j)h=0if h==1:l1.delete(0, Tk.END)text1 = "该座公寓查无此人!!!!!!!!"l1.insert(Tk.END,text1)l1.place(x=380, y=260, width=400, height=260)s1.place(x=380, y=260, width=400, height=260)else:l1.delete(0,Tk.END)for g in text:l1.insert(Tk.END,g)l1.place(x=380, y=260, width=400, height=260)s1.place(x=380, y=260, width=400, height=260)
#***********************************************************************************************************************
def f2():app.destroy()global app2app2 = Tk.Tk()app2.update()app2.geometry('800x600')app2.title("学生入住系统")app2.config(bg="gray")m = Tk.Message(app2, text="学生入住系统", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)t1 = " 寝室公约1\n  1、早晨起床轻手轻脚,不要制造声响。\n  2、每天的值日生必须按时将宿舍打扫干净,及时处理垃圾。\n\3、电脑音响开到自己能听见即可,戴上耳机更好。\n  4、个人物品放在各自的橱柜里,不得乱扔,更不要随便占领别人的地盘。\n\5、卧谈会时间不宜过长,适可而止,最晚12点睡觉。\n  6、进出请随手关门。\n  7、未经允许,不要乱拿他人的东西。\n\8、搞好个人卫生,勤洗衣服勤洗澡。\n  9、在宿舍有大声唱歌、抽烟、打呼噜等特殊嗜好者,除非其他人都欣赏,否则请慢慢改掉。\n\10、最后一个离开宿舍者,关好窗子锁好门。\n"m2 = Tk.Message(app2, text=t1, font=("SimKai", 15, "bold"))m2.config(bg="gray", width=400)m2.place(x=380, y=70, width=400, height=520)b1 = Tk.Button(app2, text="男生宿舍", font=("SimKai", 15, "bold"), command=f2_1)b1.config(bg="gray", width=200)b1.place(x=40, y=150, width=200, height=90)b2 = Tk.Button(app2, text="女生宿舍", font=("SimKai", 15, "bold"), command=f2_2)b2.config(bg="gray", width=200)b2.place(x=40, y=260, width=200, height=90)b3 = Tk.Button(app2, text="主菜单", font=("SimKai", 15, "bold"), command=f2_3)b3.config(bg="gray", width=200)b3.place(x=40, y=370, width=200, height=90)
#***********************************************************************************************************************
def f2_(t):if t==1:t1="男生宿舍入住系统"else:t1="女生宿舍入住系统"app2.destroy()global app21,l11,l12,e11,e12,e13,e14,e15,e16,e21,e22,e23,e24,e25,e26,e31,e32,e34,e35,e36,m111,m112,e33app21 = Tk.Tk()app21.update()app21.geometry('800x600')app21.title(t1)app21.config(bg="gray")m = Tk.Message(app21, text=t1, font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)m2 = Tk.Message(app21, text="信息修改", font=("SimKai", 20, "bold"))m2.config(bg="gray", width=200)m2.place(x=540, y=70, width=200, height=40)m3 = Tk.Message(app21, text="学生入住", font=("SimKai", 20, "bold"))m3.config(bg="gray", width=200)m3.place(x=50, y=70, width=200, height=40)b1 = Tk.Button(app21, text="上级菜单", font=("SimKai", 15, "bold"), command=f2_11)b1.config(bg="gray", width=200)b1.place(x=560, y=530, width=200, height=35)b2 = Tk.Button(app21, text="主菜单", font=("SimKai", 15, "bold"), command=f2_12)b2.config(bg="gray", width=200)b2.place(x=40, y=530, width=200, height=35)m11 = Tk.Message(app21, text="姓名", font=("SimKai", 15, "bold"))m11.config(bg="gray",width=100)m11.place(x=20,y=150,width=100,height=30)e11=Tk.Entry(app21,font=("SimKai", 15, "bold"))e11.config(bg="gray",width=100)e11.place(x=130,y=150,width=100,height=30)m21 = Tk.Message(app21, text="原姓名", font=("SimKai", 15, "bold"))m21.config(bg="gray", width=100)m21.place(x=330, y=150, width=100, height=30)e21 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e21.config(bg="gray", width=100)e21.place(x=430, y=150, width=100, height=30)m31 = Tk.Message(app21, text="新姓名", font=("SimKai", 15, "bold"))m31.config(bg="gray", width=100)m31.place(x=570, y=150, width=100, height=30)e31 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e31.config(bg="gray", width=100)e31.place(x=670, y=150, width=100, height=30)m12 = Tk.Message(app21, text="性别", font=("SimKai", 15, "bold"))m12.config(bg="gray", width=100)m12.place(x=20, y=190, width=100, height=30)e12 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e12.config(bg="gray", width=100)e12.place(x=130, y=190, width=100, height=30)m22 = Tk.Message(app21, text="原性别", font=("SimKai", 15, "bold"))m22.config(bg="gray", width=100)m22.place(x=330, y=190, width=100, height=30)e22 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e22.config(bg="gray", width=100)e22.place(x=430, y=190, width=100, height=30)m32 = Tk.Message(app21, text="新性别", font=("SimKai", 15, "bold"))m32.config(bg="gray", width=100)m32.place(x=570, y=190, width=100, height=30)e32 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e32.config(bg="gray", width=100)e32.place(x=670, y=190, width=100, height=30)m13 = Tk.Message(app21, text="宿舍", font=("SimKai", 15, "bold"))m13.config(bg="gray", width=100)m13.place(x=20, y=230, width=100, height=30)e13 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e13.config(bg="gray", width=100)e13.place(x=130, y=230, width=100, height=30)m23 = Tk.Message(app21, text="原宿舍", font=("SimKai", 15, "bold"))m23.config(bg="gray", width=100)m23.place(x=330, y=230, width=100, height=30)e23 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e23.config(bg="gray", width=100)e23.place(x=430, y=230, width=100, height=30)m33 = Tk.Message(app21, text="新宿舍", font=("SimKai", 15, "bold"))m33.config(bg="gray", width=100)m33.place(x=570, y=230, width=100, height=30)e33 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e33.config(bg="gray", width=100)e33.place(x=670, y=230, width=100, height=30)m14 = Tk.Message(app21, text="床号", font=("SimKai", 15, "bold"))m14.config(bg="gray", width=100)m14.place(x=20, y=270, width=100, height=30)e14 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e14.config(bg="gray", width=100)e14.place(x=130, y=270, width=100, height=30)m24 = Tk.Message(app21, text="原床号", font=("SimKai", 15, "bold"))m24.config(bg="gray", width=100)m24.place(x=330, y=270, width=100, height=30)e24 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e24.config(bg="gray", width=100)e24.place(x=430, y=270, width=100, height=30)m34 = Tk.Message(app21, text="新床号", font=("SimKai", 15, "bold"))m34.config(bg="gray", width=100)m34.place(x=570, y=270, width=100, height=30)e34 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e34.config(bg="gray", width=100)e34.place(x=670, y=270, width=100, height=30)m15 = Tk.Message(app21, text="班级", font=("SimKai", 15, "bold"))m15.config(bg="gray", width=100)m15.place(x=20, y=310, width=100, height=30)e15 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e15.config(bg="gray", width=100)e15.place(x=130, y=310, width=100, height=30)m25 = Tk.Message(app21, text="原班级", font=("SimKai", 15, "bold"))m25.config(bg="gray", width=100)m25.place(x=330, y=310, width=100, height=30)e25 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e25.config(bg="gray", width=100)e25.place(x=430, y=310, width=100, height=30)m35 = Tk.Message(app21, text="新班级", font=("SimKai", 15, "bold"))m35.config(bg="gray", width=100)m35.place(x=570, y=310, width=100, height=30)e35 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e35.config(bg="gray", width=100)e35.place(x=670, y=310, width=100, height=30)m16 = Tk.Message(app21, text="入住情况", font=("SimKai", 15, "bold"))m16.config(bg="gray", width=100)m16.place(x=20, y=350, width=100, height=30)e16 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e16.config(bg="gray", width=100)e16.place(x=130, y=350, width=100, height=30)m26 = Tk.Message(app21, text="原入住情况", font=("SimKai", 13, "bold"))m26.config(bg="gray", width=100)m26.place(x=330, y=350, width=100, height=30)e26 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e26.config(bg="gray", width=100)e26.place(x=430, y=350, width=100, height=30)m36 = Tk.Message(app21, text="新入住情况", font=("SimKai", 13, "bold"))m36.config(bg="gray", width=100)m36.place(x=570, y=350, width=100, height=30)e36 = Tk.Entry(app21, font=("SimKai", 15, "bold"))e36.config(bg="gray", width=100)e36.place(x=670, y=350, width=100, height=30)if t==1:b3 = Tk.Button(app21, text="确认入住",command=f61)b4 = Tk.Button(app21, text="确认修改",command=f71)else:b3 = Tk.Button(app21, text="确认入住",command=f62)b4 = Tk.Button(app21, text="确认修改",command=f72)b3.config(bg="gray",font=("SimKai", 15, "bold"),width=100)b3.place(x=20, y=430, width=100, height=30)m111=Tk.Message(app21,text="",font=("SimKai", 13, "bold"))m111.config(bg="white",width=100)m111.place(x=130, y=400, width=100, height=100)b4.config(bg="gray", font=("SimKai", 15, "bold"), width=100)b4.place(x=320, y=430, width=100, height=30)m112 = Tk.Message(app21, text="",font=("SimKai", 13, "bold"))m112.config(bg="white", width=100)m112.place(x=430, y=400, width=350, height=100)
#***********************************************************************************************************************
def f61():f6(1)
def f62():f6(2)
def f6(t):text1=""+e11.get()+"  "+e12.get()+"   "+e13.get()+"-"+e14.get()+"  "+e15.get()+"  "+e16.get()+"\n"text2 = "" + e11.get()text3=""+e15.get()t1=""+e13.get()+"-"+e14.get()if e13.get()!="" and e14.get()!="":index = int(e13.get()) - 1if t == 1:if int(e13.get()) <= 6 and int(e14.get()) <= 6 and float(e13.get()) == int(e13.get()) and float(e14.get()) == int(e14.get()) and int(e13.get()) >= 1 and int(e14.get()) >=1:h1 = 0h2 = 0for i in Boydormitory[index]:if t1 in i:h1 = 1breakfor i in Boydormitory:for j in i:if text2 in j and text3 in j:h2 = 1breakif e11.get() == "" or e12.get() == "" or e13.get() == "" or e14.get() == "" or e15.get() == "" or e16.get() == "":m111.config(text="请输入完整信息!!!")elif e12.get() !="男" and e12.get()!="女":m111.config(text="性别有误!!!")elif e16.get() !="请假" and e16.get()!="在校":m111.config(text="入住情况有误!!!")elif e12.get() == "女":m111.config(text= "男生宿舍!!!")elif len(Boydormitory[index]) >= 7:m111.config(text= "该宿舍已满!!!")elif h1 == 1:m111.config(text= "该床位号已有人!!!")elif h2 == 1:m111.config(text= "该学生已经入住宿舍!!!")else:t2 = "" + e11.get() + "同学成功入住宿舍!!!"m111.config(text=t2)Boydormitory[index].append(text1)else:m111.config(text= "请输入正确的住址!!!")else:if int(e13.get()) <= 6 and int(e14.get()) <= 6 and float(e13.get()) == int(e13.get()) and float(e14.get()) == int(e14.get()) and int(e13.get()) >= 1 and int(e14.get()) >=1:h1 = 0h2 = 0for i in Femaledormitory[index]:if t1 in i:h1 = 1breakfor i in Femaledormitory:for j in i:if text2 in j and text3 in j:h2 = 1breakif e11.get() == "" or e12.get() == "" or e13.get() == "" or e14.get() == "" or e15.get() == "" or e16.get() == "":m111.config(text= "请输入完整信息!!!")elif e12.get() !="男" and e12.get()!="女":m111.config(text="性别有误!!!")elif e16.get() !="请假" and e16.get()!="在校":m111.config(text="入住情况有误!!!")elif e12.get() == "男":m111.config(text= "女生宿舍!!!")elif len(Femaledormitory[index]) >= 7:m111.config(text= "该宿舍已满!!!")elif h1 == 1:m111.config(text="该床位号已有人!!!")elif h2 == 1:m111.config(text="该学生已经入住宿舍!!!")else:t2 = "" + e11.get() + "同学成功入住宿舍!!!"m111.config(text=t2)Femaledormitory[index].append(text1)else:m111.config(text="请输入正确的住址!!!")else:m111.config(text="请输入正确的住址!!!")#***********************************************************************************************************************
def f71():f7(1)
def f72():f7(2)
def f7(t):text1 = "" + e21.get() + "  " + e22.get() + "   " + e23.get() + "-" + e24.get() + "  " + e25.get() + "  " + e26.get() + "\n"text2 = "" + e21.get() + "  " + e22.get() + "   " + e23.get() + "-" + e24.get() + "  " + e25.get()text12 = "" + e21.get()text3 = "" + e25.get()t1 = "" + e23.get() + "-" + e24.get()text11 = "" + e31.get() + "  " + e32.get() + "   " + e33.get() + "-" + e34.get() + "  " + e35.get() + "  " + e36.get() + "\n"text21 = "" + e31.get() + "  " + e32.get() + "   " + e33.get() + "-" + e34.get() + "  " + e35.get()text121 = "" + e31.get()text31 = "" + e35.get()t11 = "" + e33.get() + "-" + e34.get()if e23.get()!="" and e24.get()!="":index1 = int(e23.get()) - 1if t == 1:if int(e23.get()) <= 6 and int(e24.get()) <= 6 and float(e23.get()) == int(e23.get()) and float(e24.get()) == int(e24.get()) and int(e23.get()) >= 1 and int(e24.get()) >=1:h2 = 0for i in Boydormitory:for j in i:if text2 in j:h2 = 1breakif e21.get() == "" or e22.get() == "" or e23.get() == "" or e24.get() == "" or e25.get() == "" or e26.get() == "":m112.config(text="请输入完整信息!!!")elif e22.get() != "男" and e22.get() != "女":m112.config(text="性别有误!!!")elif e26.get() != "请假" and e26.get() != "在校":m112.config(text="入住情况有误!!!")elif h2 != 1:m112.config(text= "该学生未入住宿舍或信息错误!!!")else:if e33.get() != "" and e34.get() != "":index2 = int(e33.get()) - 1if t == 1:if int(e33.get()) <= 6 and int(e24.get()) <= 6 and float(e23.get()) == int(e23.get()) and float(e24.get()) == int(e24.get()) and int(e23.get()) >= 1 and int(e24.get()) >= 1:h1 = 0for i in Boydormitory[index2]:if t11 in i:h1 = 1breakif e31.get() == "" or e32.get() == "" or e33.get() == "" or e34.get() == "" or e35.get() == "" or e36.get() == "":m112.config(text="请输入完整信息!!!")elif e32.get() != "男" and e32.get() != "女":m112.config(text="性别有误!!!")elif e36.get() != "请假" and e36.get() != "在校":m112.config(text="入住情况有误!!!")elif e32.get() == "女":m112.config(text="男生宿舍!!!")elif len(Boydormitory[index2]) >= 7:m112.config(text="该宿舍已满!!!")elif h1 == 1:m112.config(text="该床位号已有人!!!")else:if t1 != t11:for i in Boydormitory[index1]:if text2 in i:Boydormitory[index1].remove(i)Boydormitory[index2].append(text11)else:for i in Boydormitory:for j in i:if text1 in j :j=text11breakt2 = "" + e21.get() + "同学信息成功修改!!!"m112.config(text=t2)else:m112.config(text="请输入正确的住址!!!")else:m112.config(text= "请输入正确的住址!!!")else:if int(e23.get()) <= 6 and int(e24.get()) <= 6 and float(e23.get()) == int(e23.get()) and float(e24.get()) == int(e24.get()) and int(e23.get()) >= 1 and int(e24.get()) >= 1:h2 = 0for i in Femaledormitory:for j in i:if text2 in j:h2 = 1breakif e21.get() == "" or e22.get() == "" or e23.get() == "" or e24.get() == "" or e25.get() == "" or e26.get() == "":m112.config(text="请输入完整信息!!!")elif e22.get() != "男" and e22.get() != "女":m112.config(text="性别有误!!!")elif e26.get() != "请假" and e26.get() != "在校":m112.config(text="入住情况有误!!!")elif h2 != 1:m112.config(text="该学生未入住宿舍或信息错误!!!")else:if e33.get() != "" and e34.get() != "":index2 = int(e33.get()) - 1if int(e33.get()) <= 6 and int(e24.get()) <= 6 and float(e23.get()) == int(e23.get()) and float(e24.get()) == int(e24.get()) and int(e23.get()) >= 1 and int(e24.get()) >= 1:h1 = 0for i in Femaledormitory[index2]:if t11 in i:h1 = 0breakif e31.get() == "" or e32.get() == "" or e33.get() == "" or e34.get() == "" or e35.get() == "" or e36.get() == "":m112.config(text="请输入完整信息!!!")elif e32.get() != "男" and e32.get() != "女":m112.config(text="性别有误!!!")elif e36.get() != "请假" and e36.get() != "在校":m112.config(text="入住情况有误!!!")elif e22.get() == "男":m112.config(text="女生宿舍!!!")elif len(Femaledormitory[index2]) >= 7:m112.config(text="该宿舍已满!!!")elif h1 == 1:m112.config(text="该床位号已有人!!!")else:if t1 != t11:for i in Femaledormitory[index1]:if text2 in i:Femaledormitory[index1].remove(i)Femaledormitory[index2].append(text11)else:for i in Femaledormitory:for j in i:if text1 in j:j = text11breakt2 = "" + e21.get() + "同学信息成功修改!!!"m112.config(text=t2)else:m112.config(text="请输入正确的住址!!!")else:m112.config(text="请输入正确的住址!!!")else:m112.config(text="请输入正确的住址!!!")
#***********************************************************************************************************************
def f2_1():f2_(1)
def f2_2():f2_(2)
def f2_3():f1_3(app2)
def f2_12():f1_3(app21)
#***********************************************************************************************************************
def f2_2_(t):t.destroy()global app2app2 = Tk.Tk()app2.update()app2.geometry('800x600')app2.title("学生入住系统")app2.config(bg="gray")m = Tk.Message(app2, text="学生入住系统", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)t1 = " 寝室公约1\n  1、早晨起床轻手轻脚,不要制造声响。\n  2、每天的值日生必须按时将宿舍打扫干净,及时处理垃圾。\n\3、电脑音响开到自己能听见即可,戴上耳机更好。\n  4、个人物品放在各自的橱柜里,不得乱扔,更不要随便占领别人的地盘。\n\5、卧谈会时间不宜过长,适可而止,最晚12点睡觉。\n  6、进出请随手关门。\n  7、未经允许,不要乱拿他人的东西。\n\8、搞好个人卫生,勤洗衣服勤洗澡。\n  9、在宿舍有大声唱歌、抽烟、打呼噜等特殊嗜好者,除非其他人都欣赏,否则请慢慢改掉。\n\10、最后一个离开宿舍者,关好窗子锁好门。\n"m2 = Tk.Message(app2, text=t1, font=("SimKai", 15, "bold"))m2.config(bg="gray", width=400)m2.place(x=380, y=70, width=400, height=520)b1 = Tk.Button(app2, text="男生宿舍", font=("SimKai", 15, "bold"), command=f2_1)b1.config(bg="gray", width=200)b1.place(x=40, y=150, width=200, height=90)b2 = Tk.Button(app2, text="女生宿舍", font=("SimKai", 15, "bold"), command=f2_2)b2.config(bg="gray", width=200)b2.place(x=40, y=260, width=200, height=90)b3 = Tk.Button(app2, text="主菜单", font=("SimKai", 15, "bold"), command=f2_3)b3.config(bg="gray", width=200)b3.place(x=40, y=370, width=200, height=90)
def f2_11():f2_2_(app21)
def f2_21():f2_2_(app21)
#***********************************************************************************************************************
def f3():app.destroy()global app3, l11, e11, e12, e13, e14, e15, e16, m111app3 = Tk.Tk()app3.update()app3.geometry('800x600')app3.title("学生退宿系统")app3.config(bg="gray")m = Tk.Message(app3, text="学生退宿系统", font=("SimKai", 30, "bold"))m.config(bg="gray", width=400)m.place(x=0, y=20, width=800, height=60)m11 = Tk.Message(app3, text="姓名", font=("SimKai", 15, "bold"))m11.config(bg="gray", width=100)m11.place(x=20, y=150, width=100, height=30)e11 = Tk.Entry(app3, font=("SimKai", 15, "bold"))e11.config(bg="gray", width=100)e11.place(x=130, y=150, width=100, height=30)m12 = Tk.Message(app3, text="性别", font=("SimKai", 15, "bold"))m12.config(bg="gray", width=100)m12.place(x=20, y=190, width=100, height=30)e12 = Tk.Entry(app3, font=("SimKai", 15, "bold"))e12.config(bg="gray", width=100)e12.place(x=130, y=190, width=100, height=30)m13 = Tk.Message(app3, text="宿舍", font=("SimKai", 15, "bold"))m13.config(bg="gray", width=100)m13.place(x=20, y=230, width=100, height=30)e13 = Tk.Entry(app3, font=("SimKai", 15, "bold"))e13.config(bg="gray", width=100)e13.place(x=130, y=230, width=100, height=30)m14 = Tk.Message(app3, text="床号", font=("SimKai", 15, "bold"))m14.config(bg="gray", width=100)m14.place(x=20, y=270, width=100, height=30)e14 = Tk.Entry(app3, font=("SimKai", 15, "bold"))e14.config(bg="gray", width=100)e14.place(x=130, y=270, width=100, height=30)m15 = Tk.Message(app3, text="班级", font=("SimKai", 15, "bold"))m15.config(bg="gray", width=100)m15.place(x=20, y=310, width=100, height=30)e15 = Tk.Entry(app3, font=("SimKai", 15, "bold"))e15.config(bg="gray", width=100)e15.place(x=130, y=310, width=100, height=30)m16 = Tk.Message(app3, text="入住情况", font=("SimKai", 15, "bold"))m16.config(bg="gray", width=100)m16.place(x=20, y=350, width=100, height=30)e16 = Tk.Entry(app3, font=("SimKai", 15, "bold"))e16.config(bg="gray", width=100)e16.place(x=130, y=350, width=100, height=30)t1 = " 寝室公约1\n  1、早晨起床轻手轻脚,不要制造声响。\n  2、每天的值日生必须按时将宿舍打扫干净,及时处理垃圾。\n\3、电脑音响开到自己能听见即可,戴上耳机更好。\n  4、个人物品放在各自的橱柜里,不得乱扔,更不要随便占领别人的地盘。\n\5、卧谈会时间不宜过长,适可而止,最晚12点睡觉。\n  6、进出请随手关门。\n  7、未经允许,不要乱拿他人的东西。\n\8、搞好个人卫生,勤洗衣服勤洗澡。\n  9、在宿舍有大声唱歌、抽烟、打呼噜等特殊嗜好者,除非其他人都欣赏,否则请慢慢改掉。\n\10、最后一个离开宿舍者,关好窗子锁好门。\n"m2 = Tk.Message(app3, text=t1, font=("SimKai", 15, "bold"))m2.config(bg="gray", width=400)m2.place(x=380, y=70, width=400, height=520)b1 = Tk.Button(app3, text="确认删除", command=f81)b1.config(bg="gray", font=("SimKai", 15, "bold"), width=100)b1.place(x=20, y=430, width=100, height=30)m111 = Tk.Message(app3, text="", font=("SimKai", 13, "bold"))m111.config(bg="white", width=100)m111.place(x=130, y=400, width=100, height=80)b2 = Tk.Button(app3, text="主菜单", font=("SimKai", 15, "bold"), command=f8)b2.config(bg="gray", width=210)b2.place(x=20, y=500, width=210, height=50)
def f8():f1_3(app3)
def f81():text2 = "" + e11.get() + "  " + e12.get() + "   " + e13.get() + "-" + e14.get() + "  " + e15.get()index = int(e13.get()) - 1text2=""+e12.get()if text2=="男":if e11.get() == "" or e12.get() == "" or e13.get() == "" or e14.get() == "" or e15.get() == "" or e16.get() == "":m111.config(text="请输入完整信息!!!")elif e12.get() != "男" and e12.get() != "女":m111.config(text="性别有误!!!")elif e16.get() != "请假" and e16.get() != "在校":m11.config(text="入住情况有误!!!")else:h1 = 0for i in Boydormitory[index]:if text2 in i:h1 = 1Boydormitory[index].remove(i)breakif h1 == 1:m111.config(text="删除成功!!!")else:m111.config(text="无该信息!!!")else:if e11.get() == "" or e12.get() == "" or e13.get() == "" or e14.get() == "" or e15.get() == "" or e16.get() == "":m111.config(text="请输入完整信息!!!")elif e12.get() != "男" and e12.get() != "女":m111.config(text="性别有误!!!")elif e16.get() != "请假" and e16.get() != "在校":m111.config(text="入住情况有误!!!")else:h1 = 0for i in Femaledormitory[index]:if text2 in i:h1 = 1Femaledormitory[index].remove(i)breakif h1 == 1:m111.config(text="删除成功!!!")else:m111.config(text="无该信息!!!")
#***********************************************************************************************************************global one,two,three,four,five,six,gone,gtwo,gthree,gfour,gfive,gsix,Boudormitory,Femaledormitory
one=["姓名 性别 住址 班级 入住情况\n","赵一  男   1-1  221  在校\n","孔一  男   1-2  221  在校\n"]
two=["姓名 性别 住址 班级 入住情况\n","张三  男   2-1  231  在校\n"]
three=["姓名 性别 住址 班级 入住情况\n","李四  男   3-1  231  在校\n"]
four=["姓名 性别 住址 班级 入住情况\n","程五  男   4-1  211  请假\n"]
five=["姓名 性别 住址 班级 入住情况\n","王六  男   5-1  221  在校\n"]
six=["姓名 性别 住址 班级 入住情况\n","成七  男   6-1  221  在校\n"]
Boydormitory=[one,two,three,four,five,six]
gone=["姓名 性别 住址 班级 入住情况\n","陈一  女   1-1  221  在校\n"]
gtwo=["姓名 性别 住址 班级 入住情况\n","钱三  女   2-1  231  请假\n"]
gthree=["姓名 性别 住址 班级 入住情况\n","艾四  女   3-1  231  在校\n"]
gfour=["姓名 性别 住址 班级 入住情况\n","罗五  女   4-1  211  请假\n"]
gfive=["姓名 性别 住址 班级 入住情况\n","南六  女   5-1  221  在校\n"]
gsix=["姓名 性别 住址 班级 入住情况\n","秦七  女   6-1  221  在校\n"]
Femaledormitory=[gone,gtwo,gthree,gfour,gfive,gsix]#***********************************************************************************************************************
def f():app.destroy()
app = Tk.Tk()
app.geometry('800x600')
app.title("宿舍管理系统")
app.config(bg="gray")
m = Tk.Message(app, text="学生公寓",font=("SimKai",30,"bold"))
m.config(bg="gray",width=200)
m.place(x=0,y=20,width=800,height=60)
t1=" 寝室公约1\n  1、早晨起床轻手轻脚,不要制造声响。\n  2、每天的值日生必须按时将宿舍打扫干净,及时处理垃圾。\n\3、电脑音响开到自己能听见即可,戴上耳机更好。\n  4、个人物品放在各自的橱柜里,不得乱扔,更不要随便占领别人的地盘。\n\5、卧谈会时间不宜过长,适可而止,最晚12点睡觉。\n  6、进出请随手关门。\n  7、未经允许,不要乱拿他人的东西。\n\8、搞好个人卫生,勤洗衣服勤洗澡。\n  9、在宿舍有大声唱歌、抽烟、打呼噜等特殊嗜好者,除非其他人都欣赏,否则请慢慢改掉。\n\10、最后一个离开宿舍者,关好窗子锁好门。\n"
m2=Tk.Message(app,text=t1,font=("SimKai",15,"bold"))
m2.config(bg="gray",width=400)
m2.place(x=380,y=70,width=400,height=520)
b1=Tk.Button(app,text="学生查询",font=("SimKai",15,"bold"),command=f1)
b1.config(bg="gray",width=200)
b1.place(x=40,y=150,width=200,height=90)
b2=Tk.Button(app,text="学生入住",font=("SimKai",15,"bold"),command=f2)
b2.config(bg="gray",width=200)
b2.place(x=40,y=260,width=200,height=90)
b3=Tk.Button(app,text="学生退宿",font=("SimKai",15,"bold"),command=f3)
b3.config(bg="gray",width=200)
b3.place(x=40,y=370,width=200,height=90)
b4=Tk.Button(app,text="退出系统",font=("SimKai",15,"bold"),command=f)
b4.config(bg="gray",width=200)
b4.place(x=40,y=480,width=200,height=90)
app.mainloop()

结果如下:fa90cd6cc70d4052a0a5c6539eb420ad.pngda4682c2074b4b6e934d1729370b75b9.png31ae8655b5f34940bd44c8cf2db2ab19.png63fad0ae5f2049fbbd6275525486f3ec.png014b1acdaa394b12864ebaa60ad71e89.png6f9542a51bdd465292c141eb65297d2c.png6032aacad51e425ea68ade6c1329dee8.png3293a2490a084e11b7594ffc8f5837e5.png6941e6ff0f46415d913065970bd8d2b2.png7a34ad8d66a8466aafce43095738f80e.png204f1cc17a404d52bf270e35787983b4.png

这篇关于python tk窗口学生宿舍管理系统的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/627322

相关文章

使用Python绘制蛇年春节祝福艺术图

《使用Python绘制蛇年春节祝福艺术图》:本文主要介绍如何使用Python的Matplotlib库绘制一幅富有创意的“蛇年有福”艺术图,这幅图结合了数字,蛇形,花朵等装饰,需要的可以参考下... 目录1. 绘图的基本概念2. 准备工作3. 实现代码解析3.1 设置绘图画布3.2 绘制数字“2025”3.3

python使用watchdog实现文件资源监控

《python使用watchdog实现文件资源监控》watchdog支持跨平台文件资源监控,可以检测指定文件夹下文件及文件夹变动,下面我们来看看Python如何使用watchdog实现文件资源监控吧... python文件监控库watchdogs简介随着Python在各种应用领域中的广泛使用,其生态环境也

Python中构建终端应用界面利器Blessed模块的使用

《Python中构建终端应用界面利器Blessed模块的使用》Blessed库作为一个轻量级且功能强大的解决方案,开始在开发者中赢得口碑,今天,我们就一起来探索一下它是如何让终端UI开发变得轻松而高... 目录一、安装与配置:简单、快速、无障碍二、基本功能:从彩色文本到动态交互1. 显示基本内容2. 创建链

Java调用Python代码的几种方法小结

《Java调用Python代码的几种方法小结》Python语言有丰富的系统管理、数据处理、统计类软件包,因此从java应用中调用Python代码的需求很常见、实用,本文介绍几种方法从java调用Pyt... 目录引言Java core使用ProcessBuilder使用Java脚本引擎总结引言python

python 字典d[k]中key不存在的解决方案

《python字典d[k]中key不存在的解决方案》本文主要介绍了在Python中处理字典键不存在时获取默认值的两种方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录defaultdict:处理找不到的键的一个选择特殊方法__missing__有时候为了方便起见,

使用Python绘制可爱的招财猫

《使用Python绘制可爱的招财猫》招财猫,也被称为“幸运猫”,是一种象征财富和好运的吉祥物,经常出现在亚洲文化的商店、餐厅和家庭中,今天,我将带你用Python和matplotlib库从零开始绘制一... 目录1. 为什么选择用 python 绘制?2. 绘图的基本概念3. 实现代码解析3.1 设置绘图画

Python pyinstaller实现图形化打包工具

《Pythonpyinstaller实现图形化打包工具》:本文主要介绍一个使用PythonPYQT5制作的关于pyinstaller打包工具,代替传统的cmd黑窗口模式打包页面,实现更快捷方便的... 目录1.简介2.运行效果3.相关源码1.简介一个使用python PYQT5制作的关于pyinstall

使用Python实现大文件切片上传及断点续传的方法

《使用Python实现大文件切片上传及断点续传的方法》本文介绍了使用Python实现大文件切片上传及断点续传的方法,包括功能模块划分(获取上传文件接口状态、临时文件夹状态信息、切片上传、切片合并)、整... 目录概要整体架构流程技术细节获取上传文件状态接口获取临时文件夹状态信息接口切片上传功能文件合并功能小

python实现自动登录12306自动抢票功能

《python实现自动登录12306自动抢票功能》随着互联网技术的发展,越来越多的人选择通过网络平台购票,特别是在中国,12306作为官方火车票预订平台,承担了巨大的访问量,对于热门线路或者节假日出行... 目录一、遇到的问题?二、改进三、进阶–展望总结一、遇到的问题?1.url-正确的表头:就是首先ur

基于Python实现PDF动画翻页效果的阅读器

《基于Python实现PDF动画翻页效果的阅读器》在这篇博客中,我们将深入分析一个基于wxPython实现的PDF阅读器程序,该程序支持加载PDF文件并显示页面内容,同时支持页面切换动画效果,文中有详... 目录全部代码代码结构初始化 UI 界面加载 PDF 文件显示 PDF 页面页面切换动画运行效果总结主