def search_extract(*args): layout_extract.label_of_client.text = f'Cliente: {layout_extract.search.text.title()}' global widget_for_scroll_extract widget_for_scroll_extract.clear_widgets() with open(file) as archive: cont = 0 total_debts = 0 list_with_payments = [] for c in range(0, lines_in_archive(file)): line = archive.readline().replace('\n', '').split('/') if line[0] == layout_extract.search.text.title(): total_debts += float(line[2]) if line[1] != '**pagamento**': widget_for_scroll_extract.add_widget(DefaultLabel(text=f'Compra: {line[1]}\nPreço: {line[2]}', size_hint=(1, None), height=size_screen[1] / 10)) cont += 1 else: list_with_payments.append(f'{line[2]}') layout_extract.total_debts.text = f'Total: R${total_debts:.2f}' for items in list_with_payments: widget_for_scroll_extract.add_widget(DefaultLabel(text=f'PAGAMENTO\nPreço: {items.replace("-", "")}', size_hint=(1, None), height=size_screen[1] / 10)) cont += 1 widget_for_scroll_extract.height = (size_screen[1] / 10) * cont
def __init__(self, **kwargs): super(ScreenMenu, self).__init__(**kwargs) layout_menu = DefaultFloatLayout(screen_size=size_screen) layout_menu.add_widget(MDIcon(icon='icons/hexagon-outline.png', pos_hint={'center_x': .1, 'center_y': .93}, size_hint=(.1, .055))) layout_menu.add_widget(DefaultLabel(text='RS', pos_hint={'center_x': .1, 'center_y': .93})) layout_menu.add_widget(DefaultLabel(text='Register Sell', pos_hint={'center_x': .35, 'center_y': .93}, font_size=size_screen[1] / 25)) # IMPLEMENTAR: Botão de configuração: # MDIconButton(pos_hint={'center_x': .5, 'center_y': .5}, # icon='icons/config.png', # user_font_size=str(size_screen[1] / 40) + 'sp')) layout_menu.add_widget(DefaultButtonMenu(text='Cadastrar dívida', on_release=self.change_screen_for_register, pos_hint={'center_x': .5, 'center_y': .8}, icon='account-plus')) layout_menu.add_widget(DefaultButtonMenu(text='Cadastrar pagamento', on_release=self.change_screen_for_payment, pos_hint={'center_x': .5, 'center_y': .66}, icon='account-cash')) layout_menu.add_widget(DefaultButtonMenu(text='Buscar dívida', on_release=self.change_screen_for_search, pos_hint={'center_x': .5, 'center_y': .52}, icon='magnify')) layout_menu.add_widget(DefaultButtonMenu(text='Todos os devedores', on_release=self.change_screen_for_all_debtors, pos_hint={'center_x': .5, 'center_y': .38}, icon='account-search')) layout_menu.add_widget(DefaultButtonMenu(text='Total de dívidas', on_release=self.change_screen_for_all_debts, pos_hint={'center_x': .5, 'center_y': .24}, icon='cash-register')) layout_menu.add_widget(DefaultButtonMenu(text='Excluir dados', on_release=self.change_screen_for_remove_data, pos_hint={'center_x': .5, 'center_y': .10}, icon='database-remove')) self.add_widget(layout_menu)
def __init__(self, **kwargs): super(ScreenRemoveData, self).__init__(**kwargs) global layout_remove_data layout_remove_data.add_widget(DefaultHeadLabel(screen_size=size_screen, text='Excluir dados', pos_hint={'center_x': .3, 'center_y': .9})) layout_remove_data.name = DefaultTextInput(screen_size=size_screen, hint_text='Apagar dados de', pos_hint={'center_x': .5, 'center_y': .73}, icon_left='account-remove') layout_remove_data.add_widget(layout_remove_data.name) layout_remove_data.add_widget(DefaultButton(screen_size=size_screen, text='Excluir dados do usuário', on_release=self.delete_data_confirmation, pos_hint={'center_x': .5, 'center_y': .63})) layout_remove_data.label = DefaultLabel() layout_remove_data.add_widget(layout_remove_data.label) layout_remove_data.add_widget(DefaultButton(screen_size=size_screen, text='Apagar todos os dados', on_release=self.delete_all_data_confirmation, pos_hint={'center_x': .5, 'center_y': .07})) self.add_widget(layout_remove_data)
def __init__(self, **kwargs): super(ScreenTotalDebts, self).__init__(**kwargs) global layout_total_debts layout_total_debts.add_widget(DefaultHeadLabel(screen_size=size_screen, text='Total de dívidas', pos_hint={'center_x': .36, 'center_y': .9})) layout_total_debts.search = DefaultTextInput(screen_size=size_screen, hint_text='Nome do cliente', pos_hint={'center_x': .5, 'center_y': .73}, icon_left='account') layout_total_debts.add_widget(layout_total_debts.search) layout_total_debts.infos = DefaultLabel(pos_hint={'center_x': .5, 'center_y': .58}, halign='center') layout_total_debts.add_widget(layout_total_debts.infos) layout_total_debts.add_widget(DefaultButton(screen_size=size_screen, text='Procurar', on_release=self.search, pos_hint={'center_x': .5, 'center_y': .43})) self.add_widget(layout_total_debts)
def __init__(self, **kwargs): super(ScreenPayment, self).__init__(**kwargs) global layout_payment layout_payment.add_widget(DefaultHeadLabel(screen_size=size_screen, text='Pagamento', pos_hint={'center_x': .27, 'center_y': .9})) layout_payment.input_name = DefaultTextInput(screen_size=size_screen, hint_text='Pagador', pos_hint={'center_x': .5, 'center_y': .73}, icon_left='account') layout_payment.add_widget(layout_payment.input_name) layout_payment.input_payment = DefaultTextInput(screen_size=size_screen, hint_text='Valor do pagamento', pos_hint={'center_x': .5, 'center_y': .63}, icon_left='cash-minus') layout_payment.add_widget(layout_payment.input_payment) layout_payment.label = DefaultLabel(pos_hint={'center_x': .5, 'center_y': .48}) layout_payment.add_widget(layout_payment.label) layout_payment.add_widget(DefaultButton(screen_size=size_screen, text='Confirmar', on_release=self.confirmation, pos_hint={'center_x': .5, 'center_y': .33})) self.add_widget(layout_payment)
def __init__(self, **kwargs): super(ScreenExtract, self).__init__(**kwargs) global layout_extract global widget_for_scroll_extract layout_extract.add_widget(DefaultHeadLabel(screen_size=size_screen, text='Extrato', pos_hint={'center_x': .2, 'center_y': .9})) layout_extract.search = DefaultTextInput(screen_size=size_screen, hint_text='Nome do cliente', pos_hint={'center_x': .5, 'center_y': .73}, icon_left='account') layout_extract.add_widget(layout_extract.search) layout_extract.add_widget(DefaultButton(screen_size=size_screen, text='Pesquisar', on_release=self.search_extract, pos_hint={'center_x': .5, 'center_y': .63})) layout_extract.label_of_client = DefaultLabel(text='Cliente: ', size_hint=(1, None), height=size_screen[1] / 13, pos_hint={'center_x': .5, 'center_y': .54}) layout_extract.add_widget(layout_extract.label_of_client) scroll_layout_extract = ScrollView(pos_hint={'center_x': .5, 'center_y': .3}, size_hint=(.9, .4)) scroll_layout_extract.add_widget(widget_for_scroll_extract) layout_extract.add_widget(scroll_layout_extract) layout_extract.total_debts = DefaultLabel(text='Total: R$', size_hint=(1, None), height=size_screen[1] / 13, pos_hint={'center_x': .5, 'center_y': .05}) layout_extract.add_widget(layout_extract.total_debts) self.add_widget(layout_extract)
def search_all_debtors(*args): scroll_layout_all_debtors.clear_widgets() widget_for_scroll_all_debtors.clear_widgets() list_with_debtors = [] cont = 0 with open(file) as archive: for c in range(0, lines_in_archive(file)): line = archive.readline().replace('\n', '').split('/') if line[0] not in list_with_debtors: widget_for_scroll_all_debtors.add_widget(DefaultLabel(text=f'{cont + 1} - {line[0]}', size_hint=(1, None), height=size_screen[1] / 13)) cont += 1 list_with_debtors.append(line[0]) if not list_with_debtors: widget_for_scroll_all_debtors.add_widget(DefaultLabel(text='Não existe devedores cadastrados!', size_hint=(1, None), height=size_screen[1] / 13)) cont = 1 widget_for_scroll_all_debtors.height = (size_screen[1] / 13) * cont scroll_layout_all_debtors.add_widget(widget_for_scroll_all_debtors)
def __init__(self, **kwargs): super(ScreenAllDebts, self).__init__(**kwargs) global layout_all_debts layout_all_debts.add_widget(DefaultHeadLabel(screen_size=size_screen, text='Total de dívidas', pos_hint={'center_x': .35, 'center_y': .9})) layout_all_debts.add_widget(DefaultButton(screen_size=size_screen, text='Pesquisar', on_release=self.search_all_debts, pos_hint={'center_x': .5, 'center_y': .73})) layout_all_debts.infos = DefaultLabel(text='O valor total de dívida é:', pos_hint={'center_x': .5, 'center_y': .6}) layout_all_debts.add_widget(layout_all_debts.infos) self.add_widget(layout_all_debts)
def __init__(self, **kwargs): super(ScreenRegister, self).__init__(**kwargs) global layout_register layout_register.add_widget(DefaultHeadLabel(screen_size=size_screen, text='Cadastro', pos_hint={'center_x': .25, 'center_y': .9})) layout_register.buyer = DefaultTextInput(screen_size=size_screen, hint_text='Comprador', pos_hint={'center_x': .5, 'center_y': .73}, icon_left='account') layout_register.add_widget(layout_register.buyer) layout_register.product = DefaultTextInput(screen_size=size_screen, hint_text='Produto', pos_hint={'center_x': .5, 'center_y': .63}, icon_left='basket') layout_register.add_widget(layout_register.product) layout_register.price = DefaultTextInput(screen_size=size_screen, hint_text='Preço', pos_hint={'center_x': .5, 'center_y': .53}, icon_left='cash-100') layout_register.add_widget(layout_register.price) layout_register.error = DefaultLabel(pos_hint={'center_x': .5, 'center_y': .38}) layout_register.add_widget(layout_register.error) layout_register.add_widget(DefaultButton(screen_size=size_screen, text='CONFIRMAR', on_release=self.confirm, pos_hint={'center_x': .5, 'center_y': .23})) self.add_widget(layout_register)