python学生成绩管理系统GUI
时间: 2023-12-31 10:24:53 浏览: 105
以下是一个简单的Python学生成绩管理系统GUI的示例:
```python
import tkinter as tk
class Student:
def __init__(self, name, score):
self.name = name
self.score = score
class GradeManagementSystem(tk.Tk):
def __init__(self):
super().__init__()
self.title("学生成绩管理系统")
self.geometry("400x300")
self.students = []
self.add_frame = tk.Frame(self)
self.add_frame.pack(pady=10)
tk.Label(self.add_frame, text="姓名:").grid(row=0, column=0)
self.name_entry = tk.Entry(self.add_frame)
self.name_entry.grid(row=0, column=1)
tk.Label(self.add_frame, text="成绩:").grid(row=1, column=0)
self.score_entry = tk.Entry(self.add_frame)
self.score_entry.grid(row=1, column=1)
tk.Button(self.add_frame, text="添加", command=self.add_student).grid(row=2, column=0, columnspan=2)
self.display_frame = tk.Frame(self)
self.display_frame.pack(pady=10)
self.display_text = tk.Text(self.display_frame, height=10, width=30)
self.display_text.pack()
def add_student(self):
name = self.name_entry.get()
score = self.score_entry.get()
student = Student(name, score)
self.students.append(student)
self.display_students()
def display_students(self):
self.display_text.delete(1.0, tk.END)
for student in self.students:
self.display_text.insert(tk.END, f"姓名:{student.name} 成绩:{student.score}\n")
if __name__ == "__main__":
app = GradeManagementSystem()
app.mainloop()
```
阅读全文