コード例 #1
0
def tela_atualizacao(informacao_antiga):
    """
    Tela para atualizar informações de um emprestimo já cadastrado.
    :param informacao_antiga: um dicionário contento todas as antigas informações do emprestimo.
    :return: uma lista de valores, contento o conteúdo dos InputText.
    """
    layout = [
        [Text("Atualizar emprestimo")],
        [
            Text("Nome", size=(15, 1)),
            InputText(default_text=informacao_antiga['nome'],
                      do_not_clear=True)
        ],
        [
            Text("Telefone Fixo", size=(15, 1)),
            InputText(default_text=informacao_antiga['telefone'],
                      do_not_clear=True)
        ],
        [
            Text("Celular", size=(15, 1)),
            InputText(default_text=informacao_antiga['celular'],
                      do_not_clear=True)
        ],
        [
            Text("E-mail", size=(15, 1)),
            InputText(default_text=informacao_antiga['email'],
                      do_not_clear=True)
        ],
        [
            Text("De onde conhece", size=(15, 1)),
            InputText(default_text=informacao_antiga['vivencia'],
                      do_not_clear=True)
        ],
        [
            Text("Data", size=(15, 1)),
            InputText(
                default_text=informacao_antiga['data'].strftime("%d/%m/%Y"),
                do_not_clear=True)
        ],
        [
            Text("Item", size=(15, 1)),
            InputText(default_text=informacao_antiga['item'],
                      do_not_clear=True)
        ],
        [
            Button("Atualizar", button_color=('white', 'springgreen4')),
            Cancel(button_text="Cancelar",
                   button_color=('white', 'firebrick3'))
        ]
    ]
    janela = Window(
        "Cadastro",
        icon=('C:\\Loans-management\\Icon\\icon-logo.ico')).Layout(layout)
    botao, valores = janela.Read()
    print(valores)
    if botao == "Atualizar":
        janela.Close()
        return valores
    elif botao == 'Cancelar':
        janela.Close()
コード例 #2
0
def tela_cadastro():
    """
    Tela para cadastro de novo emprestimo.
    :return: uma lista contento as informações inputadas.
    """
    layout = [[Text("Cadastrar emprestimo")],
              [Text("Nome", size=(15, 1)),
               InputText()],
              [Text("Telefone Fixo", size=(15, 1)),
               InputText()], [Text("Celular", size=(15, 1)),
                              InputText()],
              [Text("E-mail", size=(15, 1)),
               InputText()],
              [Text("De onde conhece", size=(15, 1)),
               InputText()],
              [
                  Text("Data", size=(15, 1)),
                  InputText("ex: dia/mês/ano", do_not_clear=False)
              ], [Text("Item", size=(15, 1)),
                  InputText()],
              [
                  Button("Cadastrar", button_color=('white', 'springgreen4')),
                  Cancel(button_text="Cancelar",
                         button_color=('white', 'firebrick3'))
              ]]
    janela = Window(
        "Cadastro",
        disable_close=True,
        icon=('C:\\Loans-management\\Icon\\icon-logo.ico')).Layout(layout)
    botao, valores = janela.Read()
    if botao == "Cadastrar":
        janela.Close()
        return valores
    elif botao == 'Cancelar' or botao is None:
        janela.Close()
コード例 #3
0
def tela_escolha_busca():
    """
    Tela na qual o usuário escolhera qual o método de busca.
    :return: retorna uma string, sendo a escolha do usuário.
    """
    layout_busca = [[T("Deseja buscar por:", size=(30, 1))],
                    [
                        Button("Nome",
                               button_color=('white', 'springgreen4'),
                               size=(8, 1)),
                        Button("Item",
                               button_color=('white', 'springgreen4'),
                               size=(8, 1)),
                        Button("Ano",
                               button_color=('white', 'springgreen4'),
                               size=(8, 1)),
                        Button("Mes + Ano",
                               button_color=('white', 'springgreen4'),
                               size=(10, 1))
                    ],
                    [
                        Button("Cancelar",
                               button_color=('white', 'firebrick3'),
                               size=(8, 1),
                               pad=(150, 0))
                    ]]
    janela_busca = Window(
        "Buscas",
        size=(400, 100),
        text_justification=('center'),
        icon=(
            'C:\\Loans-management\\Icon\\icon-logo.ico')).Layout(layout_busca)
    botao_busca, valores_busca = janela_busca.Read()
    janela_busca.Close()
    return botao_busca
