class Message(Show_style): def __init__(self, master=None): Show_style.__init__(self, master) self.add_status() self.create_widget() self.pack_all() def create_widget(self): self.create_main_frame() def create_main_frame(self): self.main_labelframe = LabelFrame(self, text='消息中心') self.main_list_item = (('业务编号',10),('客户编号',8),('客户名称',20),('发放日',10),('到期日',10),('贷款金额',5),('产品名称',10),('期限', 5),('利率',8), ('申请状态', 14)) self.main_list = MultiListbox(self.main_labelframe, self.main_list_item, height=22) self.main_list.grid(padx=10, pady=10, row=0, column=0) self.check_button = Button(self.main_labelframe, text='察看') def check_func(): apply_information = self.get_mutilistbox_choose() if not apply_information: MessageBox('当前申请', '请先选中一个申请消息') return self.apply_information_toplevel = ApplyInformationToplevel(self, apply_information) self.check_button['command'] = check_func self.check_button.grid(pady=10, row=1, column=0) def get_mutilistbox_choose(self): now = self.main_list.curselection() if not now: return None else: print 'now', self.main_list.get(now) number = self.main_list.get(now)[0] #return const.apply_information_list[int(now[0])] for apply_information in const.apply_information_list: if apply_information[15] == number: return apply_information def refresh_mutilistbox(self): self.main_list.delete(0, self.main_list.size()) self.add_item() def add_item(self): apply_list = show_apply_list() for p in apply_list: now_state = int(p[-1]) if now_state >= 5: p[-1] = '审核通过' elif now_state > int(const.user_type): p[-1] = '等待上级审核' elif now_state == int(const.user_type): p[-1] = '等待当前用户审核' elif now_state < int(const.user_type): continue self.main_list.insert(Tkinter.END, p) def pack_all(self): self.main_labelframe.pack()
class EmailSettings(Toplevel): def __init__(self, parent): Toplevel.__init__(self, parent, height=400, width=700) #self.pack_propagate(0) self.transient(parent) self.title("VSAS - Email Settings") self._parent = parent self.adminEmail="" emailFile = open("vsasGUI/emailTester.txt","r") self.emailList = emailFile.readlines() emailFile.close() body = Frame(self, bg="black") self._initialFocus = self.body(body) body.pack_propagate(0) body.pack(padx=5,pady=5) self.buttonBox() self.current=None self.grab_set() self.bind("<F1>",self.displayHelp) if not self._initialFocus: self._initialFocus = self self.protocol("WM_DELETE_WINDOW", self.cancel) self.geometry("+%d+%d" % (parent.winfo_rootx()+50, parent.winfo_rooty()+50)) self._initialFocus.focus_set() self._parent.wait_window(self) def body(self, master): # create canvas to hold scrollbar and listbox objects emailListCanvas = Canvas(master, width=350, height=400) emailListCanvas.config(scrollregion=emailListCanvas.bbox(ALL)) emailListCanvas.grid(column=0, sticky=W) # create multiListbox to hold email list self._emailListbox = MultiListbox(emailListCanvas, (('Email', 160),("",1)), command = self.deleteEmail) for item in self.emailList: self._emailListbox.insert(END, (item,"")) self._emailListbox.grid(column = 0,columnspan=3, sticky=W) addButton = Button(emailListCanvas, text="Add",command=self.addEmail) addButton.grid(row=1,column=0) deleteButton = Button(emailListCanvas, text="Delete",command=self.deleteEmail) deleteButton.grid(row=1,column=1) helpButton = Button(emailListCanvas, text="Help", command = self.displayHelp) helpButton.grid(row=1,column=2) #Label(master, text="The administrator email will receive\nall information regarding all alerts", #fg="green",bg="black").grid(column=1, row=0) #self.adminEmailDisplay = Label(master, text=self.adminEmail) #self.adminEmailDisplay.grid(column=1, row=1) def buttonBox(self): pass def addEmail(self): email = EmailInput(self, title="Add Email").get() if len(email)>0: emailFile = open("vsasGUI/emailTester.txt","a") #emailComposite = email.split(",") #emailTuple = (emailComposite[0], emailComposite[1]) print email email = email+"\n" self.emailList.append(email) emailFile.write(email) emailFile.close() self._emailListbox.insert(END, (email,"")) self.update() def deleteEmail(self, event=None): if MsgBox.askyesno("Delete Email?","Are you sure you want to delete selected email?"): index = self.emailList[eval(self._emailListbox.curselection()[0])] self.emailList.remove(index) self._emailListbox.delete(0,END) emailFile = open("vsasGUI/emailTester.txt","w") for item in self.emailList: emailFile.write(item) self._emailListbox.insert(END, (item,"")) emailFile.close() def displayHelp(self, event=None): helpText = open("vsasGUI/EmailScreenHelp.txt","r").read() MsgBox.showinfo(title="VSAS Email Settings - Help", message=helpText) def cancel(self, event=None): if MsgBox.askyesno("Done?", "All changes have been saved.\nReturn to VSAS Main?"): self._parent.focus_set() self.destroy()
class Message(Show_style): def __init__(self, master=None): Show_style.__init__(self, master) self.add_status() self.create_widget() self.pack_all() def create_widget(self): self.create_main_frame() def create_main_frame(self): self.main_labelframe = LabelFrame(self, text='消息中心') self.main_list_item = (('业务编号', 10), ('客户编号', 8), ('客户名称', 20), ('发放日', 10), ('到期日', 10), ('贷款金额', 5), ('产品名称', 10), ('期限', 5), ('利率', 8), ('申请状态', 14)) self.main_list = MultiListbox(self.main_labelframe, self.main_list_item, height=22) self.main_list.grid(padx=10, pady=10, row=0, column=0) self.check_button = Button(self.main_labelframe, text='察看') def check_func(): apply_information = self.get_mutilistbox_choose() if not apply_information: MessageBox('当前申请', '请先选中一个申请消息') return self.apply_information_toplevel = ApplyInformationToplevel( self, apply_information) self.check_button['command'] = check_func self.check_button.grid(pady=10, row=1, column=0) def get_mutilistbox_choose(self): now = self.main_list.curselection() if not now: return None else: print 'now', self.main_list.get(now) number = self.main_list.get(now)[0] #return const.apply_information_list[int(now[0])] for apply_information in const.apply_information_list: if apply_information[15] == number: return apply_information def refresh_mutilistbox(self): self.main_list.delete(0, self.main_list.size()) self.add_item() def add_item(self): apply_list = show_apply_list() for p in apply_list: now_state = int(p[-1]) if now_state >= 5: p[-1] = '审核通过' elif now_state > int(const.user_type): p[-1] = '等待上级审核' elif now_state == int(const.user_type): p[-1] = '等待当前用户审核' elif now_state < int(const.user_type): continue self.main_list.insert(Tkinter.END, p) def pack_all(self): self.main_labelframe.pack()
class EmailSettings(Toplevel): def __init__(self, parent): Toplevel.__init__(self, parent, height=400, width=700) #self.pack_propagate(0) self.transient(parent) self.title("VSAS - Email Settings") self._parent = parent self.adminEmail = "" emailFile = open("emailTester.txt", "r") self.emailList = emailFile.readlines() emailFile.close() body = Frame(self, bg="black") self._initialFocus = self.body(body) body.pack_propagate(0) body.pack(padx=5, pady=5) self.buttonBox() self.current = None self.grab_set() self.bind("<F1>", self.displayHelp) if not self._initialFocus: self._initialFocus = self self.protocol("WM_DELETE_WINDOW", self.cancel) self.geometry("+%d+%d" % (parent.winfo_rootx() + 50, parent.winfo_rooty() + 50)) self._initialFocus.focus_set() self._parent.wait_window(self) def body(self, master): # create canvas to hold scrollbar and listbox objects emailListCanvas = Canvas(master, width=350, height=400) emailListCanvas.config(scrollregion=emailListCanvas.bbox(ALL)) emailListCanvas.grid(column=0, sticky=W) # create multiListbox to hold email list self._emailListbox = MultiListbox(emailListCanvas, (('Email', 160), ("", 1)), command=self.deleteEmail) for item in self.emailList: self._emailListbox.insert(END, (item, "")) self._emailListbox.grid(column=0, columnspan=3, sticky=W) addButton = Button(emailListCanvas, text="Add", command=self.addEmail) addButton.grid(row=1, column=0) deleteButton = Button(emailListCanvas, text="Delete", command=self.deleteEmail) deleteButton.grid(row=1, column=1) helpButton = Button(emailListCanvas, text="Help", command=self.displayHelp) helpButton.grid(row=1, column=2) #Label(master, text="The administrator email will receive\nall information regarding all alerts", #fg="green",bg="black").grid(column=1, row=0) #self.adminEmailDisplay = Label(master, text=self.adminEmail) #self.adminEmailDisplay.grid(column=1, row=1) def buttonBox(self): pass def addEmail(self): email = EmailInput(self, title="Add Email").get() if len(email) > 0: emailFile = open("emailTester.txt", "a") #emailComposite = email.split(",") #emailTuple = (emailComposite[0], emailComposite[1]) print email email = email + "\n" self.emailList.append(email) emailFile.write(email) emailFile.close() self._emailListbox.insert(END, (email, "")) self.update() def deleteEmail(self, event=None): if MsgBox.askyesno("Delete Email?", "Are you sure you want to delete selected email?"): index = self.emailList[eval(self._emailListbox.curselection()[0])] self.emailList.remove(index) self._emailListbox.delete(0, END) emailFile = open("emailTester.txt", "w") for item in self.emailList: emailFile.write(item) self._emailListbox.insert(END, (item, "")) emailFile.close() def displayHelp(self, event=None): helpText = open("EmailScreenHelp.txt", "r").read() MsgBox.showinfo(title="VSAS Email Settings - Help", message=helpText) def cancel(self, event=None): if MsgBox.askyesno( "Done?", "All changes have been saved.\nReturn to VSAS Main?"): self._parent.focus_set() self.destroy()