Beispiel #1
0
 def findNameInDatabase(self, window: sg.Window, name: str) -> Optional[DataBaseSearchResult]:
     database = window.FindElement('_db_name_').Get()
     fromdate = self.from_calendar.get_date()
     tilldate = self.till_calendar.get_date()
     if database in self.databaseFindFunctions:
         filename = self.databaseFindFunctions[database](window, name, fromdate, tilldate)
         if filename is not None:
             return DataBaseSearchResult(filename, fromdate, tilldate)
     else:
         sg.PopupError('Database \'{}\' is not supported'.format(database), title='ERROR')
     return None
Beispiel #2
0
    def onWindowFinalize(self, window: sg.Window) -> None:
        today = date.today()

        # There are no normal calendar in pySimpleGUI, so adding it by tkinter
        self.from_calendar = tkcalendar.DateEntry(window.FindElement('_db_from_frame_').Widget,
                                                  width=10,
                                                  year=today.year,
                                                  month=today.month,
                                                  day=today.day,
                                                  date_pattern='dd/mm/Y',
                                                  borderwidth=2)

        self.till_calendar = tkcalendar.DateEntry(window.FindElement('_db_till_frame_').Widget,
                                                  width=10,
                                                  year=today.year,
                                                  month=today.month,
                                                  day=today.day,
                                                  date_pattern='dd/mm/Y',
                                                  borderwidth=2)
        self.from_calendar.pack()
        self.till_calendar.pack()
        self.initLiChessClient()
Beispiel #3
0
 def onEvent(self, window: sg.Window, button) -> Optional[DataBaseSearchResult]:
     if button == '_db_find_':
         return self.findNameInDatabase(window, window.FindElement('_db_name_input_').Get())
     return None
Beispiel #4
0
    def chessDbShowSearchList(self, window: sg.Window, doc: lh.HtmlElement) -> None:
        th_elements = doc.xpath('//font/table/tr/th')
        tr_elements = doc.xpath('//font/table/tr')
        if len(th_elements) == 0:
            sg.PopupError('Internal error', title='ERROR')
            return

        header_row = []
        for element in th_elements:
            header_row.append(element.text_content())

        table_data = []
        for i in range(1, len(tr_elements)):
            if len(tr_elements[i]) > 0:
                table_dict = {}
                j = 0
                for t in tr_elements[i].iterchildren():
                    key = th_elements[j].text_content()
                    data = t.text_content().strip()
                    if key == data:
                        break
                    table_dict[key] = data
                    j = j + 1

                if j == len(th_elements):
                    table_data.append(table_dict)

        headers_to_show = self.searchTableHeadingsSizes.keys()
        table_to_show = []
        i = 1
        for table_dict in table_data:
            result_row = []
            for column in headers_to_show:
                if column == '#':
                    result_row.append(str(i))
                    continue
                if not (column in table_dict.keys()):
                    print('\'{}\' is not found in table {}'.format(column, table_dict))
                    sg.PopupError('Internal error: \'{}\' is not found in table'.format(column),
                                  title='ERROR')
                    return None
                result_row.append(table_dict[column])
            table_to_show.append(result_row)
            i += 1

        tableLayout = [[sg.Table(table_to_show,
                                 headings=list(self.searchTableHeadingsSizes.keys()),
                                 justification='left',
                                 auto_size_columns=False,
                                 col_widths=list(self.searchTableHeadingsSizes.values()),
                                 num_rows=10,
                                 key='_db_search_table_')],
                       [sg.Button('OK')]]
        table_window = sg.Window('Select player',
                                 default_button_element_size=(12, 1),
                                 auto_size_buttons=False,
                                 ).Layout(tableLayout)
        button, value = table_window.Read()
        table_window.Close()

        if button == 'OK' and '_db_search_table_' in value:
            if value['_db_search_table_'] is not None and len(value['_db_search_table_']) > 0:
                index = value['_db_search_table_'][0]
                window.FindElement('_db_name_input_').Update(table_to_show[index][self.searchTableIdIndex])
Beispiel #5
0
                  ]
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)
            janela.FindElement('item').Update(item)
            janela.FindElement('email').Update(email)
            janela.FindElement('vivencia').Update(vivencia)
            janela.FindElement('Edit').Update(visible=True)
            janela.FindElement('Apag').Update(visible=True)
        except IndexError:
            pass
    elif evento == 'Buscar':
        janela.FindElement('nome').Update('')
        janela.FindElement('telefone').Update('')
        janela.FindElement('celular').Update('')
        janela.FindElement('data').Update('')