コード例 #4
0
def tela_excluir():
    """
    Tela para confirmação da exclusão de um emprestimo.
    :return: um valor booleano, para confirmação ou negação da ação.
    """
    layout = [[Text('Tem certeza que deseja excluir?')],
              [
                  Button("Sim",
                         size=(8, 1),
                         button_color=('white', 'springgreen4'),
                         pad=(20, 1)),
                  Button("Não",
                         size=(8, 1),
                         button_color=('white', 'firebrick3'))
              ]]
    janela = Window(
        'Excluir',
        icon=('C:\\Loans-management\\Icon\\icon-logo.ico')).Layout(layout)
    botao, evento = janela.Read()
    if botao == 'Sim':
        janela.Close()
        return True
    else:
        janela.Close()
        return False
コード例 #5
0
    def firstTest(temperature : int, m : SimpleNamespace, w : sg.Window):
        assert(temperature == 25 or temperature == 45)
        attenuation = ATTENUATION

        m.ardq.put(
            ArduinoMessage.TEMPERATURE({
                25: temp_bassa,
                45: temp_alta
            }[temperature]))

        while attenuation >= 0:
            if attenuation in m.collected_data.diretta[temperature].keys():
                attenuation -= 1
                continue
            else:
                break

        # I dati sono gia' stati raccolti
        if attenuation < 0:
            return True

        if not sendCommand(
                WorkMessage.SEND("Set_ATT,{:.2f}".format(attenuation)), m, w):
            w[Id.STATUS].Update("Errore di comunicazione!")
            return False

        if not sg.Popup(
                "Verifica carico 500HM correttamente inserito e temperatura impostata {:.2f} C"
                .format(temperature),
                keep_on_top=True,
                title="Attenzione!"):
            w[Id.STATUS].Update("Procedura interrotta!")
            return False

        while attenuation >= 0:
            if readings := readParameters(temperature, m, w):
                _, values = w.Read(timeout=0)
                k = float(values[Id.K])
                adjusted = .5 * ((readings[0] * k) / .5)
                adjusted = adjustPopup(adjusted)

                m.collected_data.diretta[temperature][attenuation] = [
                    readings[1], readings[3], adjusted
                ]
            else:
                return False

            if attenuation <= 0:
                break

            attenuation -= 1
            if not sendCommand(
                    WorkMessage.SEND("Set_ATT,{:.2f}".format(attenuation)), m,
                    w):
                w[Id.STATUS].Update("Errore di comunicazione!")
                return False
コード例 #6
0
ファイル: main_2.py プロジェクト: raghavg123/Xpnsit
    def Signup(self):
        signup_active = True

        layout = [
            [T("Signup for Xpnsit", **heading_format), ],
            [T("First Name:"), Input(size=(15, 1), key="f_name"), T(
                " "), T("Last Name:"), Input(size=(15, 1), key="l_name")],
            [T("Username:"******"user")],
            [T("Password:"******"pass", password_char="*")],
            [],
            [T(' '*40), Submit()]
        ]

        signup_win = Window("Xpnsit - Signup", layout=layout)

        while signup_active:  # <------------ Event Loop -----------------> #
            event, values = signup_win.Read()

            if event in (None, 'Exit'):
                signup_active = False
                login_active = True

            if event == 'Submit':
                self.vals = [values["user"], values["pass"],
                             values["mail"], values["f_name"], values["l_name"]]
                if not username_used(self.vals[0]):
                    create_account(*self.vals)

                    # <------------------- Confirmation of Insertion ------------------> #
                    success = check_login_info(values["user"], values["pass"])

                    if success == True:
                        print("Signup Successful.")
                        Popup(
                            "Signup Successful!",
                            "Exit this popup to return to the login page"
                        )
                        signup_win.close()
                        signup_active = False
                        login_active = True
                else:
                    PopupError("ERROR: Username already in usage",
                               title="Username already taken")
