Skip to main content

Best Keyboard and Pagination for the Pyrogram Library.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykeyboard-0.1.3.tar.gz (5.2 kB view details)

Uploaded Source

File details

Details for the file pykeyboard-0.1.3.tar.gz.

File metadata

  • Download URL: pykeyboard-0.1.3.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for pykeyboard-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3b82f0b91c3cfb7a803191c48e93e8f325d5027837fe79e83d54a619a0d00eb5
MD5 0538f58a99c5b4f87b714f4dc1517980
BLAKE2b-256 6967e453104e878b90dfff5b29624eb8e3acd21cd5b74719e1d146b87e232099

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page