This repository has been archived on 2024-10-14. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
2022-01-15 21:00:39 +03:00
.github Update FUNDING.yml 2021-01-05 17:17:40 +03:00
docs/source/images Add files via upload 2022-01-15 21:00:39 +03:00
pykeyboard Add files via upload 2022-01-09 00:21:24 +03:00
.gitignore Update .gitignore 2020-06-10 06:24:18 +03:00
LICENSE Add files via upload 2020-06-11 01:04:30 +03:00
README.md Add files via upload 2022-01-09 00:21:24 +03:00
requirements.txt Add files via upload 2020-12-30 19:01:05 +03:00
setup.py Add files via upload 2022-01-09 00:21:24 +03:00

pykeyboard

PyPI Downloads GitHub

Pykeyboard

What's new?

  • Added a new method to InlineKeyboard for working with pagination. The InlinePaginationKeyboard class will be removed in a future version.
  • Overriding the KeyboardButton, ReplyKeyboardRemove, ForceReply, InlineKeyboardButton methods in ReplyButton, ReplyKeyboardRemove, ForceReply, InlineButton.

Installation

pip install pykeyboard

Documentation

Inline Keyboard

from pykeyboard import InlineKeyboard
Parameters:
  • row_width (integer, default 3)

Inline Keyboard add buttons

Code

from pykeyboard import InlineKeyboard, InlineButton


keyboard = InlineKeyboard(row_width=3)
keyboard.add(
    InlineButton('1', 'inline_keyboard:1'),
    InlineButton('2', 'inline_keyboard:2'),
    InlineButton('3', 'inline_keyboard:3'),
    InlineButton('4', 'inline_keyboard:4'),
    InlineButton('5', 'inline_keyboard:5'),
    InlineButton('6', 'inline_keyboard:6'),
    InlineButton('7', 'inline_keyboard:7')
)

Result

add_inline_button

Inline Keyboard row buttons

Code

from pykeyboard import InlineKeyboard, InlineButton


keyboard = InlineKeyboard()
keyboard.row(InlineButton('1', 'inline_keyboard:1'))
keyboard.row(
    InlineButton('2', 'inline_keyboard:2'),
    InlineButton('3', 'inline_keyboard:3')
)
keyboard.row(InlineButton('4', 'inline_keyboard:4'))
keyboard.row(
    InlineButton('5', 'inline_keyboard:5'),
    InlineButton('6', 'inline_keyboard:6')
)

Result

row_inline_button

Pagination inline keyboard

from pykeyboard import InlineKeyboard

Parameters:

  • count_pages (integer)
  • current_page (integer)
  • callback_pattern (string) - use of the {number} pattern is required

Pagination 3 pages

Code

from pykeyboard import InlineKeyboard

keyboard = InlineKeyboard()
keyboard.paginate(3, 3, 'pagination_keyboard:{number}')

Result

pagination_keyboard_3

Pagination 5 pages

Code

from pykeyboard import InlineKeyboard

keyboard = InlineKeyboard()
keyboard.paginate(5, 3, 'pagination_keyboard:{number}')

Result

pagination_keyboard_5

Pagination 9 pages

Code

from pykeyboard import InlineKeyboard

keyboard = InlineKeyboard()
keyboard.paginate(9, 5, 'pagination_keyboard:{number}')

Result

pagination_keyboard_9

Pagination 100 pages

Code

from pykeyboard import InlineKeyboard

keyboard = InlineKeyboard()
keyboard.paginate(100, 100, 'pagination_keyboard:{number}')

Result

pagination_keyboard_100

Pagination 150 pages and buttons

Code

from pykeyboard import InlineKeyboard, InlineButton

keyboard = InlineKeyboard()
keyboard.paginate(150, 123, 'pagination_keyboard:{number}')
keyboard.row(
    InlineButton('Back', 'pagination_keyboard:back'),
    InlineButton('Close', 'pagination_keyboard:close')
)

Result

pagination_keyboard_150

Reply Keyboard

from pykeyboard import ReplyKeyboard

Parameters:

  • resize_keyboard (bool, optional)
  • one_time_keyboard (bool, optional)
  • selective (bool, optional)
  • row_width (integer, default 3)

Reply Keyboard add buttons

Code

from pykeyboard import ReplyKeyboard, ReplyButton


keyboard = ReplyKeyboard(row_width=3)
keyboard.add(
    ReplyButton('Reply button 1'),
    ReplyButton('Reply button 2'),
    ReplyButton('Reply button 3'),
    ReplyButton('Reply button 4'),
    ReplyButton('Reply button 5')
)

Result

add_reply_button

Reply Keyboard row buttons

Code

from pykeyboard import ReplyKeyboard, ReplyButton


keyboard = ReplyKeyboard()
keyboard.row(ReplyButton('Reply button 1'))
keyboard.row(
    ReplyButton('Reply button 2'),
    ReplyButton('Reply button 3')
)
keyboard.row(ReplyButton('Reply button 4'))
keyboard.row(ReplyButton('Reply button 5'))

Result

row_reply_button