コード例 #7
0
ファイル: main_2.py プロジェクト: raghavg123/Xpnsit
    def Login(self):
        login_active = True
        layout = [
            [T("Xpnsit", **heading_format)],
            [T("Username:"******"user")],
            [T("Password:"******"pass", password_char='*')],
            [Button("Login", bind_return_key=True), Button("Signup")]
        ]

        win = Window("Xpnsit", layout=layout)

        while login_active:  # <------------ Event Loop -----------------> #
            event, values = win.Read()

            if event is None:
                print("Exiting event loop")
                login_active = False
                self.app_state = False
                win.close()
                del win
                break

            if event == "Login":
                success = check_login_info(values["user"], values["pass"])

                if success == True:
                    print("Login Successful.")

                    self.user_details = get_user_details(values["user"])
                    self.user = NewUser(*self.user_details)

                    win.close()

                    self.Interface()
                    login_active = False
                else:
                    PopupError(
                        "ERROR: Username or password incorrect.\nPlease try again.")

            if event == "Signup":
                self.Signup()
コード例 #8
0
def process_window(window: sg.Window):
    """
    Processes events, button clicks, for a detailed window
    :param window: The PySimpleGUI Window to work with
    :return: event: The button clicked or None if exited
    """
    event, values = window.Read(
        timeout=0)  # Read without waiting for button clicks
    if event in (None, 'Close'):
        window.Close()
        return None
    elif event == 'Action 1':
        window.Element('_ACTION_RESULT_').Update('Action 1 result = ' +
                                                 str(randint(0, 1000)))
    elif event == 'Action 2':
        window.Element('_ACTION_RESULT_').Update('Action 2 result = ' +
                                                 str(randint(-1000, 0)))
    # show dummy stats so can see window is live and operational
    window.Element('_INPUT_BYTES_').Update(randint(0, 40000))
    window.Element('_OUTPUT_BYTES_').Update(randint(0, 40000))
    return event  # return the button clicked
コード例 #9
0
def tela_busca(botao):
    """
    tela na qual será informado o que o usuário deseja pesquisar.
    :param botao: uma string, que informará qual o método de busca.
    :return: retorna dado informado pelo usuário, que será usado em uma função de busca.
    """
    if botao == 'Nome':
        layout_nome = [[T("Qual nome deseja buscar?", size=(30, 1))],
                       [In(size=(30, 1)), Button("Buscar")]]
        janela_nome = Window("Busca Nome",
                             size=(370, 100),
                             icon=('C:\\Loans-management\\Icon\\icon-logo.ico'
                                   )).Layout(layout_nome)
        buscar, nome = janela_nome.Read()
        janela_nome.Close()
        return nome[0]
    if botao == 'Item':
        layout_item = [[T("Qual item deseja buscar?", size=(30, 1))],
                       [In(size=(30, 1)), Button("Buscar")]]
        janela_item = Window("Busca Item",
                             size=(370, 100),
                             icon=('C:\\Loans-management\\Icon\\icon-logo.ico'
                                   )).Layout(layout_item)
        buscar, item = janela_item.Read()
        janela_item.Close()
        return item[0]
    if botao == 'Ano':
        layout_mes = [[T("Qual ano deseja buscar?", size=(30, 1))],
                      [In(size=(30, 1)), Button("Buscar")]]
        janela_mes = Window("Busca Ano",
                            size=(370, 100),
                            icon=('C:\\Loans-management\\Icon\\icon-logo.ico'
                                  )).Layout(layout_mes)
        buscar, mes = janela_mes.Read()
        try:
            mes = datetime.strptime(mes[0], '%Y').date().year
        except TypeError and ValueError:
            janela_mes.Close()
            return Popup("Erro na Busca",
                         button_color=('white', 'springgreen4'))
        janela_mes.Close()
        return mes
    if botao == 'Mes + Ano':
        layout_mes_ano = [[T("Qual mes e ano deseja buscar?", size=(30, 1))],
                          [In("Ex: 10/2018", size=(30, 1)),
                           Button("Buscar")]]
        janela_mes_ano = Window(
            "Busca Mes",
            size=(370, 100),
            icon=('C:\\Loans-management\\Icon\\icon-logo.ico'
                  )).Layout(layout_mes_ano)
        buscar, mes_ano = janela_mes_ano.Read()
        try:
            mes_ano = datetime.strptime(mes_ano[0], '%m/%Y').date()
        except TypeError and ValueError:
            janela_mes_ano.Close()
            return Popup("Erro na Busca",
                         button_color=('white', 'springgreen4'))
        janela_mes_ano.Close()
        return mes_ano
    if botao == 'Cancelar':
        return 0
