Utilities¶
Utility functions for creating and inspecting keyboards from configuration dicts.
Importable from pykeyboard.utils.
create_keyboard_from_config function¶
Create a keyboard from a configuration dictionary.
Config Keys¶
| Key | Type | Default | Description |
|---|---|---|---|
type | str | "inline" | "inline" or "reply" |
row_width | int | — | Buttons per row |
buttons | list | [] | Button configs (dicts or plain strings) |
Raises
ValueError — if type is not "inline" or "reply"
Usage
get_keyboard_info function¶
Get comprehensive metadata about a keyboard.
Return Fields¶
| Key | Type | Description |
|---|---|---|
type | str | Class name |
row_width | int | Row width |
total_buttons | int | Total buttons |
total_rows | int | Number of rows |
| Key | Type | Description |
|---|---|---|
has_pagination | bool | Has pagination |
current_page | int | Current page |
total_pages | int | Total pages |
callback_pattern | str | Callback pattern |
custom_locales_count | int | Custom locales count |
| Key | Type | Description |
|---|---|---|
is_persistent | bool | Persistent keyboard |
resize_keyboard | bool | Auto-resize |
one_time_keyboard | bool | One-time use |
selective | bool | Selective display |
placeholder | str | Input placeholder |
Usage
validate_keyboard_config function¶
Validate a configuration dict before creating a keyboard.
Returns: List of error messages (empty if valid).