def updateAllList(self): self.allEnrList.setEditTriggers(QAbstractItemView.NoEditTriggers) model = QStandardItemModel(self.allEnrList) for i in Enrollee.all(): item = QStandardItem(i.to_string()) model.appendRow(item) self.allEnrList.setModel(model)
def exportXlsxClick(self): wb = openpyxl.load_workbook('..\\..\\Reports\\All.xlsx') if 'Enrollees' not in wb.sheetnames: wb.create_sheet('Enrollees') ws = wb['Enrollees'] ws.delete_cols(1, 6) ws.delete_rows(1, 100) all_list = Enrollee.all() for i in range (len(all_list)): ws.cell(row=i + 1, column=1).value = all_list[i].id ws.cell(row=i + 1, column=2).value = all_list[i].surname ws.cell(row=i + 1, column=3).value = all_list[i].name ws.cell(row=i + 1, column=4).value = all_list[i].patronymic ws.cell(row=i + 1, column=5).value = all_list[i].address ws.cell(row=i + 1, column=6).value = all_list[i].birthday ws.cell(row=i + 1, column=7).value = all_list[i].passport wb.save('..\\..\\Reports\\All.xlsx')
def all_enrollees(): try: enrollees = Enrollee.all() print_arr(enrollees) if len(enrollees) == 0: print("No results") else: res = int( input( "Enter number of selected enrollee or '-1' to go back: ")) if res > 0 and res <= len(enrollees): manipulate_enrollee(enrollees[res - 1]) return if res == -1: return else: print("Incorrect input") except: print("Error")
def exportDocxClick(self): for i in Enrollee.all(): enr_export(i)
def update_all(self, listbox): listbox.delete(0, END) self.all_list = Enrollee.all() for elem in self.all_list: listbox.insert(END, elem.to_string()) return
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) all = Frame(self) all.pack(side=LEFT, fill=Y) Label(all, text="All enrollees").pack() self.all_listbox = Listbox(all, width=100) self.all_listbox.bind('<Double-1>', self.all_list_on_click) self.all_list = Enrollee.all() for person in self.all_list: self.all_listbox.insert(END, person.to_string()) self.all_listbox.pack(side="top", fill="both", expand=True) all_docx_report = Button(all, text = "Export info about all enrollees in docx files", command=self.all_docx_export) all_docx_report.pack(side="top") xlsx_report = Button(all, text = "Export info about all enrollees in Excel", command=self.xlsx_export) xlsx_report.pack(side="top") ################################################################################################# find = Frame(self) find.pack(side=LEFT, fill=Y) Label(find, text="Find enrollee").pack() find_entry = Entry(find) find_entry.pack() self.find_listbox = Listbox(find, width=100) self.find_listbox.bind('<Double-1>', self.find_list_on_click) find_enr = partial(self.find_enr, self.find_listbox, find_entry) find_btn = Button(find, text="Find", command = find_enr).pack() self.find_listbox.pack(side="top", fill="both", expand=True) ######################################################################################################## add = Frame(self) add.pack() Label(add, text="Add enrollee", font="Helvetica -14 bold").grid(columnspan=2) Label(add, text="Surname: ").grid(row=1, column=0) surn = Entry(add, width=50) surn.grid(row=1, column=1) Label(add, text="Name: ").grid(row=2, column=0) name = Entry(add, width=50) name.grid(row=2, column=1) Label(add, text="Patronymic: ").grid(row=3, column=0) patr = Entry(add, width=50) patr.grid(row=3, column=1) Label(add, text="Address: ").grid(row=4, column=0) addr = Entry(add, width=50) addr.grid(row=4, column=1) Label(add, text="Date of birthday: ").grid(row=5, column=0) birth = DateEntry(add, width=12, background='darkblue', foreground='white', borderwidth=2, date_pattern='dd.mm.y') birth.grid(row=5, column=1) Label(add, text="Number of passport: ").grid(row=6, column=0) passp = Entry(add, width=50) passp.grid(row=6, column=1) add_enr = partial(self.add_enr, surn, name, patr, addr, birth, passp, self.all_listbox) add_btn = Button(add, text="Add enrollee", command =add_enr) add_btn.grid(columnspan=2)