程序设计之学生成绩信息管理系统(附源码

学生成绩信息管理系统GUI(附源码

**

任务需求

需求
班级类,学生类,课程类,选课
主要功能:
(1)能按学期、按班级完成对学生成绩的录入、修改
(2)能按班级统计学生的成绩,求学生的总分及平均分,并能根据学生的平均成绩进行排序
(3)能查询学生成绩,不及格科目及学生名单
(4)能按班级输出学生的成绩单
登录框账号密码都是:student1
在这里插入图片描述
1首先登陆然后录入学生相关信息
在这里插入图片描述
2创建窗口录入成绩(录入完所有学生成绩后再点已经录入完成,然后关掉录入成绩窗口)
这里利用的字典一个个导入的成绩
在这里插入图片描述
3修改信息,修改好后可以直接确定就行就直接保存在了同一个文件夹下的txt文件里面了
在这里插入图片描述
4这里可以通过输入姓名查询,就是字典的应用
5打印的成绩单全是在同一个文件夹里面的txt文件有标注
源码给大家奉上,有漏洞bug希望大家反馈






import tkinter as tk
import tkinter
import tkinter.font as font
from tkinter import messagebox
import codecs
from tkinter import *
import random
def creatAuthCode():
   res1=""
   res2=""
   res3=""
   for i in range(2):
       num=random.randint(0,9)
       res1+=str(num)
       num=random.randint(65,91)
       res2+=str(chr(num))
       num=random.randint(97,123)
       res3+=str(chr(num))
   string=str(res1+res2+res3)
   txt.set(string)
window5 = tk.Tk()
window5.title('学生成绩管理登录界面')       # 设置窗口的标题
window5.geometry('250x150+600+250')     # 设置窗口的大小

tk.Label(window5, text="用户名:").place(x=30, y=40, anchor='nw')
tk.Label(window5, text="密码  :").place(x=30, y=60, anchor='nw')

usr_name_var = tk.StringVar()
password_var = tk.StringVar()
tk.Entry(window5, textvariable=usr_name_var)\
   .place(x=70, y=40, anchor='nw')
tk.Entry(window5, textvariable=password_var, show='*')\
   .place(x=70, y=60, anchor='nw')
e1=usr_name_var
e2=password_var
def login():
   if e1.get() == "student1"and e2.get()=="student1":

       dict = {}

       def G():

           window1 = tkinter.Tk()
           window1.geometry("300x80+600+240")
           window1.title("学生信息录入")
           lb2 = tkinter.Label(window1, text="姓名")
           lb2.grid(row=2, column=0)
           e4 = Entry(window1)
           e4.grid(row=2, column=1, padx=10, pady=5)
           lb1 = tkinter.Label(window1, text="成绩")
           lb1.grid(row=4, column=0)
           e5 = Entry(window1)
           e5.grid(row=4, column=1, padx=10, pady=5)
           bt = tkinter.Button(window1, text='确定', width=10, command=window1.quit) \
               .grid(row=2, column=5, sticky=E, padx=10, pady=5)
           mainloop()
           nm = str(e4.get())
           sc = float(e5.get())
           with codecs.open('学生信息', mode='a', encoding='utf-8') as file_txt:
               for i in range(1):
                   file_txt.write('\n' + '姓名' + str(nm) + '\t' + "成绩" + str(sc) + '\t')
           dict[nm] = sc
           button = tkinter.Button(window1, text="已录入所有学生", command=M, width=15, height=1)
           button.grid(column=1, row=5)
           button5 = tkinter.Button(window1, text="下一页", command=G, width=10, height=1)
           button5.grid(column=2, row=4)

       def M():
           dict1 = sorted(dict.items(), key=lambda dict: dict[1], reverse=True)
           with codecs.open('学生成绩由大小', mode='a', encoding='utf-8') as file_txt:
               for i in dict1:
                   file_txt.write('\n' + str(i) + '\t')

       def find():
           window2 = tkinter.Tk()
           window2.geometry("250x80+600+350")
           window2.title("学生成绩查询")
           e6 = Entry(window2)
           e6.grid(row=2, column=1, padx=8, pady=5)
           lb3 = tkinter.Label(window2, text="输入姓名")
           lb3.grid(row=2, column=0)
           bt1 = tkinter.Button(window2, text='确定', width=10, command=window2.quit) \
               .grid(row=2, column=4, sticky=E, padx=8, pady=5)
           mainloop()
           xm = str(e6.get())
           messagebox.showinfo(title=xm, message=(xm, dict[xm]))

       def rule():
           screenwidth = window.winfo_screenwidth()
           screenheight = window.winfo_screenheight()
           width = 250
           height = 250
           w = (screenwidth - width) / 2
           h = (screenheight - height) / 2
           return "%dx%d+%d+%d" % (height, width, w, h)

       def change():
           change = Toplevel()
           change.title("修改信息")
           change.geometry(rule())
           text = tkinter.Text(change, font=("微软雅黑", 14), width=40, height=12)
           text.pack()
           f = open("学生信息", "r", encoding="utf-8")
           s = f.read()
           text.insert(END, s)
           f.close()

           def exchange():
               f = open("学生信息", "w+", encoding="utf-8")
               Text = text.get('0.0', END)
               f.write(Text)
               f.close()
               change.destroy()

           tkinter.Button(change, text="确定", font=("微软雅黑", 14), command=exchange, width=5, height=1).place(x=180,
                                                                                                           y=200)

       def H():
           root = Tk()
           root.title("学生人数")
           root.geometry("249x150+600+350")
           Label(root, text="学生班级").grid(row=2, column=1)
           Label(root, text="班级人数").grid(row=4, column=1)
           Label(root, text="考试科目").grid(row=6, column=1)
           e4 = Entry(root)
           e3 = Entry(root)
           e5 = Entry(root)
           e3.grid(row=2, column=2, padx=10, pady=5)
           e4.grid(row=4, column=2, padx=10, pady=5)
           e5.grid(row=6, column=2, padx=10, pady=5)
           bt = tkinter.Button(root, text='确定', width=10, command=root.quit) \
               .grid(row=8, column=2, sticky=E, padx=10, pady=2)
           mainloop()
           cl = str(e4.get())
           n = str(e3.get())
           sb = str(e5.get())
           l = "学生班级"
           m = "班级人数"
           k = "科目"
           with codecs.open('学生信息', mode='a', encoding='utf-8') as file_txt:
               for i in range(1):
                   file_txt.write('\n' + (l) + '\t' + str(cl) + '\t')
                   file_txt.write('\n' + (m) + '\t' + str(n) + '\t')
                   file_txt.write('\n' + (k) + '\t' + str(sb) + '\t')

       def FA():
           for key in dict:
               if dict[key] < 60:
                   with codecs.open('不及格学生', mode='a', encoding='utf-8') as file_txt:
                       file_txt.write('\n' + str(key) + '\t' + str(dict[key]) + '\t')

       window = tkinter.Tk()
       window.geometry("249x280+600+350")
       window.title("学生管理系统精简版")
       window["background"] = "white"
       button = tkinter.Button(window, text="录入学生信息", fg="white", bg="Green", command=H, width=40, height=3)
       button.grid(column=20, row=2)
       button1 = tkinter.Button(window, text="录入学生成绩", fg="white", bg="Green", command=G, width=40, height=3)
       button1.grid(column=20, row=4)
       button2 = tkinter.Button(window, text="修改信息", fg="white", bg="Green", command=change, width=40, height=3)
       button2.grid(column=20, row=6)
       button3 = tkinter.Button(window, text="查询学生成绩", fg="white", bg="Green", command=find, width=40, height=3)
       button3.grid(column=20, row=8)
       button4 = tkinter.Button(window, text="打印不及格学生成绩表", fg="white", bg="Green", command=FA, width=40, height=3)
       button4.grid(column=20, row=10)
       button5 = tkinter.Button(window, text="打印学生排名成绩表", fg="white", bg="Green", command=M, width=40, height=3)
       button5.grid(column=20, row=12)
       tkinter.mainloop()
   else:
       messagebox.showinfo(title='用户名或密码错误',message="去一遍玩去")
       return False
v = StringVar()
code=Label(window5,text="验证码:")
code.place(relx=0.22,rely=0.6,anchor=CENTER)
code=Entry(window5)
code.place(relx=0.38,rely=0.6,anchor=CENTER,width=50,height=20)
txt=StringVar()
txt.set("获取验证码")
codestr=Button(window5,textvariable=txt,command=creatAuthCode,fg="red",bg="black")
codestr.place(relx=0.8,rely=0.6,anchor=CENTER)
enter=Button(window5,text="登录",command=login,width=10,height=2)
enter.place(relx=0.5,rely=0.8,anchor=CENTER)
window5.mainloop()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值