Ejemplo n.º 1
0
 def toggle(self):
     selected_rows = core.get_table_selections("workout_table")
     column = int(selected_rows[0][1])
     row = int(selected_rows[0][0])
     if column == 1:
         self._composed_workout[row]["Sets"] = (
             int(self._composed_workout[row]["Sets"]) + 1)
         core.set_table_item(
             "workout_table",
             row=row,
             column=column,
             value=str(self._composed_workout[row]["Sets"]),
         )
     elif column == 2:
         self._composed_workout[row]["Reps"] = (
             int(self._composed_workout[row]["Reps"]) + 1)
         core.set_table_item(
             "workout_table",
             row=row,
             column=column,
             value=str(self._composed_workout[row]["Reps"]),
         )
     elif column == 3:
         exercise_name = core.get_table_item("workout_table",
                                             column=0,
                                             row=row)
         example_link = workout_services.get_example_link_by_exercise(
             exercise_name)
         self.show_example(example_link)
     core.set_table_selection("workout_table",
                              row=row,
                              column=column,
                              value=False)
Ejemplo n.º 2
0
 def __toggle_stock(self, sender, data):
     """Toggle a todo to True of False.
     Get the selected cell of the table (list of [row index, column index])
     and uses the row index to update the todo at that index in the todos
     list. Then, saves the selected row index in the case you would want to
     delete that todo.
     """
     stock_row = dpg.get_table_selections("Stocks")
     stock = self.stocks[stock_row[0][0]]
     dpg.add_data("selected-stock-index", self.stocks.index(stock))
     dpg.set_value("Selected stock:", f"Selected Stock: {stock['Stock']}")
Ejemplo n.º 3
0
 def __toggle_todo(self, sender, data):
     """Toggle a todo to True of False.
     Get the selected cell of the table (list of [row index, column index])
     and uses the row index to update the todo at that index in the todos
     list. Then, saves the selected row index in the case you would want to
     delete that todo.
     """
     todo_row = dpg.get_table_selections("Todos")
     todo = self.todos[todo_row[0][0]]
     todo['done'] = not todo['done']
     dpg.add_data('selected-todo-index', self.todos.index(todo))
     dpg.set_value('Selected todo:', f"Selected id: {todo['id']}")
Ejemplo n.º 4
0
 def load_match(sender,data):
     nonlocal pars
     nonlocal c_board
     coords = dpg.get_table_selections(sender)
     dpg.delete_item('Partidas')
     dpg.delete_item('Lista de Partidas')
     i = coords[0][0]
     match = pars.matches[i]
     pars.current_match = match
     c_board.board = match.board
     c_board.reading_pgn = True
     dpg.set_value('accion','Leyendo partida PGN')
     dpg.set_value('pieza','Sin seleccionar')
     c_board.draw_board()
Ejemplo n.º 5
0
    def toggle(self, sender, data):
        selected_rows = core.get_table_selections("Workout")
        column = selected_rows[0][1]
        row = selected_rows[0][0]
        if int(column) == 0:
            pass
        elif int(column) == 3:
            exercise_name = core.get_table_item("Workout", column=0, row=row)
            example_link = get_example_link_by_exercise(exercise_name)
            self.show_example(example_link)

        core.set_table_selection("Workout",
                                 row=row,
                                 column=column,
                                 value=False)
Ejemplo n.º 6
0
    def selected(self, sender, data):
        """Handle when a row is selected in the table"""
        # sender will be the table itself. get_table_selections will return a list of selected table
        # coordinates. We can use these table coordinates to then get names of the selected
        # applications.
        selections = dpg_core.get_table_selections(sender)
        selected_items = [
            dpg_core.get_table_item(sender, *s) for s in selections
        ]

        number = int(sender.split("_")[1])
        self._grid_mapping[number] = selected_items
        self._allocated_windows = set(
            reduce(lambda s1, s2: set(s1) | set(s2),
                   self._grid_mapping.values()))
        self.refresh_available_windows()
Ejemplo n.º 7
0
def table_printer(table_name):
    selected_cells = core.get_table_selections(table_name)
    if selected_cells and len(selected_cells) == 1:
        cell_row = selected_cells[0][0]
        row_id = str(core.get_table_item(table_name, cell_row, ROW_ID_COLUMN))

        password_info = model.PasswordInfo(row_id=row_id)
        try:
            encrypted_password = model.select_password_by_row_id(password_info)
        except Exception:
            logger.add_error_message('Failed to get password.')
            return

        decrypted_password = decrypt(encrypted_password)
        pyperclip.copy(decrypted_password)

        logger.add_info_message(
            f'Row id: {row_id}\'s password was copied to clipboard.')
Ejemplo n.º 8
0
 def __remove_file(self, sender, data):
     file_row = dpg.get_table_selections("Files")
     file_index = file_row[0][0]
     self.files_list.pop(file_index)