def update_total_label(self): label_total = builder.get_object("label_total") label_total.set_text(formated_namber(self.total)) label_total_in_the_box = builder.get_object("label_total_in_the_box") label_total_in_the_box.set_text( formated_namber(self.manager.initial_value_in_the_box + self.total)) self.update_half_total_label()
def print_total_to_inform_file(self): from_file = today_file("r") line = from_file.readline() # make any changes to line here line = "Fecha: " line += str(today) + " " line += "TOTAL: " + formated_namber(self.total) + "\n" to_file = today_file("w") to_file.write(line) shutil.copyfileobj(from_file, to_file)
def btn_add(self, button): print("add") self.table_count = self.table_count + 1 if (self.table_count > 5): self.table_row_to_add = self.table_row_to_add + 1 count = float(self.count_obj.get_text()) price = self.price_obj.get_text().replace('.', '') price = int(price) value = price * count value = round(value) import_value = int(value) new_element = (self.description_obj.get_text(), self.count_obj.get_text(), self.messure, formated_namber(price), formated_namber(import_value)) self.list.append(list(new_element)) self.total = self.total + import_value self.total_label.set_text(formated_namber(self.total)) self.price_obj.set_text("") self.count_obj.set_text("") self.description_obj.set_text("")
def btn_delete(self, button): print("delete") selected = self.treeview.get_selection() (model, paths) = selected.get_selected_rows() for path in paths: iter = model.get_iter(path) text_value = self.list[iter][4] value = text_value.replace('.', '') print(int(value)) self.total = self.total - int(value) total_label = builder.get_object("label_total") total_label.set_text(formated_namber(self.total)) model.remove(iter)
def btn_new_clicked(self, button): print("new") self.inform_id += 1 print(self.inform_id) self.label_inform_number = builder.get_object("label_inform_number") self.label_inform_number.set_text(str(self.inform_id) + "-") open_file = open("./datos/presupuesto_numero.txt", "w+") open_file.write(str(self.inform_id)) self.list.clear() self.price_obj.set_text("") self.count_obj.set_text("") self.description_obj.set_text("") self.text_box_name.set_text("") self.text_box_build.set_text("") self.text_box_adress.set_text("") self.text_box_telephone.set_text("") self.total = 0 self.total_label.set_text(formated_namber(self.total)) self.table_row_to_add = 0 self.table_count = 0 self.input_inform_name.set_text('')
def modify_table(self, document): print("table") i = 1 table = document.tables[0] for elem in self.list: table.add_row() (des, count, unit, price, total) = elem run = table.cell(i, 0).paragraphs[0].add_run(des) run.font.size = Pt(10) run.font.name = "Arial" count_text = str(count) + unit + "." run = table.cell(i, 1).paragraphs[0].add_run(count_text) run.font.size = Pt(10) run.font.name = "Arial" table.cell(i, 1).paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT price_text = str(price) run = table.cell(i, 2).paragraphs[0].add_run(price_text) run.font.size = Pt(10) run.font.name = "Arial" table.cell(i, 2).paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT run = table.cell(i, 3).paragraphs[0].add_run(str(total)) run.font.size = Pt(10) run.font.name = "Arial" table.cell(i, 3).paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT self.set_cell_border(table.cell(i, 3), right={ "sz": 12, "val": "single" }, left={ "sz": 12, "val": "single" }) self.set_cell_border( table.cell(i, 0), left={ "sz": 12, "val": "single" }, ) i = i + 1 table.add_row() table.add_row() row_count = self.table_get_row_count(table) run = table.cell(row_count - 2, 0).paragraphs[0].add_run("TOTAL: ") run.font.bold = True run.font.size = Pt(10) run.font.name = "Arial" run = table.cell(row_count - 2, 3).paragraphs[0].add_run(formated_namber(self.total)) run.font.size = Pt(10) run.font.name = "Arial" table.cell(row_count - 2, 3).paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT text_total_line = "Son Gs.: " + num2words(self.total, lang='es') + "." run = table.cell(row_count - 1, 0).paragraphs[0].add_run(text_total_line) run.font.name = "Arial" run.font.bold = True run.font.size = Pt(10) self.modifyBorder(table) total_cell = table.cell(row_count - 2, 0) text_total_cell = table.cell(row_count - 1, 0) text_total_cell_nil = table.cell(row_count - 1, 3) total_cell_end = table.cell(row_count - 2, 3) self.set_cell_border( total_cell, top={ "sz": 12, "val": "single" }, bottom={ "sz": 12, "val": "single" }, left={ "sz": 12, "val": "single" }, right={ "sz": 12, "val": "single" }, ) self.set_cell_border( text_total_cell, top={ "sz": 12, "val": "single" }, bottom={ "sz": 12, "val": "single" }, left={ "sz": 12, "val": "single" }, right={ "sz": 12, "val": "single" }, ) self.set_cell_border( text_total_cell_nil, top={ "sz": 12, "val": "nil" }, bottom={ "sz": 12, "val": "nil" }, left={ "sz": 12, "val": "nil" }, right={ "sz": 12, "val": "nil" }, ) self.set_cell_border( total_cell_end, top={ "sz": 12, "val": "single" }, bottom={ "sz": 12, "val": "single" }, left={ "sz": 12, "val": "single" }, right={ "sz": 12, "val": "single" }, ) cell1 = table.cell(row_count - 1, 0) cell2 = table.cell(row_count - 1, 1) cell3 = table.cell(row_count - 1, 2) cell1.merge(cell2) cell1.merge(cell3) cell1 = table.cell(row_count - 2, 0) cell2 = table.cell(row_count - 2, 1) cell3 = table.cell(row_count - 2, 2) cell1.merge(cell2) cell1.merge(cell3)
def update_half_total_label(self): label_half_total = builder.get_object("label_halft_total") label_half_total.set_text(formated_namber(self.total / 2))