diff --git a/students.json b/students.json index f8f4609..2d5c169 100644 --- a/students.json +++ b/students.json @@ -1,3 +1,3 @@ -[{"name": "张三","math": "66", "chinese": "78", "english": "99"}, - {"name": "李四","math": "44", "chinese": "33", "english": "69"}, - {"name": "王五","math": "55", "chinese": "55", "english": "39"}] +[{"name": "张三","banji": "一年级一班", "xuehao": "1108", "youbian": "410000"}, + {"name": "李四","banji": "三年级三班", "xuehao": "3315", "youbian": "411000"}, + {"name": "王六","banji": "五年级二班", "xuehao": "5245", "youbian": "412000"}] diff --git a/views.py b/views.py index 0d3a9a7..c0ed541 100644 --- a/views.py +++ b/views.py @@ -5,18 +5,18 @@ from db import db class AboutFrame(tk.Frame): def __init__(self,root): super().__init__(root) - tk.Label(self, text='关于作品:本作品由tkinter制作').pack() + tk.Label(self, text='关于软件:基于tkinter开发').pack() tk.Label(self, text='关于作者:黄晨轲').pack() - tk.Label(self, text='版权所有:天地银行').pack() + tk.Label(self, text='开发时间:2024年5月').pack() class ChangeFrame(tk.Frame): def __init__(self,root): super().__init__(root) self.name = tk.StringVar() - self.math = tk.StringVar() - self.chinese = tk.StringVar() - self.english = tk.StringVar() + self.banji = tk.StringVar() + self.xuehao = tk.StringVar() + self.youbian = tk.StringVar() self.status = tk.StringVar() self.create_page() @@ -26,14 +26,14 @@ class ChangeFrame(tk.Frame): tk.Label(self,text='姓 名:').grid(row=1, column=1, pady=10) tk.Entry(self, textvariable=self.name).grid(row=1, column=2, pady=10) - tk.Label(self, text='数 学:').grid(row=2, column=1, pady=10) - tk.Entry(self, textvariable=self.math).grid(row=2, column=2, pady=10) + tk.Label(self, text='班 级:').grid(row=2, column=1, pady=10) + tk.Entry(self, textvariable=self.banji).grid(row=2, column=2, pady=10) - tk.Label(self, text='语 文:').grid(row=3, column=1, pady=10) - tk.Entry(self, textvariable=self.chinese).grid(row=3, column=2, pady=10) + tk.Label(self, text='学 号:').grid(row=3, column=1, pady=10) + tk.Entry(self, textvariable=self.xuehao).grid(row=3, column=2, pady=10) - tk.Label(self, text='英 语:').grid(row=4, column=1, pady=10) - tk.Entry(self, textvariable=self.english).grid(row=4, column=2, pady=10) + tk.Label(self, text='邮 编:').grid(row=4, column=1, pady=10) + tk.Entry(self, textvariable=self.youbian).grid(row=4, column=2, pady=10) tk.Button(self, text='查询', command=self.search_user).grid(row=5, column=1, pady=10, stick=tk.E) tk.Button(self, text='修改',command=self.change_user).grid(row=5, column=2, pady=10,stick=tk.E) @@ -45,19 +45,19 @@ class ChangeFrame(tk.Frame): flag, info = db.search_by_username(self.name.get()) if flag: self.name.set(info['name']) - self.math.set(info['math']) - self.chinese.set(info['chinese']) - self.english.set(info['english']) + self.banji.set(info['banji']) + self.xuehao.set(info['xuehao']) + self.youbian.set(info['youbian']) self.status.set('数据查询成功') else: self.status.set(info) def change_user(self): - stu = {"name": self.name.get(),"math": self.math.get(), "chinese": self.chinese.get(), "english": self.english.get()} + stu = {"name": self.name.get(),"banji": self.banji.get(), "xuehao": self.xuehao.get(), "youbian": self.youbian.get()} self.name.set('') - self.math.set('') - self.chinese.set('') - self.english.set('') + self.banji.set('') + self.xuehao.set('') + self.youbian.set('') db.update(stu) self.status.set('修改数据成功') @@ -68,9 +68,9 @@ class InsertFrame(tk.Frame): super().__init__(root) #tk.Label(self, text='录入页面').pack() self.name = tk.StringVar() - self.math = tk.StringVar() - self.chinese = tk.StringVar() - self.english = tk.StringVar() + self.banji = tk.StringVar() + self.xuehao = tk.StringVar() + self.youbian = tk.StringVar() self.status = tk.StringVar() self.create_page() @@ -80,14 +80,14 @@ class InsertFrame(tk.Frame): tk.Label(self,text='姓 名:').grid(row=1, column=1, pady=10) tk.Entry(self, textvariable=self.name).grid(row=1, column=2, pady=10) - tk.Label(self, text='数 学:').grid(row=2, column=1, pady=10) - tk.Entry(self, textvariable=self.math).grid(row=2, column=2, pady=10) + tk.Label(self, text='班 级:').grid(row=2, column=1, pady=10) + tk.Entry(self, textvariable=self.banji).grid(row=2, column=2, pady=10) - tk.Label(self, text='语 文:').grid(row=3, column=1, pady=10) - tk.Entry(self, textvariable=self.chinese).grid(row=3, column=2, pady=10) + tk.Label(self, text='学 号:').grid(row=3, column=1, pady=10) + tk.Entry(self, textvariable=self.xuehao).grid(row=3, column=2, pady=10) - tk.Label(self, text='英 语:').grid(row=4, column=1, pady=10) - tk.Entry(self, textvariable=self.english).grid(row=4, column=2, pady=10) + tk.Label(self, text='邮 编:').grid(row=4, column=1, pady=10) + tk.Entry(self, textvariable=self.youbian).grid(row=4, column=2, pady=10) tk.Button(self, text='录入',command=self.recode_info).grid(row=5, column=2, pady=10,stick=tk.E) tk.Label(self, textvariable=self.status).grid(row=6, column=2, pady=10) @@ -97,11 +97,11 @@ class InsertFrame(tk.Frame): def recode_info(self): - stu = {"name": self.name.get(),"math": self.math.get(), "chinese": self.chinese.get(), "english": self.english.get()} + stu = {"name": self.name.get(),"banji": self.banji.get(), "xuehao": self.xuehao.get(), "youbian": self.youbian.get()} self.name.set('') - self.math.set('') - self.chinese.set('') - self.english.set('') + self.banji.set('') + self.xuehao.set('') + self.youbian.set('') db.insert(stu) self.status.set('插入数据成功') @@ -115,17 +115,17 @@ class SearchFrame(tk.Frame): self.create_page() def create_page(self): - coulumns = ("name","chinese","math","english") - coulumns_values = ("姓名","语文","数学","英语") + coulumns = ("name","xuehao","banji","youbian") + coulumns_values = ("姓名","学号","班级","邮编") self.tree_view = ttk.Treeview(self, show='headings', columns=coulumns) self.tree_view.column('name',width=80,anchor='center') - self.tree_view.column('chinese', width=80, anchor='center') - self.tree_view.column('math', width=80, anchor='center') - self.tree_view.column('english', width=80, anchor='center') + self.tree_view.column('xuehao', width=80, anchor='center') + self.tree_view.column('banji', width=80, anchor='center') + self.tree_view.column('youbian', width=80, anchor='center') self.tree_view.heading('name',text='姓名') - self.tree_view.heading('chinese', text='语文') - self.tree_view.heading('math', text='数学') - self.tree_view.heading('english', text='英语') + self.tree_view.heading('xuehao', text='班级') + self.tree_view.heading('banji', text='学号') + self.tree_view.heading('youbian', text='邮编') self.tree_view.pack(fill=tk.BOTH, expand=True) self.show_data_frame() @@ -143,7 +143,7 @@ class SearchFrame(tk.Frame): for stu in student: print(stu) self.tree_view.insert('',index + 1,values=( - stu['name'],stu['math'],stu['chinese'],stu['english'], + stu['name'],stu['banji'],stu['xuehao'],stu['youbian'], )) @@ -161,4 +161,7 @@ class DeleteFrame(tk.Frame): def delete(self): username = self.username.get() flag,message = db.delete_by_username(username) - self.status.set(message) \ No newline at end of file + self.status.set(message) + + +