def return_rgb_action(row, action_dict):
    return row.values[2]


if __name__ == '__main__':
    table_items = [
        TableItem('red'),
        TableItem('blue'),
        TableItem('green'),
    ]

    # simplest way
    table = Table(table_items, col_names=['Color'])
    tag = get_table_input(table)
    print('\ntag={}\n'.format(tag))

    # get value from table with specified default action (get values[0] - color name)
    table = Table(table_items,
                  col_names=['Color'],
                  default_action=TABLE_RETURN_FIRST_VAL,
                  prompt='Color? (Table prompt) ')
    color_str = get_table_input(table)
    print('\ncolor_str={}\n'.format(color_str))

    # custom action for default table action and on a table item (red)
    table_items[0] = TableItem('red', action=red_action)
    table = Table(table_items,
                  col_names=['Color'],
                  default_action=return_color_str_action,
Exemple #2
0
        '?': help_cmd,
        'help': help_cmd,
        'filter': ci.GetInputCommand(filter_cmd_action, cmd_dict=ad),
        'next': ci.GetInputCommand(ci.next_page_cmd_action),
        'prev': ci.GetInputCommand(ci.prev_page_cmd_action),
        'home': ci.GetInputCommand(ci.first_page_cmd_action),
        'end': ci.GetInputCommand(ci.last_page_cmd_action),
    }

    table = ci.Table(rows=tis,
                     col_names=col_names,
                     default_action=ci.TABLE_RETURN_FIRST_VAL,
                     item_filter=unicode_item_filter,
                     action_dict=ad,
                     add_exit=False,
                     commands=cmds)
    ad['table'] = table
    return table


if __name__ == '__main__':
    print('\nUnicode Picker... type "?" for help\n')
    table = make_table(0x00080, 0x007FF, cat_filter='**', name_filter='')
    result = ci.get_table_input(table)

    if USE_CLIPBOARD is True:  # put character on the clipboard
        pyperclip.copy(result)
        print('{} copied to the clipboard'.format(result))
    else:
        print('Unicode character={}'.format(result))