我正在尝试创建一个rota系统,根据他们的等级(管理或销售助理)及其可用性自动将员工添加到rota。但是,我的代码存在一些问题,主要是那些不想为我工作的GUI。
这是代码的一部分,这里的问题是它当前不会将数据输出到列表框,即使程序运行时没有发生错误。我和其他问题需要认真的帮助。
def __init__(self):
self.window = Tk()
self.window.wm_protocol("WM_DELETE_WINDOW",self.close)
self.window.title("View Management")
self.window.config(background='#ccffcc')
self.department_lst = Listbox(self.window,width=50,height=15)
self.department_lst.grid(row=0,column=0,sticky=W,columnspan=2,padx=10,pady=3)
#Department Menu
self.department_lbl = Label(self.window,text = 'Department')
self.department_lbl.grid(row=1,column=0)
self.department_lbl.config(background='#ccffcc')
options = ['Adults','Childrens']
self.department_option_var = StringVar()
self.department_option_var.trace('w',lambda name,index,mode: self.write_lst())
self.department_option_menu = OptionMenu(self.window,self.department_option_var, *options)
self.department_option_menu.configure(width=12,background='#ccffcc')
self.department_option_menu.grid(row=1,column=1)
def write_lst(self):
self.department_lst.delete(0,END)
for management in my_users.get_management():
if management.get_department()==self.department_option_var.get():
self.department_lst.insert(END, management.get_ID() + '\n')