Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Makes a google style pagination line for a list of items.
In other words it builds a menu for navigation if you have a lot of search results or whatever list of anything
pip install ptb-menu-navigation
or if you are working with source code and use Poetry tool:
make install
from paginator import get_menu
Use get_menu
function to create a line of pages
from paginator import get_menu
from dataclasses import dataclass
# Define initial menu settings in the dataclass.
@dataclass
class Menu:
items_per_page: int = 10
pages_per_line: int = 3
navigation_signature: str = '±'
page_label: str = ' p. '
# Add the initial call of get_menu
def handling_input(update, context):
# ...
# On first invocation
navigation = get_menu(total_items=len(search_results),
current_page=1,
menu_settings=Menu)
# ...
# Add a callback to handle a page switching
def navigate(update, context):
# ...
navigation = get_menu(total_items=len(search_results),
current_page=int(current_page),
menu_settings=Menu)
# ...
where search_results
is a list of strings and current_page
is a number extracted from a callback_data
.
See examples/search_bot.py
Create a .env
file with a TOKEN
variable
inside of an /examples
for launching
the
demo bot.
eg:
TOKEN=<YOUR_TELEGRAM_BOT_TOKEN_FROM_BOT_FATHER>
You may also provide some additional menu values in the same .env
file:
ITEMS_PER_PAGE=1
PAGES_PER_LINE=1
NAVIGATION_SIGNATURE="±"
PAGE_LABEL=" p. "
FAQs
Creates google-like navigation menu using python-telegram-bot wrapper
We found that ptb-menu-pagination demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.