def print_write(self): '''This method sets the datas calls a calculate method and calls a messagebox data''' try: self.__in_hour = self.setdata(self.in_hour) self.__in_min = self.setdata(self.in_min) self.__out_hour = self.setdata(self.out_hour) self.__out_min = self.setdata(self.out_min) self.date = self.date.get() self.Meal = self.Meal.get() if self.__in_hour not in range(0, 24) or self.__out_hour \ not in range(0, 24) or self.__in_min not in range(0, 60) or self.__out_min not in range(0, 60) \ or self.Meal != 'i' and self.Meal != 'n': messagebox.single('HIBA', 'A bevitt adatok hibasak') else: self.execute() except ValueError: messagebox.single('HIBA', 'A bevitt adatok hibasak')
def showdata(self, Title, Fajl, Days): '''This method i''' Fajl = os.getcwd() + '\\' + Fajl self.Title = Title self.Fajl = Fajl IdoFajl = open(Fajl, 'a') IdoFajl.seek(0, 2) IdoFajlHossz = IdoFajl.tell() if IdoFajlHossz == 0L: messagebox.single(warempty_one, warempty_two) IdoFajl.close() else: showdata = Tk() self.f4 = showdata showdata.title(menufour_title) scrollbar = Scrollbar(showdata) scrollbar.pack(side=RIGHT, fill=Y) IdoFajl = open(Fajl, 'r') data_hours = data_min = 0 bejegyzes = 5 nap = 0 Label(showdata, text=Title, font='Bold', padx=10, pady=10).pack() begin = 0 # Start to Read from file while 1: IdoAdatok = IdoFajl.readline() Bont_result = re.match('(.*)(Munkaido)\s*(\d+:\d+)', IdoAdatok) Datum_result = re.match('(.*)(Datum)\s*(\d+.\d+.\d+)', IdoAdatok) whatday = dates.whatday(Datum_result) if Bont_result: work_time = Bont_result.group(3) hours = work_time.split(':')[0] mins = work_time.split(':')[1] data_hours += int(hours) data_min += int(mins) if IdoAdatok != '': FilePrint = self.Fajl + 'print' if begin == 0: try: os.remove(FilePrint) except WindowsError: pass directory.filewrite(FilePrint, self.Title + '\n') directory.filewrite(FilePrint, worktime_report1) begin = 1 s = re.sub('[DatumBelepesKilepesEbedMunkaIdo]', '', IdoAdatok) if whatday == 0: directory.filewrite(FilePrint, ' MON \t' + s) elif whatday == 1: directory.filewrite(FilePrint, ' TUE \t' + s) elif whatday == 2: directory.filewrite(FilePrint, ' WED \t' + s) elif whatday == 3: directory.filewrite(FilePrint, ' THU \t' + s) elif whatday == 4: directory.filewrite(FilePrint, ' FRI \t' + s) elif whatday == 5: directory.filewrite(FilePrint, ' SAT \t' + s) elif whatday == 6: directory.filewrite(FilePrint, ' SUN \t' + s) bejegyzes = bejegyzes + 1 nap = nap + 1 else: requiredmins = (nap * 8) * 60 currentmins = (data_hours * 60 + data_min) - requiredmins ShowMin = dates.mintotime(currentmins) if data_min > 60: plus_hours = data_min / 60 data_min = data_min % 60 data_hours += plus_hours data_hours = dates.ExpandWithZero(data_hours) data_min = dates.ExpandWithZero(data_min) directory.filewrite(FilePrint, '\n' + seperatesign) directory.filewrite(FilePrint, 'Osszegzesi informaciok :\n') directory.filewrite( FilePrint, 'Havi munkaorak szama : \t%s:%s' % (data_hours, data_min)) directory.filewrite(FilePrint, Days % nap) directory.filewrite( FilePrint, '\nJelenlegi óraszám : \t%s' % (ShowMin)) #Create a copy of File with open(FilePrint) as copy_of_file: file_content = copy_of_file.read() #Create a Testbox for Showing Information Ido_lista = Text(showdata, yscrollcommand=scrollbar.set, width=63, height=20, font='Bold') Ido_lista.pack(side=TOP, fill=NONE, padx=10, pady=10) scrollbar.config(command=Ido_lista.yview) Ido_lista.insert(END, file_content) Next = Button(showdata, text='Tovabb', height=1, width=20, command=self.quit_menutwo) Next.pack(side=LEFT, fill=NONE, padx=10, pady=10) Back = Button( showdata, text='Nyomtat', height=1, width=20, command=lambda : \ self.printfile(Fajl)) Back.pack(side=LEFT, fill=NONE, padx=10, pady=10) Ido_lista.configure(state='disabled') break IdoFajl.close()
def showdata( self, Title, Fajl, Days ): '''This method i''' Fajl= os.getcwd() + '\\' + Fajl self.Title = Title self.Fajl = Fajl IdoFajl = open(Fajl, 'a') IdoFajl.seek(0, 2) IdoFajlHossz = IdoFajl.tell() if IdoFajlHossz == 0L: messagebox.single(warempty_one, warempty_two) IdoFajl.close() else: showdata = Tk() self.f4 = showdata showdata.title(menufour_title) scrollbar = Scrollbar(showdata) scrollbar.pack(side=RIGHT, fill=Y) IdoFajl = open(Fajl, 'r') data_hours = data_min = 0 bejegyzes = 5 nap = 0 Label(showdata, text=Title, font='Bold', padx=10, pady=10).pack() begin = 0 # Start to Read from file while 1: IdoAdatok = IdoFajl.readline() Bont_result = re.match('(.*)(Munkaido)\s*(\d+:\d+)', IdoAdatok) Datum_result = re.match('(.*)(Datum)\s*(\d+.\d+.\d+)', IdoAdatok) whatday = dates.whatday(Datum_result) if Bont_result: work_time = Bont_result.group(3) hours = work_time.split(':')[0] mins = work_time.split(':')[1] data_hours += int(hours) data_min += int(mins) if IdoAdatok != '': FilePrint = self.Fajl + 'print' if begin == 0: try: os.remove(FilePrint) except WindowsError: pass directory.filewrite(FilePrint, self.Title + '\n' ) directory.filewrite(FilePrint, worktime_report1) begin = 1 s = re.sub('[DatumBelepesKilepesEbedMunkaIdo]', '', IdoAdatok) if whatday == 0: directory.filewrite(FilePrint, ' MON \t' + s) elif whatday == 1: directory.filewrite(FilePrint, ' TUE \t' + s) elif whatday == 2: directory.filewrite(FilePrint, ' WED \t' + s) elif whatday == 3: directory.filewrite(FilePrint, ' THU \t' + s) elif whatday == 4: directory.filewrite(FilePrint, ' FRI \t' + s) elif whatday == 5: directory.filewrite(FilePrint, ' SAT \t' + s) elif whatday == 6: directory.filewrite(FilePrint, ' SUN \t' + s) bejegyzes = bejegyzes + 1 nap = nap + 1 else: requiredmins = (nap*8)*60 currentmins = (data_hours *60 + data_min) -requiredmins ShowMin = dates.mintotime(currentmins) if data_min > 60: plus_hours = data_min / 60 data_min = data_min % 60 data_hours += plus_hours data_hours = dates.ExpandWithZero(data_hours) data_min = dates.ExpandWithZero(data_min) directory.filewrite(FilePrint, '\n' + seperatesign) directory.filewrite(FilePrint, 'Osszegzesi informaciok :\n') directory.filewrite(FilePrint, 'Havi munkaorak szama : \t%s:%s' % (data_hours, data_min)) directory.filewrite(FilePrint, Days % nap) directory.filewrite(FilePrint, '\nJelenlegi óraszám : \t%s' % (ShowMin)) #Create a copy of File with open (FilePrint) as copy_of_file: file_content = copy_of_file.read() #Create a Testbox for Showing Information Ido_lista = Text( showdata, yscrollcommand=scrollbar.set, width=63, height=20, font='Bold') Ido_lista.pack( side=TOP, fill=NONE, padx=10, pady=10) scrollbar.config(command=Ido_lista.yview) Ido_lista.insert(END, file_content) Next = Button( showdata,text='Tovabb', height=1,width=20, command=self.quit_menutwo) Next.pack( side=LEFT,fill=NONE, padx=10, pady=10) Back = Button( showdata, text='Nyomtat', height=1, width=20, command=lambda : \ self.printfile(Fajl)) Back.pack( side=LEFT, fill=NONE, padx=10, pady=10) Ido_lista.configure(state='disabled') break IdoFajl.close()