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
2020-12-30 18:01:05 +02:00
# What's new?
- Added a new method to < b > InlineKeyboard</ b > for working with < ins > pagination</ ins > . The < b > InlinePaginationKeyboard</ b > class will be removed in a future version.
# 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
from pykeyboard import InlineKeyboard
2020-09-06 21:15:00 +03:00
from pyrogram.types import InlineKeyboardButton
2020-06-11 01:04:30 +03:00
keyboard = InlineKeyboard(row_width=3)
keyboard.add(
InlineKeyboardButton('1', 'inline_keyboard#1'),
InlineKeyboardButton('2', 'inline_keyboard#2'),
InlineKeyboardButton('3', 'inline_keyboard#3'),
InlineKeyboardButton('4', 'inline_keyboard#4'),
InlineKeyboardButton('5', 'inline_keyboard#5'),
InlineKeyboardButton('6', 'inline_keyboard#6'),
InlineKeyboardButton('7', 'inline_keyboard#7')
)
```
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
from pykeyboard import InlineKeyboard
2020-09-06 21:15:00 +03:00
from pyrogram.types import InlineKeyboardButton
2020-06-11 01:04:30 +03:00
keyboard = InlineKeyboard()
keyboard.row(InlineKeyboardButton('1', 'inline_keyboard#1'))
keyboard.row(
InlineKeyboardButton('2', 'inline_keyboard#2'),
InlineKeyboardButton('3', 'inline_keyboard#3')
)
keyboard.row(InlineKeyboardButton('4', 'inline_keyboard#4'))
keyboard.row(
InlineKeyboardButton('5', 'inline_keyboard#5'),
InlineKeyboardButton('6', 'inline_keyboard#6')
)
```
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()
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()
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()
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()
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
2020-12-30 18:01:05 +02:00
from pykeyboard import InlineKeyboard
from pyrogram.types import InlineKeyboardButton
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = InlineKeyboard()
keyboard.paginate(150, 123, 'pagination_keyboard#{number}')
keyboard.row(
InlineKeyboardButton('Back', 'pagination_keyboard#back'),
InlineKeyboardButton('Close', 'pagination_keyboard#close')
)
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
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
2020-12-30 18:01:05 +02:00
from pykeyboard import ReplyKeyboard
from pyrogram.types import KeyboardButton
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = ReplyKeyboard(row_width=3)
keyboard.add(
KeyboardButton('1', 'reply_keyboard#1'),
KeyboardButton('2', 'reply_keyboard#2'),
KeyboardButton('3', 'reply_keyboard#3'),
KeyboardButton('4', 'reply_keyboard#4'),
KeyboardButton('5', 'reply_keyboard#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/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
2020-12-30 18:01:05 +02:00
from pykeyboard import ReplyKeyboard
from pyrogram.types import KeyboardButton
2020-06-11 01:04:30 +03:00
2020-12-30 18:01:05 +02:00
keyboard = ReplyKeyboard()
keyboard.row(KeyboardButton('1', 'reply_keyboard#1'))
2020-06-11 01:04:30 +03:00
keyboard.row(
2020-12-30 18:01:05 +02:00
KeyboardButton('2', 'reply_keyboard#2'),
KeyboardButton('3', 'reply_keyboard#3')
2020-06-11 01:04:30 +03:00
)
2020-12-30 18:01:05 +02:00
keyboard.row(KeyboardButton('4', 'reply_keyboard#4'))
keyboard.row(KeyboardButton('5', 'reply_keyboard#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 >