2020-06-11 19:15:03 +03:00
< div align = "center" >
2020-06-11 19:11:39 +03:00
< p align = "center" >
2020-12-30 18:01:05 +02:00
< img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/logo.png" alt = "pykeyboard" >
2020-06-11 19:11:39 +03:00
< / p >
2020-06-11 19:10:05 +03:00
![PyPI ](https://img.shields.io/pypi/v/pykeyboard )
[![Downloads ](https://pepy.tech/badge/pykeyboard )](https://pepy.tech/project/pykeyboard)
![GitHub ](https://img.shields.io/github/license/pystorage/pykeyboard )
2020-06-11 20:15:43 +03:00
2020-06-11 19:15:03 +03:00
< / div >
2020-06-11 01:04:30 +03:00
2021-02-15 18:26:16 +02:00
# Pykeyboard
- [<b>What's new?</b> ](#whats-new )
- [<b>Installation</b> ](#installation )
- [<b>Documentation</b> ](#documentation )
- [<b>Inline Keyboard</b> ](#inline-keyboard )
- [Inline Keyboard add buttons ](#inline-keyboard-add-buttons )
- [Inline Keyboard row buttons ](#inline-keyboard-row-buttons )
- [<b>Pagination inline keyboard</b> ](#pagination-inline-keyboard )
- [Pagination 3 pages ](#pagination-3-pages )
- [Pagination 5 pages ](#pagination-5-pages )
- [Pagination 9 pages ](#pagination-9-pages )
- [Pagination 100 pages ](#pagination-100-pages )
- [Pagination 150 pages and buttons ](#pagination-150-pages-and-buttons )
2022-01-15 20:55:59 +02:00
- [<b>Languages inline keyboard</b> ](#languages-inline-keyboard )
2021-02-15 18:26:16 +02:00
- [<b>Reply Keyboard</b> ](#reply-keyboard )
- [Reply Keyboard add buttons ](#reply-keyboard-add-buttons )
- [Reply Keyboard row buttons ](#reply-keyboard-row-buttons )
2020-12-30 18:01:05 +02:00
# What's new?
2022-01-15 20:55:59 +02:00
- Added a new method to < b > InlineKeyboard</ b > for working with < a href = "#pagination-inline-keyboard" >< ins > pagination</ ins ></ a > . The < b > InlinePaginationKeyboard</ b > class will be removed in a future version.
2022-01-08 23:21:24 +02:00
- Overriding the < b > KeyboardButton</ b > , < b > ReplyKeyboardRemove</ b > , < b > ForceReply</ b > , < b > InlineKeyboardButton</ b > methods in < b > ReplyButton</ b > , < b > ReplyKeyboardRemove</ b > , < b > ForceReply</ b > , < b > InlineButton</ b > .
2022-01-15 20:55:59 +02:00
- Added new method < b > InlineKeyboard</ b > . To send language < a href = "#languages-inline-keyboard" >< ins > selection keyboard</ ins ></ a > .
2020-12-30 18:01:05 +02:00
# Installation
2020-06-11 01:04:30 +03:00
```shell
pip install pykeyboard
```
2020-12-30 18:01:05 +02:00
# Documentation
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
## Inline Keyboard
2020-06-11 01:04:30 +03:00
```python
from pykeyboard import InlineKeyboard
```
2020-12-30 18:01:05 +02:00
##### Parameters:
2020-06-11 20:15:43 +03:00
- row_width (integer, default 3)
2020-12-30 18:01:05 +02:00
### Inline Keyboard add buttons
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2022-01-08 23:21:24 +02:00
from pykeyboard import InlineKeyboard, InlineButton
2020-06-11 01:04:30 +03:00
keyboard = InlineKeyboard(row_width=3)
keyboard.add(
2022-01-08 23:21:24 +02:00
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')
2020-06-11 01:04:30 +03:00
)
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 01:04:30 +03:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/add_inline_button.png" alt = "add_inline_button" > < / p >
2020-12-30 18:01:05 +02:00
### Inline Keyboard row buttons
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2022-01-08 23:21:24 +02:00
from pykeyboard import InlineKeyboard, InlineButton
2020-06-11 01:04:30 +03:00
keyboard = InlineKeyboard()
2022-01-08 23:21:24 +02:00
keyboard.row(InlineButton('1', 'inline_keyboard:1'))
2020-06-11 01:04:30 +03:00
keyboard.row(
2022-01-08 23:21:24 +02:00
InlineButton('2', 'inline_keyboard:2'),
InlineButton('3', 'inline_keyboard:3')
2020-06-11 01:04:30 +03:00
)
2022-01-08 23:21:24 +02:00
keyboard.row(InlineButton('4', 'inline_keyboard:4'))
2020-06-11 01:04:30 +03:00
keyboard.row(
2022-01-08 23:21:24 +02:00
InlineButton('5', 'inline_keyboard:5'),
InlineButton('6', 'inline_keyboard:6')
2020-06-11 01:04:30 +03:00
)
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 01:04:30 +03:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/row_inline_button.png" alt = "row_inline_button" > < / p >
2020-12-30 18:01:05 +02:00
### Pagination inline keyboard
2020-06-11 01:04:30 +03:00
```python
2020-12-30 18:01:05 +02:00
from pykeyboard import InlineKeyboard
2020-06-11 01:04:30 +03:00
```
2020-06-11 20:15:43 +03:00
#### Parameters:
2020-12-30 18:01:05 +02:00
- count_pages (integer)
- current_page (integer)
- callback_pattern (string) - use of the `{number}` pattern is < ins > required</ ins >
2020-06-11 20:15:43 +03:00
2020-12-30 18:01:05 +02:00
#### Pagination 3 pages
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2020-12-30 18:01:05 +02:00
from pykeyboard import InlineKeyboard
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = InlineKeyboard()
2022-01-08 23:21:24 +02:00
keyboard.paginate(3, 3, 'pagination_keyboard:{number}')
2020-06-11 01:04:30 +03:00
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/pagination_keyboard_3.png" alt = "pagination_keyboard_3" > < / p >
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Pagination 5 pages
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2020-12-30 18:01:05 +02:00
from pykeyboard import InlineKeyboard
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = InlineKeyboard()
2022-01-08 23:21:24 +02:00
keyboard.paginate(5, 3, 'pagination_keyboard:{number}')
2020-06-11 01:04:30 +03:00
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 20:15:43 +03:00
2020-12-30 18:01:05 +02:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/pagination_keyboard_5.png" alt = "pagination_keyboard_5" > < / p >
2020-06-11 20:15:43 +03:00
2020-12-30 18:01:05 +02:00
#### Pagination 9 pages
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2020-12-30 18:01:05 +02:00
from pykeyboard import InlineKeyboard
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = InlineKeyboard()
2022-01-08 23:21:24 +02:00
keyboard.paginate(9, 5, 'pagination_keyboard:{number}')
2020-06-11 01:04:30 +03:00
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/pagination_keyboard_9.png" alt = "pagination_keyboard_9" > < / p >
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Pagination 100 pages
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2020-12-30 18:01:05 +02:00
from pykeyboard import InlineKeyboard
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = InlineKeyboard()
2022-01-08 23:21:24 +02:00
keyboard.paginate(100, 100, 'pagination_keyboard:{number}')
2020-06-11 01:04:30 +03:00
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/pagination_keyboard_100.png" alt = "pagination_keyboard_100" > < / p >
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Pagination 150 pages and buttons
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2022-01-08 23:21:24 +02:00
from pykeyboard import InlineKeyboard, InlineButton
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = InlineKeyboard()
2022-01-08 23:21:24 +02:00
keyboard.paginate(150, 123, 'pagination_keyboard:{number}')
2020-12-30 18:01:05 +02:00
keyboard.row(
2022-01-08 23:21:24 +02:00
InlineButton('Back', 'pagination_keyboard:back'),
InlineButton('Close', 'pagination_keyboard:close')
2020-12-30 18:01:05 +02:00
)
2020-06-11 01:04:30 +03:00
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/pagination_keyboard_150.png" alt = "pagination_keyboard_150" > < / p >
2020-06-11 01:04:30 +03:00
2022-01-15 20:55:59 +02:00
### Languages inline keyboard
```python
from pykeyboard import InlineKeyboard
```
#### Parameters:
- callback_pattern (string) - use of the `{locale}` pattern is < ins > required</ ins >
- locales (string | list) - list of language codes
- be_BY - Belarusian
- de_DE - German
- zh_CN - Chinese
- en_US - English
- fr_FR - French
- id_ID - Indonesian
- it_IT - Italian
- ko_KR - Korean
- tr_TR - Turkish
- ru_RU - Russian
- es_ES - Spanish
- uk_UA - Ukrainian
- uz_UZ - Uzbek
- row_width (integer, default 2)
< p > P.S. To add new languages, write to me in < a href = "https://t.me/pymaster" > @PyMaster< / a > telegram.< / p >
#### Code
```python
from pykeyboard import InlineKeyboard
keyboard = InlineKeyboard(row_width=3)
keyboard.languages(
'languages:{locale}', ['en_US', 'ru_RU', 'id_ID'], 2
)
```
#### Result
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/languages_keyboard.png" alt = "languages_keyboard" > < / p >
2020-12-30 18:01:05 +02:00
## Reply Keyboard
2020-06-11 01:04:30 +03:00
```python
2020-12-30 18:01:05 +02:00
from pykeyboard import ReplyKeyboard
2020-06-11 01:04:30 +03:00
```
2020-12-30 18:01:05 +02:00
#### Parameters:
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
- resize_keyboard (bool, optional)
- one_time_keyboard (bool, optional)
- selective (bool, optional)
- row_width (integer, default 3)
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
### Reply Keyboard add buttons
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2022-01-08 23:21:24 +02:00
from pykeyboard import ReplyKeyboard, ReplyButton
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = ReplyKeyboard(row_width=3)
keyboard.add(
2022-01-08 23:21:24 +02:00
ReplyButton('Reply button 1'),
ReplyButton('Reply button 2'),
ReplyButton('Reply button 3'),
ReplyButton('Reply button 4'),
ReplyButton('Reply button 5')
2020-12-30 18:01:05 +02:00
)
2020-06-11 01:04:30 +03:00
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/add_reply_button.png" alt = "add_reply_button" > < / p >
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
### Reply Keyboard row buttons
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
#### Code
2020-06-11 01:04:30 +03:00
```python
2022-01-08 23:21:24 +02:00
from pykeyboard import ReplyKeyboard, ReplyButton
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = ReplyKeyboard()
2022-01-08 23:21:24 +02:00
keyboard.row(ReplyButton('Reply button 1'))
2020-06-11 01:04:30 +03:00
keyboard.row(
2022-01-08 23:21:24 +02:00
ReplyButton('Reply button 2'),
ReplyButton('Reply button 3')
2020-06-11 01:04:30 +03:00
)
2022-01-08 23:21:24 +02:00
keyboard.row(ReplyButton('Reply button 4'))
keyboard.row(ReplyButton('Reply button 5'))
2020-06-11 01:04:30 +03:00
```
2020-12-30 18:01:05 +02:00
#### Result
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
< p > < img src = "https://raw.githubusercontent.com/pystorage/pykeyboard/master/docs/source/images/row_reply_button.png" alt = "row_reply_button" > < / p >