UI¶
Keyboard¶
Keyboard
¶
Bases: UIBuilder
Генерирует клавиатуру на основе переданных кнопок.
Чтобы добавить новый ряд, передайте Ellipsis (три точки)
вместо кнопки. Клавиатуру можно создать и в другом стиле:
вызывая .add() для каждой новой кнопки и .new_line()
для перехода на следующий ряд
Настройки one_time и inline передаются при самой инициализации
Объект можно напрямую передать в поле keyboard
при отправке сообщения
Source code in vkflow\ui\keyboard.py
empty
staticmethod
¶
add
¶
Добавляет в клавиатуру кнопку
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
button
|
InitializedButton
|
Кнопка, которую надо добавить |
required |
Returns:
| Type | Description |
|---|---|
Keyboard
|
Текущая клавиатура |
Source code in vkflow\ui\keyboard.py
new_line
¶
Добавляет новый ряд клавиатуре
Source code in vkflow\ui\keyboard.py
add_button
¶
Добавляет кнопку в клавиатуру
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
Текст кнопки (для text кнопок) |
None
|
color
|
str
|
Цвет кнопки (positive, negative, primary, secondary) |
'secondary'
|
in_row
|
bool
|
Находится ли в строке с другими кнопками или занимает всю строку |
True
|
button
|
InitializedButton | None
|
Готовая кнопка (если передана, text и color игнорируются) |
None
|
**kwargs
|
Any
|
Дополнительные параметры для кнопки (payload и т.п.) |
{}
|
Returns:
| Type | Description |
|---|---|
Keyboard
|
Текущая клавиатура |
Source code in vkflow\ui\keyboard.py
View¶
View
¶
Interactive view with callback buttons.
Supports optional FSM integration via fsm_storage class attribute. When set, button callbacks can receive an 'fsm' parameter that will be automatically injected with FSMContext.
Examples:
Basic view (no FSM)¶
class MyView(View): @button(label="Click me") async def click(self, ctx): await ctx.show_snackbar("Clicked!")
View with FSM¶
class OrderView(View): fsm_storage = my_storage # Set FSM storage
@button(label="Confirm")
async def confirm(self, ctx, fsm):
data = await fsm.finish()
await ctx.show_snackbar(f"Order: {data}")
Source code in vkflow\ui\view.py
get_fsm
¶
Get FSMContext for an interaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interaction
|
CallbackButtonPressed
|
The callback button interaction |
required |
Returns:
| Type | Description |
|---|---|
Any
|
FSMContext instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fsm_storage is not configured |
Source code in vkflow\ui\view.py
Button¶
Button
¶
InteractiveButton¶
InteractiveButton
¶
Bases: InitializedButton
Source code in vkflow\ui\interactive_button.py
Carousel¶
Carousel
¶
Element¶
Element
¶
Bases: UIBuilder
Source code in vkflow\ui\carousel.py
ButtonColor¶
ButtonColor
¶
Bases: StrEnum
ButtonType¶
ButtonType
¶
Bases: StrEnum