aiogram-widgets


Nameaiogram-widgets JSON
Version 1.2.6 PyPI version JSON
download
home_page
SummaryCreate most popular widgets for aiogram 3 in few code lines
upload_time2023-12-11 22:44:25
maintainer
docs_urlNone
authorggindinson
requires_python>=3.9,<4.0
license
keywords aiogram telegram api pagination calendar checkbox multiselect templates
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

## aiogram_widgets


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

## 🔗 Links

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) 
[![Github](https://img.shields.io/github/stars/ggindinson?label=GitHub%20Repo&style=social)](https://github.com/ggindinson/aiogram_widgets)
[![PyPI - Package](https://img.shields.io/pypi/v/aiogram_widgets)](https://pypi.org/project/aiogram-widgets/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/aiogram_widgets)](https://pypistats.org/packages/aiogram-widgets)

# Features

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


# Roadmap

- Checkboxes and multiselect

- Calendar

- Aiogram 2x support


# Changelog

`Version 1.2.6:`
- Fixed a bug that caused uncompability in python version 3.10 and lower


`Version 1.2.5:`
- Pagination key is automatically unique now
- 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` 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:

```bash
pip install aiogram_widgets
```

Poetry:

```bash
poetry add aiogram_widgets
```


# 🤖 [Bot example](https://t.me/aiogram_widgets_demo_bot) | [Bot source code](https://github.com/ggindinson/aiogram_widgets/blob/main/example.py) ⚙️
![](https://raw.githubusercontent.com/ggindinson/aiogram_widgets/main/demo.gif)




# Usage/Examples



## Simple keyboard pagination

```python
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)
```python
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)
``` python
@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
```python
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

```python
@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 ⭐️

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "aiogram-widgets",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "aiogram,telegram api,pagination,calendar,checkbox,multiselect,templates",
    "author": "ggindinson",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/08/3a/52e6a55527cd807ed3f928a87ea1aa3e5044f7a99283a8f222f0476644f8/aiogram_widgets-1.2.6.tar.gz",
    "platform": null,
    "description": "\n\n## aiogram_widgets\n\n\nCreate most popular widgets for aiogram 3x in a few code lines \n\n## \ud83d\udd17 Links\n\n[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) \n[![Github](https://img.shields.io/github/stars/ggindinson?label=GitHub%20Repo&style=social)](https://github.com/ggindinson/aiogram_widgets)\n[![PyPI - Package](https://img.shields.io/pypi/v/aiogram_widgets)](https://pypi.org/project/aiogram-widgets/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/aiogram_widgets)](https://pypistats.org/packages/aiogram-widgets)\n\n# Features\n\n- Fully customizable widgets \n- Stateless\n- Automatic handling\n- Supports aiogram ^3.0.0b1\n\n\n# Roadmap\n\n- Checkboxes and multiselect\n\n- Calendar\n\n- Aiogram 2x support\n\n\n# Changelog\n\n`Version 1.2.6:`\n- Fixed a bug that caused uncompability in python version 3.10 and lower\n\n\n`Version 1.2.5:`\n- Pagination key is automatically unique now\n- Added the ability to adjust buttons passing tuple of sizes (works the similar way as in InlineKeyboardBuilder.adjust) in keyboard pagination\n\n\n`Version 1.2.4:`\n- Fixed aiogram dependency bug\n\n`Version 1.2.3:`\n- Fixed typings at Python 3.9\n- `pagination_key` now is not required\n- Better types naming\n\n`Version 1.2.2:`\n- Custom pagination keyboard support\n- Aiogram 3.0.0b8 support\n- README with more examples\n- Live bot example with source code\n- Better types naming\n\n\n## Installation\n\nPip:\n\n```bash\npip install aiogram_widgets\n```\n\nPoetry:\n\n```bash\npoetry add aiogram_widgets\n```\n\n\n# \ud83e\udd16 [Bot example](https://t.me/aiogram_widgets_demo_bot) | [Bot source code](https://github.com/ggindinson/aiogram_widgets/blob/main/example.py) \u2699\ufe0f\n![](https://raw.githubusercontent.com/ggindinson/aiogram_widgets/main/demo.gif)\n\n\n\n\n# Usage/Examples\n\n\n\n## Simple keyboard pagination\n\n```python\nfrom aiogram_widgets.pagination import KeyboardPaginator\n\n@router.message(F.text == \"/keyboard_pagination\")\nasync def keyboard_pagination(message: Message):\n    buttons = [\n        InlineKeyboardButton(text=f\"Button {i}\", callback_data=f\"button_{i}\")\n        for i in range(1, 1001)\n    ]\n    paginator = KeyboardPaginator(\n        data=buttons,\n        per_page=20,\n        per_row=2\n    )\n\n\n    await message.answer(text=\"Keyboard pagination\", reply_markup=paginator.as_markup())\n\n```\n## Keyboard pagination with additional buttons (Same with text pagination)\n```python\nfrom aiogram_widgets.pagination import KeyboardPaginator\n\n@router.message(F.text == \"/kb_additional_buttons\")\nasync def kb_additional_buttons(message: Message):\n    buttons = [\n        InlineKeyboardButton(text=f\"Button {i}\", callback_data=f\"button_{i}\")\n        for i in range(1, 1001)\n    ]\n    additional_buttons = [\n        [\n            InlineKeyboardButton(text=\"Go back \ud83d\udd19\", callback_data=\"go_back\"),\n        ]\n    ]\n    \n    paginator = KeyboardPaginator(\n        data=buttons,\n        additional_buttons=additional_buttons,    \n        per_page=20, \n        per_row=2\n    )\n\n    await message.answer(\n        text=\"Keyboard pagination with additional buttons\",\n        reply_markup=paginator.as_markup(),\n    )\n\n```\n## Keyboard pagination with custom pagination buttons (Same with text pagination)\n``` python\n@router.message(F.text == \"/kb_custom_pagination\")\nasync def kb_custom_pagination(message: Message):\n    text_data = [f\"I am string number {i}\" for i in range(1, 1001)]\n    pagination_buttons = [\n        None, \"<-\", \"->\", None\n    ]\n\n    paginator = TextPaginator(\n        data=text_data,\n        pagination_buttons=pagination_buttons,\n    )\n\n    current_text_chunk, reply_markup = paginator.current_message_data\n\n    await message.answer(\n        text=current_text_chunk,\n        reply_markup=reply_markup,\n    )\n\n```\n\n## Simple text pagination\n```python\nfrom aiogram_widgets.pagination import TextPaginator\n\n\n@router.message(F.text == \"/text_pagination\")\nasync def text_pagination(message: Message):\n    text_data = [\n        f\"I am string number {i}\"\n        for i in range(1, 1001)\n    ]\n    \n    paginator = TextPaginator(\n        data=text_data,\n    )\n\n    current_text_chunk, reply_markup = paginator.current_message_data\n\n    await message.answer(\n        text=current_text_chunk,\n        reply_markup=reply_markup,\n    )\n\n```\n\n\n## Text pagination with custom join\n\n```python\n@router.message(F.text == \"/text_join\")\nasync def text_custom_join(message: Message):\n    text_data = [f\"I am string number {i}\" for i in range(1, 1001)]\n\n    paginator = TextPaginator(\n        data=text_data,\n        join_symbol=\"\\n\\n\",\n    )\n    current_text_chunk, reply_markup = paginator.current_message_data\n\n    await message.answer(\n        text=current_text_chunk,\n        reply_markup=reply_markup,\n    )\n\n```\n\n# Feedback\n\nI would be very pleased for a star \u2b50\ufe0f\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Create most popular widgets for aiogram 3 in few code lines ",
    "version": "1.2.6",
    "project_urls": null,
    "split_keywords": [
        "aiogram",
        "telegram api",
        "pagination",
        "calendar",
        "checkbox",
        "multiselect",
        "templates"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d990f941033b5d44c6457fcca7dc0bf2ca25805841d28c3e6764cc27a6364106",
                "md5": "853afab47923d6d2a8bef71ceb247d76",
                "sha256": "3fcaca7b9ae2cc0d55335eeff0b628851f5bea64cfb5e3f9bc7f3229dec293da"
            },
            "downloads": -1,
            "filename": "aiogram_widgets-1.2.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "853afab47923d6d2a8bef71ceb247d76",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 9010,
            "upload_time": "2023-12-11T22:44:24",
            "upload_time_iso_8601": "2023-12-11T22:44:24.726933Z",
            "url": "https://files.pythonhosted.org/packages/d9/90/f941033b5d44c6457fcca7dc0bf2ca25805841d28c3e6764cc27a6364106/aiogram_widgets-1.2.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "083a52e6a55527cd807ed3f928a87ea1aa3e5044f7a99283a8f222f0476644f8",
                "md5": "5ac9821c3267e1589aba828e1bd50317",
                "sha256": "14ecd91c690155bd4b42a5eaaf43bf4e487bbf5ad9c935aa8730953d3112b6cb"
            },
            "downloads": -1,
            "filename": "aiogram_widgets-1.2.6.tar.gz",
            "has_sig": false,
            "md5_digest": "5ac9821c3267e1589aba828e1bd50317",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 6410,
            "upload_time": "2023-12-11T22:44:25",
            "upload_time_iso_8601": "2023-12-11T22:44:25.860100Z",
            "url": "https://files.pythonhosted.org/packages/08/3a/52e6a55527cd807ed3f928a87ea1aa3e5044f7a99283a8f222f0476644f8/aiogram_widgets-1.2.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-11 22:44:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "aiogram-widgets"
}
        
Elapsed time: 0.30060s