Inline pagination for aiogram 2.25.2
Project description
AiogramPaginationInline 2.25.2
Description
A simple library for aiogram 2.25.2 that allows you to easily do pagination for any Inline keyboards.
Install for pip:
pip install aiogram2252-page
Create paginations object
from aiogram2252_page.paginator import Paginator
from aiogram import types
kb = types.InlineKeyboardMarkup()
paginator = Paginator(data=kb, size=5)
Params
data: Any ready-to-use keyboard InlineKeyboardMarkup or any iterable object with InlineKeyboardButton.
size: The number of rows of buttons on one page, excluding the navigation bar.
Return
A paginator object that, when called, returns a ready-made keyboard with pagination.
Get data for registrations handler paginator
from aiogram2252_page.paginator import Paginator
from aiogram import types
kb = types.InlineKeyboardMarkup()
paginator = Paginator(data=kb, size=5)
@dp.message_handler()
async def some_func(message: types.Message):
await message.answer(
text='Pagination ',
reply_markup=paginator()
)
Return paginator_handler()
Data for registrations paginator.
Example
import random
from aiogram import Bot, Dispatcher, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher.filters import CommandStart
from aiogram.utils.executor import Executor
from aiogram2252_page.paginator import Paginator
token = ''
storage = MemoryStorage()
bot = Bot(token=token)
dp = Dispatcher(bot, storage=storage)
@dp.message_handler(CommandStart(), state='*')
async def start(message: types.Message):
await message.answer('Hello world!')
'''row_width - this parameter indicates the number of columns in the pagination'''
kb = types.InlineKeyboardMarkup(row_width=2)
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data='pass'
) for i in range(100)
]
)
'''size is a parameter that indicates the number of rows in a column'''
paginator = Paginator(data=kb, size=5, dp=dp, callback_startswith="page:")
await message.answer(
text='Paginator',
reply_markup=paginator()
)
if __name__ == '__main__':
Executor(dp).start_polling()
Screenshots
First page:
Second page:
Last page:
Clicking on the current page number returns to the first page
The order of entries is not lost.
License MIT
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
Built Distribution
File details
Details for the file aiogram2252_page-0.0.4.tar.gz
.
File metadata
- Download URL: aiogram2252_page-0.0.4.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cd5810ef7d955d37a035e41a125c2ad6920c3dd537ba17146bea70249af0a2d |
|
MD5 | de3ca39d1b9e6322db0640d9fdbbec8a |
|
BLAKE2b-256 | 2e7cc9ca2d9bde945f95d6c04af2999f480f23f651725243caadc4af7520f81f |
File details
Details for the file aiogram2252_page-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: aiogram2252_page-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abe2257aaee79a765545b69ef33e5a001e46e07f9643e9202cdadde70096ffdc |
|
MD5 | 76007de2f110445df79854330ca974dd |
|
BLAKE2b-256 | 80f6ee13085f37a1b5425619a4124baa7a25affc3cc2604a326179ef697a4f45 |