Skip to main content

aiogram_widgets

Create most popular widgets for aiogram 3x in a few code lines

🔗 Links

MIT License Github PyPI - Package PyPI - Downloads

Features

  • Fully customizable widgets
  • Stateless
  • Automatic handling
  • Supports aiogram ^3.0.0b1

Roadmap

  • Checkboxes and multiselect

  • Calendar

  • Aiogram 2x support

Changelog

Version 1.2.7:

  • Fixed a bug that still required pagination_key option

Version 1.2.6:

  • Fixed a bug that caused uncompability in python versions 3.10 and lower

Version 1.2.5:

  • Added the ability to adjust buttons passing tuple of sizes (works the similar way as in InlineKeyboardBuilder.adjust) in keyboard pagination

Version 1.2.4:

  • Fixed aiogram dependency bug

Version 1.2.3:

  • Fixed typings at Python 3.9
  • pagination_key option now is not required
  • Better types naming

Version 1.2.2:

  • Custom pagination keyboard support
  • Aiogram 3.0.0b8 support
  • README with more examples
  • Live bot example with source code
  • Better types naming

Installation

Pip:

pip install aiogram_widgets

Poetry:

poetry add aiogram_widgets

🤖 Bot example | Bot source code ⚙️

Usage/Examples

Simple keyboard pagination

from aiogram_widgets.pagination import KeyboardPaginator

@router.message(F.text == "/keyboard_pagination")
async def keyboard_pagination(message: Message):
    buttons = [
        InlineKeyboardButton(text=f"Button {i}", callback_data=f"button_{i}")
        for i in range(1, 1001)
    ]
    paginator = KeyboardPaginator(
        data=buttons,
        per_page=20,
        per_row=2
    )


    await message.answer(text="Keyboard pagination", reply_markup=paginator.as_markup())

Keyboard pagination with additional buttons (Same with text pagination)

from aiogram_widgets.pagination import KeyboardPaginator

@router.message(F.text == "/kb_additional_buttons")
async def kb_additional_buttons(message: Message):
    buttons = [
        InlineKeyboardButton(text=f"Button {i}", callback_data=f"button_{i}")
        for i in range(1, 1001)
    ]
    additional_buttons = [
        [
            InlineKeyboardButton(text="Go back 🔙", callback_data="go_back"),
        ]
    ]
    
    paginator = KeyboardPaginator(
        data=buttons,
        additional_buttons=additional_buttons,    
        per_page=20, 
        per_row=2
    )

    await message.answer(
        text="Keyboard pagination with additional buttons",
        reply_markup=paginator.as_markup(),
    )

Keyboard pagination with custom pagination buttons (Same with text pagination)

@router.message(F.text == "/kb_custom_pagination")
async def kb_custom_pagination(message: Message):
    text_data = [f"I am string number {i}" for i in range(1, 1001)]
    pagination_buttons = [
        None, "<-", "->", None
    ]

    paginator = TextPaginator(
        data=text_data,
        pagination_buttons=pagination_buttons,
    )

    current_text_chunk, reply_markup = paginator.current_message_data

    await message.answer(
        text=current_text_chunk,
        reply_markup=reply_markup,
    )

Simple text pagination

from aiogram_widgets.pagination import TextPaginator


@router.message(F.text == "/text_pagination")
async def text_pagination(message: Message):
    text_data = [
        f"I am string number {i}"
        for i in range(1, 1001)
    ]
    
    paginator = TextPaginator(
        data=text_data,
    )

    current_text_chunk, reply_markup = paginator.current_message_data

    await message.answer(
        text=current_text_chunk,
        reply_markup=reply_markup,
    )

Text pagination with custom join

@router.message(F.text == "/text_join")
async def text_custom_join(message: Message):
    text_data = [f"I am string number {i}" for i in range(1, 1001)]

    paginator = TextPaginator(
        data=text_data,
        join_symbol="\n\n",
    )
    current_text_chunk, reply_markup = paginator.current_message_data

    await message.answer(
        text=current_text_chunk,
        reply_markup=reply_markup,
    )

Feedback

I would be very pleased for a star ⭐️

Release files for aiogram-widgets 1.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiogram-widgets 1.2.7
File Size Uploaded
aiogram_widgets-1.2.7.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiogram-widgets 1.2.7
File Interpreter ABI Platform
aiogram_widgets-1.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 15.3 kB

Release files / aiogram_widgets-1.2.7.tar.gz

Download URL aiogram_widgets-1.2.7.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
af2c2daa6769986bda8a332be99bbfe870b4a232db26425300dd351abe9ad608
BLAKE2b-256 checksum
How to use checksums
496a366aa45de926269eac205bc37185aa4d3e06676c4fc1b330177ec64de93f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.2 Windows/10

Release files / aiogram_widgets-1.2.7-py3-none-any.whl

Download URL aiogram_widgets-1.2.7-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
432b3ce82e91345e802b0230665edc3b8392c12c3460b90fb4e7a2c92c301716
BLAKE2b-256 checksum
How to use checksums
a4c2819764dbe78a36fa0f1e065104d229a0d8ee78bcedd80668646e886d34bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.2 Windows/10

Release history Release notifications | RSS feed

This release

1.2.7 This release

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page