from tkinter import *
from tkinter import ttk
class studentClass():
def __init__(self, master):
self.name = StringVar()
self.master = master
self.createStudent()
def createStudent(self):
# 设置主窗口背景颜色
self.master.configure(bg="#96CDCD")
# 创建一个大的容器,用于放置所有控件
container = Frame(self.master, bg="#96CDCD")
container.pack(pady=10, padx=10, fill=BOTH, expand=True)
# 创建标签和输入框区域
label_frame = Frame(container, bg="#96CDCD")
label_frame.pack(side=TOP, pady=(10, 5))
name_label = Label(label_frame, text="姓名:", bg="#96CDCD", fg="white")
name_label.pack(side=LEFT, padx=5)
self.name_entry = Entry(label_frame, textvariable=self.name, width=20)
self.name_entry.pack(side=LEFT, padx=5)
# 创建按钮区域
button_frame = Frame(container, bg="#96CDCD")
button_frame.pack(side=BOTTOM, pady=(5, 10))
query_button = Button(button_frame, text="查询", bg="#96CDCD", fg="white", command=self.query)
query_button.pack(side=LEFT, padx=10)
add_button = Button(button_frame, text="新增", bg="#96CDCD", fg="white", command=self.add)
add_button.pack(side=LEFT, padx=10)
import_button = Button(button_frame, text="导入", bg="#96CDCD", fg="white", command=self.import_data)
import_button.pack(side=LEFT, padx=10)
export_button = Button(button_frame, text="导出", bg="#96CDCD", fg="white", command=self.export_data)
export_button.pack(side=LEFT, padx=10)
# 创建表格区域
table_frame = Frame(container, bg="#96CDCD")
table_frame.pack(side=TOP, fill=X, expand=True)
columns = ("name", "sdept1", "sdept", "class","teacher","score","talent")
self.tree_view = ttk.Treeview(table_frame, show='headings', columns=columns, style="Treeview")
self.tree_view.tag_configure("oddrow", background="#EAEAEA")
self.tree_view.tag_configure("evenrow", background="#FFFFFF")
self.tree_view.column("name", width=80, anchor='center')
self.tree_view.column("sdept1", width=80, anchor='center')
self.tree_view.column("sdept", width=80, anchor='center')
self.tree_view.column("class", width=80, anchor='center')
self.tree_view.column("teacher", width=80, anchor='center')
self.tree_view.column("score", width=80, anchor='center')
self.tree_view.column("talent", width=80, anchor='center')
self.tree_view.heading('name', text="姓名")
self.tree_view.heading('sdept1', text="院系")
self.tree_view.heading('sdept', text="专业")
self.tree_view.heading('class', text="班级")
self.tree_view.heading('teacher', text="负责教师")
self.tree_view.heading('score', text="学生成绩")
self.tree_view.heading('talent', text="擅长领域")
infor=["韩浩","软件学院","新型平台软件","2205","胡春辉","100","体育"]
self.tree_view.insert("","end",text="Item1",values=infor)
self.tree_view.pack(pady=10, fill=BOTH, expand=True)
self.tree_view.bind("<Double-1>",self.tree_vi)
# 树形视图滚动条设置
vsb = Scrollbar(table_frame, orient="vertical", command=self.tree_view.yview)
vsb.pack(side=RIGHT, fill=Y)
hsb = Scrollbar(table_frame, orient="horizontal", command=self.tree_view.xview)
hsb.pack(side=BOTTOM, fill=X)
self.tree_view.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
def tree_vi(self):
print(111)
def query(self):
pass
def add(self):
pass
def import_data(self):
pass
def export_data(self):
pass
class adminClass():
def __init__(self, master):
self.master = master
Button(master, text="这是招聘管理界面", font=("微软雅黑", 14), fg="white", bg="#96CDCD").pack()
class scoreClass():
def __init__(self, master):
self.master = master
Label(master, text="这是打分管理界面").pack()
class journalClass():
def __init__(self, master):
self.master = master
Label(master, text="这是日志管理界面").pack()
class discussClass():
def __init__(self, master):
self.master = master
Label(master, text="这是讨论区管理界面").pack()
root = Tk()
root.geometry("700x500")
frame = Frame(root, width=100, height=500, highlightbackground="#668B8B", highlightthickness=3)
frame.config(background="#96CDCD")
frame.pack(fill=Y, side=LEFT)
bai = Label(frame)
student = Label(frame, text="学生系统", font=("微软雅黑", 14), fg="white", bg="#96CDCD")
student.place(x=5, y=30)
admin = Label(frame, text="招聘系统", font=("微软雅黑", 14), fg="white", bg="#96CDCD")
admin.place(x=5, y=120)
score = Label(frame, text="打分管理", font=("微软雅黑", 14), fg="white", bg="#96CDCD")
score.place(x=5, y=210)
journal = Label(frame, text="日志管理", font=("微软雅黑", 14), fg="white", bg="#96CDCD")
journal.place(x=5, y=300)
discuss = Label(frame, text="讨论区", font=("微软雅黑", 14), fg="white", bg="#96CDCD")
discuss.place(x=5, y=390)
stuFrame = Frame(root)
admFrame = Frame(root)
scoFrame = Frame(root)
jouFrame = Frame(root)
disFrame = Frame(root)
studentClass(stuFrame)
adminClass(admFrame)
scoreClass(scoFrame)
journalClass(jouFrame)
discussClass(disFrame)
def stuFuntion(event=None):
stuFrame.pack(fill=BOTH, expand=True)
admFrame.pack_forget()
scoFrame.pack_forget()
jouFrame.pack_forget()
disFrame.pack_forget()
def admFuntion(event=None):
admFrame.pack()
stuFrame.pack_forget()
scoFrame.pack_forget()
jouFrame.pack_forget()
disFrame.pack_forget()
def scoFuntion(event=None):
scoFrame.pack()
stuFrame.pack_forget()
jouFrame.pack_forget()
disFrame.pack_forget()
admFrame.pack_forget()
def jouFuntion(event=None):
jouFrame.pack()
stuFrame.pack_forget()
disFrame.pack_forget()
admFrame.pack_forget()
scoFrame.pack_forget()
def disFuntion(event=None):
disFrame.pack()
stuFrame.pack_forget()
disFrame.pack_forget()
admFrame.pack_forget()
scoFrame.pack_forget()
student.bind("<Button-1>", stuFuntion)
admin.bind("<Button-1>", admFuntion)
score.bind("<Button-1>", scoFuntion)
journal.bind("<Button-1>", jouFuntion)
discuss.bind("<Button-1>", disFuntion)
root.title("学生管理系统")
root.mainloop()
self.tree_view.bind("<Double-1>",self.tree_vi)
这一行报错
studentClass.tree_vi() takes 1 positional argument but 2 were given