forked from hlilyjiaxin/mysql_python_DB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcourse_class.py
More file actions
69 lines (62 loc) · 2.77 KB
/
course_class.py
File metadata and controls
69 lines (62 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from tkinter import *
import tets
class course:
def __init__(self,SNO):
self.root = Tk()
self.root.wm_title(SNO)
self.root.geometry("900x400")
self.SNO=SNO
self.student_label = Label(self.root, text="学生详细信息:")
self.course_label = Label(self.root, text="可选课程")
self.score_label = Label(self.root, text="已修课程成绩")
self.choose_course_label = Label(self.root, text="已选课程")
self.course_entry_label = Label(self.root, text="请输入课程号:")
self.student_text = Text(self.root, height=10, width=50)
self.course_text = Text(self.root, height=10, width=50)
self.score_text = Text(self.root, height=10, width=50)
self.choose_course_text = Text(self.root, height=10, width=50)
self.course_entry = Entry(self.root, width=5)
self.course_button = Button(self.root, text="选课", command=self.choose_course)
self.course_button2 = Button(self.root, text="退课", command=self.delete_course)
self.course_button3 = Button(self.root, text="关闭")
def inilize(self):
self.student_label.grid(row=0, column=0, sticky=W)
self.student_text.grid(row=1, column=0, sticky=E)
self.course_label.grid(row=0, column=1, sticky=W)
self.course_text.grid(row=1, column=1, sticky=E)
self.score_label.grid(row=3, column=0, sticky=W)
self.score_text.grid(row=4, column=0, sticky=E)
self.choose_course_label.grid(row=3, column=1, sticky=W)
self.choose_course_text.grid(row=4, column=1, sticky=E)
self.course_entry_label.grid(row=0, column=3)
self.course_entry.grid(row=1, column=3)
self.course_button.grid(row=1, column=4)
self.course_button2.grid(row=2, column=4)
self.course_button3.grid(row=4, column=4)
# 选课
def choose_course(self):
course_number = self.course_entry.get()
tets.insert_choose_course(self.SNO, str(course_number), 0)
self.update_ui()
# 退课
def delete_course(self):
course_number = self.course_entry.get()
tets.delete_choose_course(str(course_number))
self.update_ui()
# 更新ui
def update_ui(self):
self.student_text.delete(1.0, END)
self.course_text.delete(1.0, END)
self.score_text.delete(1.0, END)
self.choose_course_text.delete(1.0, END)
tets.display_student(self.student_text, self.SNO)
tets.display_course(self.course_text, self.SNO)
tets.display_score(self.score_text, self.SNO)
tets.display_choose_course(self.choose_course_text, self.SNO)
def start(self):
self.inilize()
self.update_ui()
self.root.mainloop()
if __name__=='__main__':
c=course('S5')
c.start()