def __init__(self, slave, nameFirm): self.slave = slave self.nameFirm = nameFirm self.data = Data(self.slave, 'seller', self.nameFirm) self.balans = '----' self.db = Base('seller') self.format = Format()
def editData(self, event): newDateParam = self.date.get() checkDate = self.format.formatDate(newDateParam) if checkDate != False: newoplParam = self.opl.get() newpolParam = self.pol.get() newoplParam = newoplParam.replace(',', '.') newpolParam = newpolParam.replace(',', '.') checkNewoplParam = self.format.formatMany(newoplParam) checkNewpolParam = self.format.formatMany(newpolParam) if checkNewoplParam != False and checkNewpolParam != False: if newpolParam == None: newpolParam = '' if newoplParam == None: newoplParam = '' newComment = self.comment.get() newComment = newComment.replace('\"', '') newComment = newComment.replace('\'', '') newComment = self.format.formatCode(newComment) dataUpdate = Base(self.nameParam) dataUpdate.updateDataFirm(self.nameFirm, self.oldListParam, newDateParam, newoplParam, newpolParam, newComment) self.cancelEdit() else: self.error(self.editDataSel, 2) else: self.error(self.editDataSel, 1)
def newData(self, event): dateParam = self.date.get() checkDate = self.format.formatDate(dateParam) if checkDate != False: oplParam = self.opl.get() polParam = self.pol.get() oplParam = oplParam.replace(',', '.') polParam = polParam.replace(',', '.') checkOpl = self.format.formatMany(oplParam) checkPol = self.format.formatMany(polParam) if checkOpl != False and checkPol != False: if polParam == None: polParam = '' if oplParam == None: oplParam = '' comment = self.comment.get() comment = comment.replace('\"', '') comment = comment.replace('\'', '') comment = self.format.formatCode(comment) dataInsert = Base(self.nameParam) dataInsert.insertDataFirm(self.nameFirm, dateParam, oplParam, polParam, comment) self.cancelAdd() else: self.error(self.dataSel, 2) else: self.error(self.dataSel, 1)
def __init__(self, slave, name): self.name = name self.slave = slave self.db = Base(name) self.format = Format() self.var = IntVar() self.var.set(1) self.sortType = 1
def __init__(self, root): #self.loggerFactory = LoggerFactory() #self.logger = self.loggerFactory.getLoggers("customer") name = 'customer' self.root = root self.addFirm = Add(name) self.db = Base(name) self.format = Format() self.var = IntVar() self.var.set(1) self.sortType = 1
def editData(self, event): #print '1' newNameFirm = self.entName.get() newNameFirm = newNameFirm.replace('\"', '').replace('\'', '') newNameFirm = self.format.formatCode(newNameFirm) newInn = self.entInn.get() #newDateAct = self.entDate.get() newComment = self.entComment.get() newComment = newComment.replace('\"', '').replace('\'', '') newComment = self.format.formatCode(newComment) dataUpdate = Base(self.name) check = dataUpdate.updateData(self.listParam, newNameFirm.strip(), newInn, newComment) if check == False: self.error(self.edit) else: self.cancelEdit()
def newData(self, event): nameFirm = self.entName.get() nameFirm = nameFirm.replace('\"', '').replace('\'', '') nameFirm = nameFirm.strip() nameFirm = self.format.formatCode(nameFirm) inn = self.entInn.get() dateAct = '' comment = self.entComment.get() comment = comment.replace('\"', '').replace('\'', '') comment = self.format.formatCode(comment) if nameFirm == '' or nameFirm == None: self.cancelAdd() else: dataInsert = Base(self.name) check = dataInsert.insertData(nameFirm.strip(), inn, dateAct, comment) if check == False: self.error(self.firm) else: self.cancelAdd()
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import os from dataBase import Base if __name__ == "__main__": from optparse import OptionParser p=OptionParser() p.add_option('-p',dest='partiel',action="store_true", default=False,help='import de machine, groupe, ratio Maille et Perf uniquement') p.add_option('-f',dest='force',action="store_true", default=False,help='ecrasement des valeurs dans la base par les valeurs dans les fichiers en cas de meme clef primaire') p.add_option('-d',dest='database',default="myMesh.db",help='nom de la database') options, args = p.parse_args() if len(args) != 1 : print "entrer SVP le nom de la directory ou sont rangees les fichiers a charger" exit() folder=args[0] if not(os.path.isdir(folder)): print folder , " n existe pas" exit() maBase=Base(options.database) maBase.initialise() maBase.importFromCSV(folder,options.partiel,options.force) maBase.close()
class Seller(): def __init__(self,root): #self.loggerFactory = LoggerFactory() #self.logger = self.loggerFactory.getLoggers("seller") name = 'seller' self.root = root self.addFirm = Add(name) self.db = Base(name) self.format = Format() self.var=IntVar() self.var.set(1) self.sortType = 1 def pageSeller(self): Grid.rowconfigure(self.root, 0, weight=1) Grid.columnconfigure(self.root, 0, weight=1) self.seller = Toplevel(self.root,bg = '#59CCE9') self.seller.title('Поставщики') self.seller.geometry('1160x550+50+50') #self.seller.grab_set() Grid.rowconfigure(self.seller, 1, weight=1) Grid.columnconfigure(self.seller, 1, weight=1) framSel1 = Frame(self.seller,width=230,height=550,bg = '#59AAE9') self.selFrame2() framSel1.grid(row=1,column=1, rowspan=1, columnspan=1, sticky=N + S + E + W) framSel1ButtonAdd = Button(framSel1,font="Arial 12 bold",width=20,height=1,text="Добавить поставщика",bg='#EAEEEE',command=self.addSeller) framSel1ButtonAdd.place(x = 10, y = 45) #framSel1ButtonAdd.bind('<Button-1>', lambda _: self.addFirm.formAdd(self.seller)) framSel1ButtonEdit = Button(framSel1,font="Arial 12 bold",width=20,height=1,text="Редактировать",bg='#EAEEEE',command=self.editSeller) framSel1ButtonEdit.place(x = 10, y = 90) framSel1ButtonDelete = Button(framSel1,font="Arial 12 bold",width=20,height=1,text="Удалить",bg='#EAEEEE',command=self.deleteSeller) framSel1ButtonDelete.place(x = 10, y = 135) framSel1ButtonReload = Button(framSel1,font="Arial 12 bold",width=20,height=1,text="Обновить",bg='#EAEEEE',command=self.update) framSel1ButtonReload.place(x = 10, y = 180) framSel1ButtonExit = Button(framSel1,font="Arial 12 bold",width=8,height=1,text="Выход",bg='#EAEEEE',command=self.cancel) framSel1ButtonExit.place(x = 70, y = 470) Label(framSel1, text="Сортировать:",font="Arial 12 bold",bg='#59CCE9').place(x=10,y=240) rbutton1=Radiobutton(framSel1,text='по организации',font="Arial 11 bold",bg='#59CCE9',variable=self.var,value=1,command=self.radio_change) rbutton2=Radiobutton(framSel1,text='по менеджеру',font="Arial 11 bold",bg='#59CCE9',variable=self.var,value=2,command=self.radio_change) rbutton3=Radiobutton(framSel1,text='по дате',font="Arial 11 bold",bg='#59CCE9',variable=self.var,value=3,command=self.radio_change) rbutton1.place(x = 12, y = 270) rbutton2.place(x = 12, y = 300) rbutton3.place(x = 12, y = 330) def radio_change(self): if self.var.get() == 1: self.sortType = 1 elif self.var.get() == 2: self.sortType = 2 elif self.var.get() == 3: self.sortType = 3 def selFrame2(self): self.lists = [] Grid.rowconfigure(self.seller, 1, weight=100) Grid.columnconfigure(self.seller, 2, weight=100) framSel2 = Frame(self.seller,width=930,height=550) framSel2.grid(row=1,column=2, rowspan=1, columnspan=1, sticky=N + S + E + W) Label(framSel2, text='Поставщики',font="Arial 15 bold",bg="#59CCE9",bd=10).pack(fill=BOTH) frameb1 = Frame(framSel2); frameb1.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb1, text='№\n',borderwidth=1, relief=RAISED, font="Arial 12 bold", bg = '#59CCE9').pack(fill=X) lb1 = Listbox(frameb1, width=5, height=23, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE,font="Arial 13 bold", bg = '#D3E9E6') lb1.pack(expand=YES, fill=BOTH) lb1.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) lb1.bind('<Button-1>', lambda e, s=self: s._select(e.y)) lb1.bind('<Leave>', lambda e: 'break') lb1.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) lb1.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) #lb1.bind('<MouseWheel>', lambda e, s=self: s._whell(e.x, e.y)) frameb2 = Frame(framSel2); frameb2.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb2, text='Организация\n', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg = '#59CCE9').pack(fill=X) self.lb2 = Listbox(frameb2, width=40, height=23, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE,font="Arial 13 bold", bg = '#D3E9E6') self.lb2.pack(expand=YES, fill=BOTH) self.lb2.bind('<Double-Button-1>', self.curSelect) self.lb2.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) self.lb2.bind('<Button-1>', lambda e, s=self: s._select(e.y)) self.lb2.bind('<Leave>', lambda e: 'break') self.lb2.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) self.lb2.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) #self.lb2.bind('<MouseWheel>', lambda e, s=self: s._whell(e.x, e.y)) self.menu = Menu(self.lb2, font="Arial 12 bold", bg = 'lightblue', bd=10, tearoff=0) self.menu.add_command(label="Редактировать", command=self.editSeller) self.menu.add_command(label="Удалить", command=self.deleteSeller) self.lb2.bind("<Button-3>", lambda e, s=self: s.showMenu(e)) frameb3 = Frame(framSel2); frameb3.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb3, text='ИНН\n', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg = '#59CCE9').pack(fill=X) lb3 = Listbox(frameb3, width=15, height=23, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE,font="Arial 13 bold", bg = '#D3E9E6') lb3.pack(expand=YES, fill=BOTH) lb3.bind('<Double-Button-1>', self.curSelect) lb3.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) lb3.bind('<Button-1>', lambda e, s=self: s._select(e.y)) lb3.bind('<Leave>', lambda e: 'break') lb3.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) lb3.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) #lb3.bind('<MouseWheel>', lambda e, s=self: s._whell(e.x, e.y)) #lb3.bind('<Button-3>', lambda e, s=self: s._select(e.y)) self.menu = Menu(lb3, font="Arial 12 bold", bg = 'lightblue', bd=10, tearoff=0) self.menu.add_command(label="Редактировать", command=self.editSeller) self.menu.add_command(label="Удалить", command=self.deleteSeller) lb3.bind("<Button-3>", lambda e, s=self: s.showMenu(e)) frameb4 = Frame(framSel2); frameb4.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb4, text='Дата\nактуальлности', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg = '#59CCE9').pack(fill=X) lb4 = Listbox(frameb4, width=15, height=23, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE,font="Arial 13 bold", bg = '#D3E9E6') lb4.pack(expand=YES, fill=BOTH) lb4.bind('<Double-Button-1>', self.curSelect) lb4.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) lb4.bind('<Button-1>', lambda e, s=self: s._select(e.y)) lb4.bind('<Leave>', lambda e: 'break') lb4.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) lb4.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) #lb4.bind('<MouseWheel>', lambda e, s=self: s._whell(e.x, e.y)) #lb4.bind('<Button-3>', lambda e, s=self: s._select(e.y)) self.menu = Menu(lb4, font="Arial 12 bold", bg = 'lightblue', bd=10, tearoff=0) self.menu.add_command(label="Редактировать", command=self.editSeller) self.menu.add_command(label="Удалить", command=self.deleteSeller) lb4.bind("<Button-3>", lambda e, s=self: s.showMenu(e)) frameb5 = Frame(framSel2); frameb5.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb5, text='Менеджер\n', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg = '#59CCE9').pack(fill=X) lb5 = Listbox(frameb5, width=25, height=23, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE,font="Arial 13 bold", bg = '#D3E9E6') lb5.pack(expand=YES, fill=BOTH) lb5.bind('<Double-Button-1>', self.curSelect) lb5.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) lb5.bind('<Button-1>', lambda e, s=self: s._select(e.y)) lb5.bind('<Leave>', lambda e: 'break') lb5.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) lb5.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) #lb5.bind('<MouseWheel>', lambda e, s=self: s._whell(e.x, e.y)) #lb5.bind('<Button-3>', lambda e, s=self: s._select(e.y)) self.menu = Menu(lb5, font="Arial 12 bold", bg = 'lightblue', bd=10, tearoff=0) self.menu.add_command(label="Редактировать", command=self.editSeller) self.menu.add_command(label="Удалить", command=self.deleteSeller) lb5.bind("<Button-3>", lambda e, s=self: s.showMenu(e)) self.lists.append(lb1) self.lists.append(self.lb2) self.lists.append(lb3) self.lists.append(lb4) self.lists.append(lb5) sb = Scrollbar(framSel2, orient=VERTICAL, command=self._scroll) sb.pack(expand=YES, fill=Y) self.lists[0]['yscrollcommand']=sb.set #self.lists[0].config(yscrollcommand=sb.set) #sb.config(command=self.lists.yview) #self.lists[0]['yview']=sb.set resault = self.db.selectData(self.sortType) iter = 1 for name,inn,date_act,comment in resault: name = self.format.formatCode(name) comment = self.format.formatCode(comment) if str(name) == '' or str(name) == '-': break else: lb1.insert(END, ' %s' % str(iter)) self.lb2.insert(END, '%s' % str(name)) lb3.insert(END, '%s' % str(inn)) lb4.insert(END, '%s' % str(date_act)) lb5.insert(END, '%s' % str(comment)) iter = iter + 1 def showMenu(self,e): self._select2(e.y) self.curSelectAll(e) self.menu.post(e.x_root, e.y_root) def curSelect(self,evt): try: self.lb2.get(self.lb2.curselection()) values = [self.lb2.get(idx) for idx in self.lb2.curselection()] #print (', '.join(values)) self.doubleClick(', '.join(values)) #print '%s' % ', '.join(values) except Exception: pass def curSelectAll(self,evt): try: self.listParameter = [] for lb in self.lists: lb.get(lb.curselection()) values = [lb.get(idx) for idx in lb.curselection()] self.listParameter.append(str(self.format.formatCode(', '.join(values)))) #(str((', '.join(values)).encode('utf-8'))) #print '%s' % ', '.join(values) except Exception: pass def addSeller(self): self.addFirm.formAdd(self.seller) def editSeller(self): try: self.addFirm.formEdit(self.seller, self.listParameter) except Exception: pass def deleteSeller(self): self.delWindow = Toplevel(self.seller,bg = '#59CCE9') self.delWindow.title('Удаление покупателя') self.delWindow.geometry('280x150+450+180') self.delWindow.grab_set() Label(self.delWindow, text="",font="Arial 12 bold",bg = '#59CCE9').pack(side=TOP) Label(self.delWindow, text="Удалить все данные",font="Arial 12 bold",bg = '#59CCE9').pack(side=TOP) Label(self.delWindow, text="по выбранной организации?",font="Arial 12 bold",bg = '#59CCE9').pack(side=TOP) Button1 = Button(self.delWindow,font="Arial 12 bold",width=8,height=1,bg ='#EAEEEE',text="Нет",command=self.quitDel).pack(side=LEFT,padx=33) Button2 = Button(self.delWindow,font="Arial 12 bold",width=8,height=1,bg ='#EAEEEE',text="Да",command=self.deleteFirm).pack(side=LEFT) def deleteFirm(self): try: self.db.deleteFirm(self.listParameter) except Exception: pass self.quitDel() self.update() def quitDel(self): self.delWindow.destroy() def _select2(self, y): try: row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) return 'break' except Exception: pass def _select(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.curSelectAll(y) return 'break' def _button2(self, x, y): for l in self.lists: l.scan_mark(x, y) return 'break' def _whell(self, x, y): for l in self.lists: l.scan_mark(x, y) #return 'break' def _b2motion(self, x, y): for l in self.lists: l.scan_dragto(x, y) return 'break' def _scroll(self, *args): for l in self.lists: apply(l.yview, args) def curselection(self): #print str(self.lists[0].curselection()) return self.lists[0].curselection() def delete(self, first, last=None): for l in self.lists: l.delete(first, last) def get(self, first, last=None): result = [] for l in self.lists: result.append(l.get(first,last)) if last: return apply(map, [None] + result) return result def index(self, index): self.lists[0].index(index) def insert(self, index, *elements): for e in elements: i = 0 for l in self.lists: l.insert(index, e[i]) i = i + 1 def size(self): return self.lists[0].size() def see(self, index): for l in self.lists: l.see(index) def selection_anchor(self, index): for l in self.lists: l.selection_anchor(index) def selection_clear(self, first, last=None): for l in self.lists: l.selection_clear(first, last) def selection_includes(self, index): return self.lists[0].selection_includes(index) def selection_set(self, first, last=None): for l in self.lists: l.selection_set(first, last) def update(self): self.selFrame2() def cancel(self): self.seller.destroy() def doubleClick(self,nameFirm): nameFirm = str(self.format.formatCode(nameFirm)) addData = AddDataSeller(self.seller, nameFirm) addData.addForm() '''
class Info(): def __init__(self, slave, name): self.name = name self.slave = slave self.db = Base(name) self.format = Format() self.var = IntVar() self.var.set(1) self.sortType = 1 def tableInfo(self): Grid.rowconfigure(self.slave, 0, weight=1) Grid.columnconfigure(self.slave, 0, weight=1) self.text, self.oneColumn, self.twoColumn = self.param() self.slave.title(self.text) self.slave.geometry('1300x555+100+100') self.info = Toplevel(self.slave) ###self.info.title(self.text) ###self.info.geometry('1300x555+100+100') self.info.grab_set() self.frameDialog() self.frameBox() def frameDialog(self): Grid.rowconfigure(self.info, 1, weight=1) Grid.columnconfigure(self.info, 0, weight=1) frame2 = Frame(self.info, width=1300, height=95, bg='#20BAB5') frame2.grid(row=1, column=0, rowspan=1, columnspan=1, sticky=N + S + E + W) # Label Label(frame2, text="Начало периода:", font="Arial 12 bold", bg='#20BAB5').place(x=10, y=20) Label(frame2, text="Окончание периода:", font="Arial 12 bold", bg='#20BAB5').place(x=270, y=20) # Entry self.startDate = Entry(frame2, width=9, background='#CCEBEE', font="Arial 11 bold") self.startDate.insert(0, '2016-01-01') self.startDate.place(x=160, y=20) self.endDate = Entry(frame2, width=9, background='#CCEBEE', font="Arial 11 bold") self.endDate.insert(0, self.currentDate()) self.endDate.place(x=450, y=20) # Button buttonAdd = Button(frame2, font="Arial 12 bold", width=15, height=1, text="Сохранить в файл", bg='#E1E9E8', command=self.printToFile).place(x=11, y=55) buttonEdit = Button(frame2, font="Arial 12 bold", width=15, height=1, text="Обновить", bg='#E1E9E8', command=self.replace).place(x=180, y=55) buttonDel = Button(frame2, font="Arial 12 bold", width=15, height=1, text="Выход", bg='#E1E9E8', command=self.quit).place(x=350, y=55) Label(frame2, text="Сортировать:", font="Arial 12 bold", bg='#20BAB5').place(x=850, y=66) rbutton1 = Radiobutton(frame2, text='по организации', font="Arial 11 bold", bg='#20BAB5', variable=self.var, value=1, command=self.radio_change) rbutton2 = Radiobutton(frame2, text='по менеджеру', font="Arial 11 bold", bg='#20BAB5', variable=self.var, value=2, command=self.radio_change) rbutton1.place(x=980, y=66) rbutton2.place(x=1130, y=66) def frameBox(self): self.lists = [] Grid.rowconfigure(self.info, 2, weight=100) Grid.columnconfigure(self.info, 0, weight=100) frame1 = Frame(self.info, width=1300, height=450) frame1.grid(row=2, column=0, rowspan=1, columnspan=1, sticky=N + S + E + W) Label(frame1, text=self.text, font="Arial 14 bold", bd=15, bg='#20BAB5').pack(side=TOP, fill=X) frameb = Frame(frame1) frameb.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb, text='ID\n', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#20BAB5').pack(fill=X) lb = Listbox(frameb, width=5, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb.pack(expand=YES, fill=BOTH) self.serv(lb) frameb1 = Frame(frame1) frameb1.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb1, text='Наименование\n', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#20BAB5').pack(fill=X) self.lb1 = Listbox(frameb1, width=58, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') self.lb1.pack(expand=YES, fill=BOTH) self.serv(self.lb1) frameb2 = Frame(frame1) frameb2.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb2, text=self.oneColumn, borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#20BAB5').pack(fill=X) lb2 = Listbox(frameb2, width=14, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb2.pack(expand=YES, fill=BOTH) self.serv(lb2) frameb3 = Frame(frame1) frameb3.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb3, text=self.twoColumn, borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#20BAB5').pack(fill=X) lb3 = Listbox(frameb3, width=14, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb3.pack(expand=YES, fill=BOTH) self.serv(lb3) frameb5 = Frame(frame1) frameb5.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb5, text='Остаток на\nначало периода', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#20BAB5').pack(fill=X) lb5 = Listbox(frameb5, width=16, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb5.pack(expand=YES, fill=BOTH) self.serv(lb5) frameb4 = Frame(frame1) frameb4.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb4, text='Остаток на\nконец периода', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#20BAB5').pack(fill=X) lb4 = Listbox(frameb4, width=16, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb4.pack(expand=YES, fill=BOTH) self.serv(lb4) frameb6 = Frame(frame1) frameb6.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb6, text='Менеджер\n', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#20BAB5').pack(fill=X) lb6 = Listbox(frameb6, width=18, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb6.pack(expand=YES, fill=BOTH) self.serv(lb6) self.lists.append(lb) self.lists.append(self.lb1) self.lists.append(lb2) self.lists.append(lb3) self.lists.append(lb5) self.lists.append(lb4) self.lists.append(lb6) sb = Scrollbar(frame1, orient=VERTICAL, command=self._scroll) sb.pack(expand=YES, fill=Y) self.lists[0]['yscrollcommand'] = sb.set valueStartDate, valueEndDate = self.getDates() self.resault = self.db.infoStat(valueStartDate, valueEndDate, self.sortType) iter = 1 for param in self.resault: if str(param) == '' or str(param) == '-': break else: #iter = 1 #for rec xrange (0,len(param)): #name, plus, minus, balans in param: lb.insert(END, ' %s' % str(iter)) self.lb1.insert(END, ' %s' % param[0]) lb2.insert(END, '%s' % str(param[1])) lb3.insert(END, '%s' % str(param[2])) lb5.insert(END, '%s' % str(param[3])) lb4.insert(END, '%s' % str(param[4])) lb6.insert(END, '%s' % str(param[5])) iter = iter + 1 def param(self): if self.name == 'seller': text = 'Сводная таблица по поставщикам' oneColumn = 'Оплатили\nна сумму' twoColumn = 'Получили\nна сумму' elif self.name == 'customer': text = 'Сводная таблица по покупателям' oneColumn = 'Отгрузили\nна сумму' twoColumn = 'Оплата\n на сумму' return text, oneColumn, twoColumn def radio_change(self): if self.var.get() == 1: self.sortType = 1 elif self.var.get() == 2: self.sortType = 2 def quit(self): self.info.destroy() def replace(self): self.frameBox() def serv(self, slave): #slave.bind('<Button-3>', self.curseleсt()) slave.bind('<Double-Button-1>', self.curSelect) slave.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) slave.bind('<Button-1>', lambda e, s=self: s._select(e.y)) slave.bind('<Leave>', lambda e: 'break') slave.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) slave.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) return def curSelect(self, evt): try: self.lb1.get(self.lb1.curselection()) values = [self.lb1.get(idx) for idx in self.lb1.curselection()] #print (', '.join(values)) self.doubleClick(', '.join(values)) #print '%s' % ', '.join(values) except Exception: pass def curSelectAll(self, evt): try: self.listParameter = [] for lb in self.lists: lb.get(lb.curselection()) values = [lb.get(idx) for idx in lb.curselection()] self.listParameter.append( str(self.format.formatCode(', '.join(values)))) except Exception: pass def _select2(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) return 'break' def _select(self, y): try: row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.curSelectAll(y) return 'break' except Exception: pass def _button2(self, x, y): for l in self.lists: l.scan_mark(x, y) return 'break' def _b2motion(self, x, y): for l in self.lists: l.scan_dragto(x, y) return 'break' def _scroll(self, *args): for l in self.lists: apply(l.yview, args) def curselection(self): return self.lists[0].curselection() def delete(self, first, last=None): for l in self.lists: l.delete(first, last) def get(self, first, last=None): result = [] for l in self.lists: result.append(l.get(first, last)) if last: return apply(map, [None] + result) return result def index(self, index): self.lists[0].index(index) def insert(self, index, *elements): for e in elements: i = 0 for l in self.lists: l.insert(index, e[i]) i = i + 1 def size(self): return self.lists[0].size() def see(self, index): for l in self.lists: l.see(index) def selection_anchor(self, index): for l in self.lists: l.selection_anchor(index) def selection_clear(self, first, last=None): for l in self.lists: l.selection_clear(first, last) def selection_includes(self, index): return self.lists[0].selection_includes(index) def selection_set(self, first, last=None): for l in self.lists: l.selection_set(first, last) ''' def editCustomerData(self): try: self.data.editFormCustomerData(self.cus, self.listParameter) except Exception: pass def deleteCustomerData(self): try: self.db.deleteDataFirm(self.nameFirm,self.listParameter) except Exception: pass ''' def currentDate(self): curDate = datetime.date.today() return str(curDate) def currentTime(self): curTime = datetime.datetime.now() strCurTime = str(curTime).replace(' ', '_').replace(':', '')[:17] return strCurTime def currentDate(self): curDate = datetime.date.today() return str(curDate) def getDates(self): sDate = self.startDate.get() eDate = self.endDate.get() return sDate, eDate def doubleClick(self, nameFirm): nameFirm = nameFirm.strip() nameFirm = str(self.format.formatCode(nameFirm)) if self.name == 'seller': addData = AddDataSeller(self.info, nameFirm) elif self.name == 'customer': addData = AddDataCustomer(self.info, nameFirm) addData.addForm() def printToFile(self): res = self.resault name = self.name if name == 'seller': nameRus = 'ПОСТАВЩИКИ' columnOne = ' Оплачено ' columnTwo = ' Получено ' elif name == 'customer': nameRus = 'ПОКУПАТЕЛИ' columnOne = ' Отгружено' columnTwo = ' Оплата ' sDate = self.startDate.get() eDate = self.endDate.get() try: dirApp = (os.getcwd()).decode('cp1251') self.pathDir = '%s/savefile' % (dirApp) nameDecode = name.decode('UTF-8') self.nameFile = '%s.txt' % (nameRus.decode('UTF-8')) #self.nameFile = '%s_%s.txt' % (self.currentTime(),nameDecode) self.pathFile = os.path.join(self.pathDir, self.nameFile) with open(self.pathFile, 'w') as file: file.write(nameRus + '\n') file.write('Период с %s по %s%s' % (str(sDate), str(eDate), '\n')) file.write('\n') file.write('%s%s' % ( '************************************************************************************************************************', '\n')) file.write('%s %-2s %s %-48s %s %11s %s %11s%s %11s %s%s' % ('|', 'N', '|', 'НАИМЕНОВАНИЕ', '|', columnOne, '|', columnTwo, '|', ' Остаток на | Остаток на | Менеджер ', '|', '\n')) file.write('%s%s' % ( '| | | | | нач.периода |оконч.периода| |', '\n')) file.write('%s%s' % ( '************************************************************************************************************************', '\n')) iter = 1 for param in res: if iter > 1: file.write('%s%s' % ( '|----|--------------------------------------|-------------|-------------|-------------|-------------|------------------|', '\n')) #line = '%s %-10s %s %-15s %s %-15s %s %-40s %s%s' % ('|',a,'|',b,'|',c,'|',d,'|','\n') #line = '%s %-2s %s %-30s %s %13s %s %13s %s %13s %s%s' % ('|',str(iter),'|',self.formating(param[0]),'|',param[1],'|',param[2],'|',param[3],'|','\n') names = self.formating(param[0], 1) manag = self.formating(param[5], 2) line = '%s %-2s %s %-19s %s %11s %s %11s %s %11s %s %11s %s %8s %s%s' % ( '|', str(iter), '|', names, '|', param[1], '|', param[2], '|', param[3], '|', param[4], '|', manag, '|', '\n') #print line file.write(line) iter = iter + 1 file.write('%s%s' % ( '************************************************************************************************************************', '\n')) file.write('%s%s' % ('', '\n')) #file.write('Баланс : %s%s' % (balans,'\n')) file.close() self.ok() #except Exception: except Exception as error: traceback.print_exc() self.error() def ok(self): self.saveWind = Toplevel(self.info) self.saveWind.title('Выгразка данных в файл') #self.saveWind["bg"] = "green" self.saveWind.geometry('600x200+300+220') #self.saveWind.state("zoomed") self.saveWind.grab_set() Label(self.saveWind, text="Файл:", font="Arial 12 bold").pack(side=TOP, pady=10) Label(self.saveWind, text=self.nameFile, font="Arial 12 bold").pack(side=TOP) Label(self.saveWind, text="успешно сохранен по пути:", font="Arial 12 bold").pack(side=TOP) Label(self.saveWind, text=self.pathDir, font="Arial 12 bold").pack() buttonExit = Button(self.saveWind, font="Arial 12 bold", width=8, height=1, text="Ok", bd=10, command=self.quitOk).pack(side=BOTTOM, pady=10) def error(self): self.saveWind = Toplevel(self.info) self.saveWind.title('Ошибка сохранения файла') self.saveWind.geometry('400x110+300+200') self.saveWind.grab_set() Label(self.saveWind, text='Возникла ошибка при выгрузке данных в файл', font="Arial 12 bold").pack(side=TOP, pady=15) buttonExit = Button(self.saveWind, font="Arial 12 bold", width=8, height=1, text="Ok", bd=10, command=self.quitOk).pack(side=BOTTOM, pady=5) def quitOk(self): self.saveWind.destroy() def formating(self, valueString, flag): space = ' ' if flag == 1: if len(valueString.decode('utf-8')) > 36: splitValue = list(valueString.decode('utf-8')) newSplitValue = splitValue[0:36] valueString = '' for symb in newSplitValue: valueString = valueString + symb valueString = valueString.encode('utf-8') elif len(valueString.decode('utf-8')) < 36: while len(valueString.decode('utf-8')) < 36: valueString = '%s%s' % (valueString, space) elif flag == 2: if len(valueString.decode('utf-8')) > 16: splitValue = list(valueString.decode('utf-8')) newSplitValue = splitValue[0:16] valueString = '' for symb in newSplitValue: valueString = valueString + symb valueString = valueString.encode('utf-8') elif len(valueString.decode('utf-8')) < 16: while len(valueString.decode('utf-8')) < 16: valueString = '%s%s' % (valueString, space) return valueString
#!/usr/bin/env python import sys,os from PyQt4 import QtGui,QtCore pathRacine=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'..')) if os.path.dirname(pathRacine) not in sys.path : sys.path.insert(0,pathRacine) from dataBase import Base if __name__ == "__main__": from optparse import OptionParser p=OptionParser() p.add_option('-p',dest='partiel',action="store_true", default=False,help='export de machine, groupe, ratio Maille et Perf uniquement') p.add_option('-d',dest='database',default="../myMesh.db",help='nom de la database') options, args = p.parse_args() maBase=Base(options.database) maBase.initialise() maBase.exportToCSV(options.partiel) maBase.close()
class AddDataSeller(): def __init__(self, slave, nameFirm): self.slave = slave self.nameFirm = nameFirm self.data = Data(self.slave, 'seller', self.nameFirm) self.balans = '----' self.db = Base('seller') self.format = Format() def addForm(self): Grid.rowconfigure(self.slave, 0, weight=1) Grid.columnconfigure(self.slave, 0, weight=1) self.sel = Toplevel(self.slave, bg='#59CCE9') self.sel.title('Данные по %s' % (self.nameFirm)) self.sel.geometry('1000x650+120+100') self.sel.grab_set() #self.frameBox() self.frameDialog() self.frameBox() self.frameBal() def frameDialog(self): Grid.rowconfigure(self.sel, 1, weight=1) Grid.columnconfigure(self.sel, 0, weight=1) frame2 = Frame(self.sel, width=1000, height=95, bg='#59CCE9') frame2.grid(row=1, column=0, rowspan=1, columnspan=1, sticky=N + S + E + W) # Label Label(frame2, text="Начало периода:", font="Arial 12 bold", bg='#59CCE9').place(x=10, y=20) Label(frame2, text="Окончание периода:", font="Arial 12 bold", bg='#59CCE9').place(x=270, y=20) # Entry self.startDate = Entry(frame2, width=9, background='#CCEBEE', font="Arial 11 bold") self.startDate.insert(0, '2016-01-01') self.startDate.place(x=160, y=20) self.endDate = Entry(frame2, width=9, background='#CCEBEE', font="Arial 11 bold") self.endDate.insert(0, self.currentDate()) self.endDate.place(x=450, y=20) # Button buttonAdd = Button(frame2, font="Arial 12 bold", width=15, height=1, text="Завести данные", bg='#EAEEEE') buttonAdd.place(x=11, y=55) buttonAdd.bind('<Button-1>', lambda _: self.data.formAddData()) buttonEdit = Button(frame2, font="Arial 12 bold", width=15, height=1, text="Редактировать", bg='#EAEEEE', command=self.editSellerData).place(x=180, y=55) buttonDel = Button(frame2, font="Arial 12 bold", width=12, height=1, text="Удалить", bg='#EAEEEE', command=self.deleteSellerData).place(x=350, y=55) buttonPrint = Button(frame2, font="Arial 12 bold", width=16, height=1, text="Сохранить в файл", bg='#EAEEEE', command=self.printToFile).place(x=490, y=55) buttonExit = Button(frame2, font="Arial 12 bold", width=12, height=1, text="Выход", bg='#EAEEEE', command=self.quit).place(x=670, y=55) buttonReload = Button(frame2, font="Arial 12 bold", width=12, height=1, text="Обновить", bg='#EAEEEE', command=self.replace).place(x=810, y=55) def frameBox(self): self.lists = [] Grid.rowconfigure(self.sel, 2, weight=100) Grid.columnconfigure(self.sel, 0, weight=100) frame1 = Frame(self.sel, width=1000, height=450) frame1.grid(row=2, column=0, rowspan=1, columnspan=1, sticky=N + S + E + W) Label(frame1, text=self.nameFirm, font="Arial 13 bold", bd=15, bg='#59CCE9').pack(side=TOP, fill=X) frameb1 = Frame(frame1) frameb1.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb1, text='Дата\nоперации', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#59CCE9').pack(fill=X) lb1 = Listbox(frameb1, width=18, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb1.pack(expand=YES, fill=BOTH) self.serv(lb1) frameb2 = Frame(frame1) frameb2.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb2, text='Оплатили\n(в рублях)', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#59CCE9').pack(fill=X) lb2 = Listbox(frameb2, width=25, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb2.pack(expand=YES, fill=BOTH) self.serv(lb2) frameb3 = Frame(frame1) frameb3.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb3, text='Получили товара\nна сумму (в рублях)', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#59CCE9').pack(fill=X) lb3 = Listbox(frameb3, width=25, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb3.pack(expand=YES, fill=BOTH) self.serv(lb3) frameb4 = Frame(frame1) frameb4.pack(side=LEFT, expand=YES, fill=BOTH) Label(frameb4, text='Примечание\n', borderwidth=1, relief=RAISED, font="Arial 12 bold", bg='#59CCE9').pack(fill=X) lb4 = Listbox(frameb4, width=40, height=18, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE, font="Arial 13 bold", bg='#D3E9E6') lb4.pack(expand=YES, fill=BOTH) self.serv(lb4) self.lists.append(lb1) self.lists.append(lb2) self.lists.append(lb3) self.lists.append(lb4) sb = Scrollbar(frame1, orient=VERTICAL, command=self._scroll) sb.pack(expand=YES, fill=Y) self.lists[0]['yscrollcommand'] = sb.set valueStartDate, valueEndDate = self.getDates() self.resault, self.balansStart, self.balansSum, self.balansEnd, self.payCurr, self.depayCurr = self.db.statFirm( self.nameFirm, valueStartDate, valueEndDate) for datePaym, oplata, prichod, comment in self.resault: #if str(datePaym.encode('utf-8')) == '' or str(datePaym.encode('utf-8')) == '-': if str(datePaym) == '' or str(datePaym) == '-': break else: lb1.insert(END, ' %s' % datePaym) lb2.insert(END, '%s' % str(oplata)) lb3.insert(END, '%s' % str(prichod)) comment = comment.encode('utf-8') lb4.insert(END, '%s' % str(comment)) def frameBal(self): Grid.rowconfigure(self.sel, 3, weight=1) Grid.columnconfigure(self.sel, 0, weight=1) frameB = Frame(self.sel, width=1000, height=105, bg='#59CCE9') frameB.grid(row=3, column=0, rowspan=1, columnspan=1, sticky=N + S + E + W) #Label(frameB, text='Остаток на начало периода : ' + str(self.balansStart), width=47, bd=14, font="Arial 12 bold",bg='#59CCE9').pack(fill=X,side=LEFT)#grid(row = 1, column = 1) #Label(frameB, text='Остаток на окончание периода : ' + str(self.balansEnd), width=47, bd=14, font="Arial 12 bold",bg='#59CCE9').pack(fill=X,side=RIGHT)#grid(row = 1, column = 1) Label(frameB, text="", font="Arial 3 bold", bg='#59CCE9').grid(row=0, column=0, padx=15, sticky=W) Label(frameB, text="Остаток на начало периода: ", font="Arial 12 bold", bg='#59CCE9').grid(row=1, column=0, padx=15, sticky=W) Label(frameB, text="Остаток на окончание периода: ", font="Arial 12 bold", bg='#59CCE9').grid(row=2, column=0, padx=15, sticky=W) Label(frameB, text=str(self.balansStart), font="Arial 12 bold", bg='#59CCE9').grid(row=1, column=1, sticky=E) Label(frameB, text=str(self.balansEnd), font="Arial 12 bold", bg='#59CCE9').grid(row=2, column=1, sticky=E) Label(frameB, text="Оплатили товара за период на сумму: ", font="Arial 12 bold", bg='#59CCE9').grid(row=1, column=2, padx=50, sticky=W) Label(frameB, text="Получили товара за период на сумму: ", font="Arial 12 bold", bg='#59CCE9').grid(row=2, column=2, padx=50, sticky=W) Label(frameB, text=str(self.payCurr), font="Arial 12 bold", bg='#59CCE9').grid(row=1, column=3, sticky=E) Label(frameB, text=str(self.depayCurr), font="Arial 12 bold", bg='#59CCE9').grid(row=2, column=3, sticky=E) Label(frameB, text="", font="Arial 12 bold", bg='#59CCE9').grid(row=1, column=4, padx=40, sticky=W) def quit(self): self.sel.destroy() def replace(self): self.frameBox() self.frameBal() def serv(self, slave): #slave.bind('<Button-3>', self.curseleсt()) slave.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) slave.bind('<Button-1>', lambda e, s=self: s._select(e.y)) slave.bind('<Leave>', lambda e: 'break') slave.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) slave.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) self.menu = Menu(slave, font="Arial 12 bold", bg='lightblue', bd=10, tearoff=0) self.menu.add_command(label="Редактировать", command=self.editSellerData) self.menu.add_command(label="Удалить", command=self.deleteSellerData) slave.bind("<Button-3>", lambda e, s=self: s.showMenu(e)) return def showMenu(self, e): self._select2(e.y) self.curSelectAll(e) self.menu.post(e.x_root, e.y_root) def curSelectAll(self, evt): try: self.listParameter = [] for lb in self.lists: lb.get(lb.curselection()) values = [lb.get(idx) for idx in lb.curselection()] self.listParameter.append( str(self.format.formatCode(', '.join(values)))) except Exception: pass def _select2(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) return 'break' def _select(self, y): try: row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.curSelectAll(y) return 'break' except Exception: pass def _button2(self, x, y): for l in self.lists: l.scan_mark(x, y) return 'break' def _b2motion(self, x, y): for l in self.lists: l.scan_dragto(x, y) return 'break' def _scroll(self, *args): for l in self.lists: apply(l.yview, args) def curselection(self): return self.lists[0].curselection() def delete(self, first, last=None): for l in self.lists: l.delete(first, last) def get(self, first, last=None): result = [] for l in self.lists: result.append(l.get(first, last)) if last: return apply(map, [None] + result) return result def index(self, index): self.lists[0].index(index) def insert(self, index, *elements): for e in elements: i = 0 for l in self.lists: l.insert(index, e[i]) i = i + 1 def size(self): return self.lists[0].size() def see(self, index): for l in self.lists: l.see(index) def selection_anchor(self, index): for l in self.lists: l.selection_anchor(index) def selection_clear(self, first, last=None): for l in self.lists: l.selection_clear(first, last) def selection_includes(self, index): return self.lists[0].selection_includes(index) def selection_set(self, first, last=None): for l in self.lists: l.selection_set(first, last) def editSellerData(self): try: self.data.editFormSellerData(self.sel, self.listParameter) except Exception: pass def deleteSellerData(self): try: self.db.deleteDataFirm(self.nameFirm, self.listParameter) except Exception: pass def currentDate(self): curDate = datetime.date.today() return str(curDate) def currentTime(self): curTime = datetime.datetime.now() strCurTime = str(curTime).replace(' ', '_').replace(':', '')[:17] return strCurTime def getDates(self): sDate = self.startDate.get() eDate = self.endDate.get() return sDate, eDate def printToFile(self): res = self.resault name = self.nameFirm balansStart = self.balansStart balansEnd = self.balansEnd sDate = self.startDate.get() eDate = self.endDate.get() try: dirApp = (os.getcwd()).decode('cp1251') self.pathDir = '%s/savefile' % (dirApp) nameDecode = name.decode('UTF-8') self.nameFile = '%s.txt' % (nameDecode) #self.nameFile = '%s_%s.txt' % (self.currentTime(),nameDecode) self.pathFile = os.path.join(self.pathDir, self.nameFile) iter = 1 with open(self.pathFile, 'w') as file: file.write('Поставщик: ' + name + '\n') file.write('Период с %s по %s%s' % (str(sDate), str(eDate), '\n')) file.write('\n') file.write('Остаток на начало периода : %s%s' % (balansStart, '\n')) file.write('\n') file.write('%s%s' % ( '***********************************************************************************************************************', '\n')) file.write('%s %10s %s %18s %s %18s %s %25s %s%s' % ( '|', ' Дата ', '|', ' Оплачено ', '|', ' Получено ', '|', ' Примечание ', '|', '\n')) file.write('%s%s' % ( '***********************************************************************************************************************', '\n')) for a, b, c, d in res: if len(d) > 60: d = d[0:60] elif len(d) < 60: d = d.ljust(60) if iter > 1: file.write('%s%s' % ( '|------------|--------------------|--------------------|--------------------------------------------------------------|', '\n')) #line = '%s %-10s %s %-15s %s %-15s %s %-40s %s%s' % ('|',a,'|',b,'|',c,'|',d,'|','\n') line = '%s %-10s %s %18s %s %18s %s %s %s%s' % ( '|', a, '|', b, '|', c, '|', d, '|', '\n') file.write(self.format.formatCode(line)) iter = iter + 1 file.write('%s%s' % ( '***********************************************************************************************************************', '\n')) file.write('%s%s' % ('', '\n')) #file.write('Остаток на начало периода : %s%s' % (balansStart,'\n')) file.write('Остаток на окончание периода : %s%s' % (balansEnd, '\n')) file.write('Оплатили товара за период на сумму : %s%s' % (self.payCurr, '\n')) file.write('Получили товара за период на сумму : %s%s' % (self.depayCurr, '\n')) file.close() self.ok() #except Exception: except Exception as error: traceback.print_exc() self.error() def ok(self): self.saveWind = Toplevel(self.sel) self.saveWind.title('Выгразка данных в файл') #self.saveWind["bg"] = "green" self.saveWind.geometry('600x200+300+220') #self.saveWind.state("zoomed") self.saveWind.grab_set() Label(self.saveWind, text="Файл:", font="Arial 12 bold").pack(side=TOP, pady=10) Label(self.saveWind, text=self.nameFile, font="Arial 12 bold").pack(side=TOP) Label(self.saveWind, text="успешно сохранен по пути:", font="Arial 12 bold").pack(side=TOP) Label(self.saveWind, text=self.pathDir, font="Arial 12 bold").pack() buttonExit = Button(self.saveWind, font="Arial 12 bold", width=8, height=1, text="Ok", bd=10, command=self.quitOk).pack(side=BOTTOM, pady=10) def error(self): self.saveWind = Toplevel(self.sel) self.saveWind.title('Ошибка сохранения файла') self.saveWind.geometry('400x110+300+200') self.saveWind.grab_set() Label(self.saveWind, text='Возникла ошибка при выгрузке данных в файл', font="Arial 12 bold").pack(side=TOP, pady=15) buttonExit = Button(self.saveWind, font="Arial 12 bold", width=8, height=1, text="Ok", bd=10, command=self.quitOk).pack(side=BOTTOM, pady=5) def quitOk(self): self.saveWind.destroy()