Form
endstone.form
¶
Classes:
| Name | Description |
|---|---|
ActionForm |
Represents a form with buttons that let the player take action. |
Button |
Represents a button with text and an optional icon. |
Divider |
Represents a divider. |
Dropdown |
Represents a dropdown with a set of predefined options. |
Header |
Represents a header with a label. |
Label |
Represents a text label. |
MessageForm |
Represents a form with two buttons. |
ModalForm |
Represents a modal form with controls. |
Slider |
Represents a slider with a label. |
StepSlider |
Represents a step slider with a set of predefined options. |
TextInput |
Represents a text input field. |
Toggle |
Represents a toggle button with a label. |
ActionForm
¶
ActionForm(
title: str | Translatable = "",
content: str | Translatable = "",
buttons: (
list[Button | Divider | Header | Label] | None
) = None,
on_submit: Callable[[Player, int], None] | None = None,
on_close: Callable[[Player], None] | None = None,
)
Represents a form with buttons that let the player take action.
Methods:
| Name | Description |
|---|---|
add_button |
Adds a button to the form. |
add_divider |
Adds a divider to the form. |
add_header |
Adds a header to the form. |
add_label |
Adds a label to the form. |
Attributes:
| Name | Type | Description |
|---|---|---|
content |
str | Translatable
|
The content of the form. |
controls |
list[Button | Divider | Header | Label]
|
The controls of the action form. |
on_close |
Callable[[Player], None]
|
The on close callback of the form. |
on_submit |
Callable[[Player, int], None]
|
The on submit callback of the form. |
title |
str | Translatable
|
The title of the form. |
controls
property
writable
¶
The controls of the action form.
on_submit
property
writable
¶
The on submit callback of the form.
add_button
¶
add_button(
text: str | Translatable,
icon: str | None = None,
on_click: Callable[[Player], None] | None = None,
) -> ActionForm
Adds a button to the form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | Translatable
|
The text of the button. |
required |
icon
|
str | None
|
The path or URL to the icon image. |
None
|
on_click
|
Callable[[Player], None] | None
|
The on click callback of the button. |
None
|
Returns:
| Type | Description |
|---|---|
ActionForm
|
A reference to the current form. |
add_divider
¶
add_divider() -> ActionForm
add_header
¶
add_header(text: str | Translatable) -> ActionForm
Adds a header to the form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | Translatable
|
The text of the header. |
required |
Returns:
| Type | Description |
|---|---|
ActionForm
|
A reference to the current form. |
add_label
¶
add_label(text: str | Translatable) -> ActionForm
Adds a label to the form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | Translatable
|
The text of the label. |
required |
Returns:
| Type | Description |
|---|---|
ActionForm
|
A reference to the current form. |
Button
¶
Button(
text: str | Translatable = "",
icon: str | None = None,
on_click: Callable[[Player], None] | None = None,
)
Dropdown
¶
Dropdown(
label: str | Translatable = "",
options: list[str] | None = None,
default_index: int | None = None,
)
Represents a dropdown with a set of predefined options.
Methods:
| Name | Description |
|---|---|
add_option |
Adds a new option to the dropdown. |
Attributes:
| Name | Type | Description |
|---|---|---|
default_index |
int | None
|
The optional default index of the dropdown. |
label |
str | Translatable
|
The label of the dropdown. |
options |
list[str]
|
The options of the dropdown. |
Header
¶
Header(label: str | Translatable = '')
Represents a header with a label.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str | Translatable
|
The label of the header. |
Label
¶
Label(text: str | Translatable = '')
Represents a text label.
Attributes:
| Name | Type | Description |
|---|---|---|
text |
str | Translatable
|
The text of the label. |
MessageForm
¶
MessageForm(
title: str | Translatable = "",
content: str | Translatable = "",
button1: str | Translatable = "",
button2: str | Translatable = "",
on_submit: Callable[[Player, int], None] | None = None,
on_close: Callable[[Player], None] | None = None,
)
Represents a form with two buttons.
Attributes:
| Name | Type | Description |
|---|---|---|
button1 |
str | Translatable
|
The text of button1. |
button2 |
str | Translatable
|
The text of button2. |
content |
str | Translatable
|
The content of the form. |
on_close |
Callable[[Player], None]
|
The on close callback of the form. |
on_submit |
Callable[[Player, int], None]
|
The on submit callback of the form. |
title |
str | Translatable
|
The title of the form. |
on_submit
property
writable
¶
The on submit callback of the form.
ModalForm
¶
ModalForm(
title: str | Translatable = "",
controls: (
list[
Dropdown
| Label
| Slider
| StepSlider
| TextInput
| Toggle
| Divider
| Header
]
| None
) = None,
submit_button: str | Translatable | None = None,
icon: str | None = None,
on_submit: Callable[[Player, str], None] | None = None,
on_close: Callable[[Player], None] | None = None,
)
Represents a modal form with controls.
Methods:
| Name | Description |
|---|---|
add_control |
Adds a control to the form. |
Attributes:
| Name | Type | Description |
|---|---|---|
controls |
list[Dropdown | Label | Slider | StepSlider | TextInput | Toggle | Divider | Header]
|
The controls of the modal form. |
icon |
str | None
|
The path or URL to the icon file. |
on_close |
Callable[[Player], None]
|
The on close callback of the form. |
on_submit |
Callable[[Player, str], None]
|
The on submit callback of the form. |
submit_button |
str | Translatable | None
|
The submit button text of the form. |
title |
str | Translatable
|
The title of the form. |
controls
property
writable
¶
The controls of the modal form.
on_submit
property
writable
¶
The on submit callback of the form.
submit_button
property
writable
¶
submit_button: str | Translatable | None
The submit button text of the form.
Slider
¶
Slider(
label: str | Translatable = "",
min: float = 0,
max: float = 100,
step: float = 20,
default_value: float | None = None,
)
Represents a slider with a label.
Attributes:
| Name | Type | Description |
|---|---|---|
default_value |
float | None
|
The optional default value of the slider. |
label |
str | Translatable
|
The label of the slider. |
max |
float
|
The maximum value of the slider. |
min |
float
|
The minimum value of the slider. |
step |
float
|
The step size of the slider. |
StepSlider
¶
StepSlider(
label: str | Translatable = "",
options: list[str] | None = None,
default_index: int | None = None,
)
Represents a step slider with a set of predefined options.
Methods:
| Name | Description |
|---|---|
add_option |
Adds a new option to the step slider. |
Attributes:
| Name | Type | Description |
|---|---|---|
default_index |
int | None
|
The optional default index of the step slider. |
label |
str | Translatable
|
The label of the step slider. |
options |
list[str]
|
The options of the step slider. |
TextInput
¶
TextInput(
label: str | Translatable = "",
placeholder: str | Translatable = "",
default_value: str | None = None,
)
Represents a text input field.
Attributes:
| Name | Type | Description |
|---|---|---|
default_value |
str | None
|
The optional default text of the text input field. |
label |
str | Translatable
|
The label of the text input field. |
placeholder |
str | Translatable
|
The placeholder of the text input field. |
default_value
property
writable
¶
default_value: str | None
The optional default text of the text input field.
placeholder
property
writable
¶
placeholder: str | Translatable
The placeholder of the text input field.
Toggle
¶
Toggle(
label: str | Translatable = "",
default_value: bool = False,
)
Represents a toggle button with a label.
Attributes:
| Name | Type | Description |
|---|---|---|
default_value |
bool
|
The default value of the toggle. |
label |
str | Translatable
|
The label of the toggle. |