コード例 #10
0
],
        [
            Slider(range=(37, 32767),
                   orientation='h',
                   default_value=10000,
                   key="Beep",
                   tooltip="Current frequency")
        ],
        [
            Button("-", key="Lower", tooltip="Lower frequency", size=(1, 1)),
            Button("+", key="Raise", tooltip="Raise frequency", size=(1, 1))
        ]]

layout = [[Column(col1)]]

window = Window("Beep!").Layout(layout).Finalize()
window.Size = (310, 140)
while True:
    event, values = window.Read(timeout=10)

    if not event or event == "Quit":
        break
    elif event == "Raise":
        window.Element("Beep").Update(values["Beep"] + int(values["Step"]))
    elif event == "Lower":
        window.Element("Beep").Update(values["Beep"] - int(values["Step"]))

    elif event == "Beep!":
        print(values)
        Beep(int(values["Beep"]), int(values["Time"]))
コード例 #11
0

def Different(dataINframes, sameEntries):
    dataOUTframes = list()
    for indx in range(0, len(dataINframes)):
        dataOUTframes.append((dataINframes[indx].merge(
            sameEntries[indx], indicator=True,
            how='left').loc[lambda x: x['_merge'] != 'both']
                              ).drop_duplicates())
    return dataOUTframes


window = Window('CompyrisonTool').Layout(layout1)
runTool = True
while runTool:
    event, values = window.Read()
    if (event is None or event == 'exit'):
        runTool = False

    if (event == 'toLayout2'):
        try:
            values['numFiles'] = int(values['numFiles'])
            layout2.append(
                [Text('Comparing ' + str(values['numFiles']) + ' files')])
            column = []
            for i in range(0, values['numFiles']):
                column.append([
                    Text(i + 1),
                    Input('Path', size=(49, 0)),
                    FileBrowse(file_types=(("Excel Workbook", "*.xlsx"),
                                           ("All Files", "*.*")))
コード例 #12
0
ファイル: main_2.py プロジェクト: raghavg123/Xpnsit
class Xpnsit:
    
    def __init__(self):
        self.app_state: bool = True
    # <------------------- Misc. Functions (Layouts and Updaters and stuff) --------------------> #

    def Add_Trans(self, particulars: str, _type: str, amount: float, date: str):
        cursor = conn.cursor()

        try:
            cursor.execute(f"""
            INSERT INTO transactions (
                user_id,
                username,
                particulars,
                exp_type,
                amount,
                exp_date
            )
            VALUES (
                {self.user.user_id},
                '{self.user.uname}',
                '{particulars}',
                '{_type}',
                {amount},
                "{date}"
                );
            """)

            conn.commit()

            Popup("Transaction successfully added.")
            self.win.Refresh()

        except SQLErrors.ProgrammingError:
            PopupError("ERROR: Invalid details.\nRectify and try again.")

        cursor.close()

    def Create_Add_Trans_Layout(self):
        layout = [
            [T("New Transaction", font=("Helvetica", 18))],
            [T("NOTE:", font=("Helvetica", 20)), T(
                "All fields are required to be filled.")],
            [T("Particulars:"), Multiline("Enter details of transaction",
                                          autoscroll=True, key="Particulars")],
            [T("Transaction type:"), Combo(["Select", "Credit", "Debit"],
                                           "Select", readonly=True, key="new_type")],
            [T("Amount:"), Input(enable_events=True, key="amount")],
            [T("Date Of Transaction:"), Input("YYYY-MM-DD or use the button on the right",
                                              key="date"), CalendarButton("Select Date", target="date", format="%Y-%m-%d")],
            [Submit()]
        ]

        return layout

    def History(self):
        history_values, table, no_of_records = get_transactions(
            self.user.uname)

        self.slider = sg.Slider(
            range=(0, no_of_records),
            default_value=no_of_records,
            orientation='h',
            enable_events=True,
            key='slider'
        )

        layout = [
            [T("Transaction History", font=("Helvetica", 18))],
            [T("All your transactions, in one place. Right click any one to delete or edit it.")],
            [T('Number of records to be shown:'), self.slider],
            [T("Show records from "),
             Input(f"{year}-{month}-1", key="start_date", size=(10, 1)),
             CalendarButton("Start date", target="start_date", default_date_m_d_y=(
                 month, 1, year), button_color=("white", "green"), format="%Y-%m-%d"),
             T("to"),
             Input(f"{year}-{month}-{day}", key="end_date", size=(10, 1)),
             CalendarButton("End date", target="end_date", default_date_m_d_y=(
                 month, day, year), button_color=("white", "red"), format="%Y-%m-%d")
             ],
            [T("Type:"), Combo(["All", "Credit", "Debit"],
                               default_value="All", key="used_type", readonly=True)],
            [T("Sort by:"), Combo(["Name", "Amount", "Date of Transaction"],
                                  default_value="Name", key="sort_by", readonly=True), Combo(["Ascending", "Descending"], default_value="Ascending", key="asc_or_desc", readonly=True)],
            [table, Button("Refresh", button_color=(
                "white", "orange"), bind_return_key=True, key="refresh")],


        ]
        self.history_active = True

        return layout

    def update_table(self):
        start, end = self.values['start_date'], self.values["end_date"]
        aod = 'ASC' if self.values["asc_or_desc"] == "Ascending" else "DESC"
        sort = "particulars" if self.values["sort_by"] == "Name" else "amount" if self.values["sort_by"] == "Amount" else "exp_date"
        n = self.values["slider"] if self.event == 'slider' else 10000
        new_trans, new_table, new_number_of_trans = get_transactions(
            self.user.user_id,
            int(n),
            start,
            end,
            aod,  # a(scending)o(r)d(escending)
            sort
        )
        print(new_trans, new_table, new_number_of_trans)

        self.win["table"].Update(new_trans)  # Updates table

        # Updates max number of records to be possibly displayed
        self.win["slider"].Update(range=(0, new_number_of_trans+1))

        # Updates the default value of the slider to be the max
        self.slider.Update(value=new_number_of_trans)

        self.win.Refresh()

    def create_graph(self):

        fig, w, h = get_graph_values(
            self.values['a_start_date'],
            self.values['a_end_date'],
            self.values["a_type"],
        )
        self.figure_agg = draw_figure(
            self.win['canvas'].TKCanvas, fig)
    # <------------------ Main Screens --------------------> #

    def Login(self):
        login_active = True
        layout = [
            [T("Xpnsit", **heading_format)],
            [T("Username:"******"user")],
            [T("Password:"******"pass", password_char='*')],
            [Button("Login", bind_return_key=True), Button("Signup")]
        ]

        win = Window("Xpnsit", layout=layout)

        while login_active:  # <------------ Event Loop -----------------> #
            event, values = win.Read()

            if event is None:
                print("Exiting event loop")
                login_active = False
                self.app_state = False
                win.close()
                del win
                break

            if event == "Login":
                success = check_login_info(values["user"], values["pass"])

                if success == True:
                    print("Login Successful.")

                    self.user_details = get_user_details(values["user"])
                    self.user = NewUser(*self.user_details)

                    win.close()

                    self.Interface()
                    login_active = False
                else:
                    PopupError(
                        "ERROR: Username or password incorrect.\nPlease try again.")

            if event == "Signup":
                self.Signup()

    def Signup(self):
        signup_active = True

        layout = [
            [T("Signup for Xpnsit", **heading_format), ],
            [T("First Name:"), Input(size=(15, 1), key="f_name"), T(
                " "), T("Last Name:"), Input(size=(15, 1), key="l_name")],
            [T("Username:"******"user")],
            [T("Password:"******"pass", password_char="*")],
            [],
            [T(' '*40), Submit()]
        ]

        signup_win = Window("Xpnsit - Signup", layout=layout)

        while signup_active:  # <------------ Event Loop -----------------> #
            event, values = signup_win.Read()

            if event in (None, 'Exit'):
                signup_active = False
                login_active = True

            if event == 'Submit':
                self.vals = [values["user"], values["pass"],
                             values["mail"], values["f_name"], values["l_name"]]
                if not username_used(self.vals[0]):
                    create_account(*self.vals)

                    # <------------------- Confirmation of Insertion ------------------> #
                    success = check_login_info(values["user"], values["pass"])

                    if success == True:
                        print("Signup Successful.")
                        Popup(
                            "Signup Successful!",
                            "Exit this popup to return to the login page"
                        )
                        signup_win.close()
                        signup_active = False
                        login_active = True
                else:
                    PopupError("ERROR: Username already in usage",
                               title="Username already taken")

    def Dashboard(self):
        income, expenses = get_income_and_expense(self.user.uname)

        if (income, expenses) == (None, None):
            dash_layout = [
                [T(f"Welcome {self.user.first_name}")],
                [T("Looks like you have no transactions!\nGo add one in the Transactions tab.",
                   justification="center")],
                [T("-"*60, text_color="gray")],
            ]
        else:
            dash_layout = [
                [T(f"Welcome {self.user.first_name}")],
                [T(f"Your expenses for {month_name}-{year} are:"),
                 T(str(expenses), font=("Arial", 20))],
                [T(f"Your income for {month_name}-{year} is:"),
                 T(str(income), font=("Arial", 20))],
                [T("-"*80, text_color="gray")],
                [T("Net Profit/Loss:", font=("Segoe", 18)),
                 T(str(income-expenses), font=("Arial", 24))]
            ]

        dash_active = True

        return dash_layout

    def Transactions(self):
        transaction_layout = [
            [T("Transactions", font=("Helvetica", 18))],
            [TabGroup(
                [
                    [Tab("New Transaction", self.Create_Add_Trans_Layout())],
                    [Tab("History", self.History())]
                ]
            )]
        ]

        return transaction_layout

    def Analytics(self):
        fig, w, h = get_graph_values()


        analysis_layout = [
            [T("Analytics", font=("Helvetica", 18))],
            [T("Here you can find and generate graphs for your desired timeframe\nand observe trends in your balance.")],
            [T("Generate for records from "),
             Input(f"{year}-{month}-1", key="a_start_date", size=(10, 1)),
             CalendarButton("Start date", target="a_start_date", default_date_m_d_y=(
                 month, 1, year), button_color=("white", "green"), format="%Y-%m-%d"),
             T("to"),
             Input(f"{year}-{month}-{day}", key="a_end_date", size=(10, 1)),
             CalendarButton("End date", target="a_end_date", default_date_m_d_y=(
                 month, day, year), button_color=("white", "red"), format="%Y-%m-%d")
             ],
            [T("Type:"), Combo(["All", "Credit", "Debit"],
                               default_value="All", key="a_type", readonly=True)],
            [Button("Generate", button_color=("white", "orange"))],
            [Canvas(size=(w, h), key="canvas")]
        ]

        return analysis_layout

    def Interface(self):
        global graph_active


        layout = [
            [T("Xpnsit", **heading_format), T(" "*50), Button("Settings"),
             Button("Log Out", button_color=("black", "yellow"))],
            [TabGroup([
                [
                    Tab("Dashboard", self.Dashboard(
                    ), tooltip="See an overview of your account", font=("Arial", 12)),
                    Tab("Transactions", self.Transactions(
                    ), tooltip="View,add and delete transactions", font=("Arial", 12), key="transactions"),
                    Tab("Analytics", self.Analytics(
                    ), tooltip="Get a graphical insight to your spendings.", font=("Arial", 12))
                ]
            ],)]
        ]

        self.win = Window("Xpnsit v1.0", layout=layout, size = (590,640),resizable=True)
        while True:
            self.event, self.values = self.win.Read()
            self.figure_agg = self.create_graph()

            if self.event == "Log Out":
                logout = PopupYesNo("Are you sure you want to log out?")

                if logout == 'Yes':
                    sg.popup_quick_message(
                        "Okay, closing. Bye", auto_close_duration=10)
                    self.win.close()
                    # self.app_state = False
                    del self.win
                    break
            elif self.event is None:
                self.win.close()
                self.app_state = False
                del self.win
                break

            if self.event != sg.TIMEOUT_KEY:
                print(f"Event = {self.event}\nValues = {self.values}\n")


            if self.event == "Submit":
                _type = "CR" if self.values["new_type"] in (
                    "Credit", "Select") else "DR"
                self.Add_Trans(
                    self.values["Particulars"],
                    _type,
                    self.values["amount"],
                    self.values["date"])

            if self.event in ("slider", "refresh"):

                self.update_table()
                self.win.refresh()

            if self.event == "Generate":
                # self.create_graph()
                delete_figure_agg(self.figure_agg)
                self.create_graph()
                self.win.read()
                self.win.refresh()
コード例 #13
0
                   ]
coluna_btt = [[Button('Editar', key='Editar',pad=(10,0,5), size=(8,1), button_color=('white', 'springgreen4')),
               Button('Apagar', key='Apagar', size=(8,1), button_color=('white', 'firebrick3'))]]
coluna_bt1 = [[Button("Cadastrar",button_color=('white', 'springgreen4'), size=(8,1)),
               Button("Sair", button_color=('white', 'firebrick3'), size=(8,1), pad=(10,0))]]
coluna_nomes = [[Button('Buscar', size=(8,1), pad=(25,1), button_color=('white', 'springgreen4')),
                 Button("", key='botao_busca', visible=False, size=(12,1),  button_color=('white', 'firebrick3'))],
                [Text("", size=(30,2), justification=('center'), key='buscas')],
                [Listbox(values= NOMES, key='lista', change_submits=True, size=(130, 100))]]
tela_principal = [[Frame("Loans-Management", coluna_detalhes), Column(coluna_nomes, size=(130,100))],
                  [Column(coluna_bt1, key='Apag', visible=True)],
                  [Column(coluna_btt, key='Edit', visible=False)]
                  ]
janela = Window("Loans-Management", size=(600, 350), icon=('C:\\Loans-management\\Icon\\icon-logo.ico'), text_justification=('center')).Layout(tela_principal)
while True:
    evento, valores = janela.Read()
    if evento == 'lista':
        try:
            nome = valores['lista'][0]
            emprestimo = buscar_nome(nome)
            nome = "Nome: " + emprestimo['nome']
            telefone = "Telefone: " + emprestimo['telefone']
            celular = "Celular: " + emprestimo['celular']
            email = "E-mail: " + emprestimo['email']
            vivencia = "Vivencia: " + emprestimo['vivencia']
            data = "Data: " + emprestimo['data'].strftime("%d/%m/%Y")
            item = "Item: " + emprestimo['item']
            janela.FindElement('nome').Update(nome)
            janela.FindElement('telefone').Update(telefone)
            janela.FindElement('celular').Update(celular)
            janela.FindElement('data').Update(data)