first commit

main
hck 6 months ago
parent ec70015d6f
commit 7cc6e5a1e7

@ -1,3 +1,3 @@
[{"name": "张三","math": "66", "chinese": "78", "english": "99"}, [{"name": "张三","banji": "一年级一班", "xuehao": "1108", "youbian": "410000"},
{"name": "李四","math": "44", "chinese": "33", "english": "69"}, {"name": "李四","banji": "三年级三班", "xuehao": "3315", "youbian": "411000"},
{"name": "王五","math": "55", "chinese": "55", "english": "39"}] {"name": "王六","banji": "五年级二班", "xuehao": "5245", "youbian": "412000"}]

@ -5,18 +5,18 @@ from db import db
class AboutFrame(tk.Frame): class AboutFrame(tk.Frame):
def __init__(self,root): def __init__(self,root):
super().__init__(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='版权所有:天地银行').pack() tk.Label(self, text='开发时间2024年5月').pack()
class ChangeFrame(tk.Frame): class ChangeFrame(tk.Frame):
def __init__(self,root): def __init__(self,root):
super().__init__(root) super().__init__(root)
self.name = tk.StringVar() self.name = tk.StringVar()
self.math = tk.StringVar() self.banji = tk.StringVar()
self.chinese = tk.StringVar() self.xuehao = tk.StringVar()
self.english = tk.StringVar() self.youbian = tk.StringVar()
self.status = tk.StringVar() self.status = tk.StringVar()
self.create_page() self.create_page()
@ -26,14 +26,14 @@ class ChangeFrame(tk.Frame):
tk.Label(self,text='姓 名:').grid(row=1, column=1, pady=10) 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.Entry(self, textvariable=self.name).grid(row=1, column=2, pady=10)
tk.Label(self, text='数 学:').grid(row=2, column=1, 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.Entry(self, textvariable=self.banji).grid(row=2, column=2, pady=10)
tk.Label(self, text='语 文:').grid(row=3, column=1, 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.Entry(self, textvariable=self.xuehao).grid(row=3, column=2, pady=10)
tk.Label(self, text='英 语:').grid(row=4, column=1, 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.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.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) 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()) flag, info = db.search_by_username(self.name.get())
if flag: if flag:
self.name.set(info['name']) self.name.set(info['name'])
self.math.set(info['math']) self.banji.set(info['banji'])
self.chinese.set(info['chinese']) self.xuehao.set(info['xuehao'])
self.english.set(info['english']) self.youbian.set(info['youbian'])
self.status.set('数据查询成功') self.status.set('数据查询成功')
else: else:
self.status.set(info) self.status.set(info)
def change_user(self): 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.name.set('')
self.math.set('') self.banji.set('')
self.chinese.set('') self.xuehao.set('')
self.english.set('') self.youbian.set('')
db.update(stu) db.update(stu)
self.status.set('修改数据成功') self.status.set('修改数据成功')
@ -68,9 +68,9 @@ class InsertFrame(tk.Frame):
super().__init__(root) super().__init__(root)
#tk.Label(self, text='录入页面').pack() #tk.Label(self, text='录入页面').pack()
self.name = tk.StringVar() self.name = tk.StringVar()
self.math = tk.StringVar() self.banji = tk.StringVar()
self.chinese = tk.StringVar() self.xuehao = tk.StringVar()
self.english = tk.StringVar() self.youbian = tk.StringVar()
self.status = tk.StringVar() self.status = tk.StringVar()
self.create_page() self.create_page()
@ -80,14 +80,14 @@ class InsertFrame(tk.Frame):
tk.Label(self,text='姓 名:').grid(row=1, column=1, pady=10) 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.Entry(self, textvariable=self.name).grid(row=1, column=2, pady=10)
tk.Label(self, text='数 学:').grid(row=2, column=1, 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.Entry(self, textvariable=self.banji).grid(row=2, column=2, pady=10)
tk.Label(self, text='语 文:').grid(row=3, column=1, 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.Entry(self, textvariable=self.xuehao).grid(row=3, column=2, pady=10)
tk.Label(self, text='英 语:').grid(row=4, column=1, 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.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.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) 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): 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.name.set('')
self.math.set('') self.banji.set('')
self.chinese.set('') self.xuehao.set('')
self.english.set('') self.youbian.set('')
db.insert(stu) db.insert(stu)
self.status.set('插入数据成功') self.status.set('插入数据成功')
@ -115,17 +115,17 @@ class SearchFrame(tk.Frame):
self.create_page() self.create_page()
def create_page(self): def create_page(self):
coulumns = ("name","chinese","math","english") coulumns = ("name","xuehao","banji","youbian")
coulumns_values = ("姓名","语文","数学","英语") coulumns_values = ("姓名","学号","班级","邮编")
self.tree_view = ttk.Treeview(self, show='headings', columns=coulumns) self.tree_view = ttk.Treeview(self, show='headings', columns=coulumns)
self.tree_view.column('name',width=80,anchor='center') self.tree_view.column('name',width=80,anchor='center')
self.tree_view.column('chinese', width=80, anchor='center') self.tree_view.column('xuehao', width=80, anchor='center')
self.tree_view.column('math', width=80, anchor='center') self.tree_view.column('banji', width=80, anchor='center')
self.tree_view.column('english', width=80, anchor='center') self.tree_view.column('youbian', width=80, anchor='center')
self.tree_view.heading('name',text='姓名') self.tree_view.heading('name',text='姓名')
self.tree_view.heading('chinese', text='语文') self.tree_view.heading('xuehao', text='班级')
self.tree_view.heading('math', text='') self.tree_view.heading('banji', text='')
self.tree_view.heading('english', text='英语') self.tree_view.heading('youbian', text='邮编')
self.tree_view.pack(fill=tk.BOTH, expand=True) self.tree_view.pack(fill=tk.BOTH, expand=True)
self.show_data_frame() self.show_data_frame()
@ -143,7 +143,7 @@ class SearchFrame(tk.Frame):
for stu in student: for stu in student:
print(stu) print(stu)
self.tree_view.insert('',index + 1,values=( self.tree_view.insert('',index + 1,values=(
stu['name'],stu['math'],stu['chinese'],stu['english'], stu['name'],stu['banji'],stu['xuehao'],stu['youbian'],
)) ))
@ -162,3 +162,6 @@ class DeleteFrame(tk.Frame):
username = self.username.get() username = self.username.get()
flag,message = db.delete_by_username(username) flag,message = db.delete_by_username(username)
self.status.set(message) self.status.set(message)

Loading…
Cancel
Save