Button
Button
¶
Bases: Static
A simple clickable button.
ACTIVE_EFFECT_DURATION
class-attribute
¶
When buttons are clicked they get the -active
class for this duration (in seconds)
Pressed
¶
__init__(label=None, variant='default', *, name=None, id=None, classes=None, disabled=False)
¶
Create a Button widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
TextType | None
|
The text that appears within the button. |
None
|
variant |
ButtonVariant
|
The variant of the button. |
'default'
|
name |
str | None
|
The name of the button. |
None
|
id |
str | None
|
The ID of the button in the DOM. |
None
|
classes |
str | None
|
The CSS classes of the button. |
None
|
disabled |
bool
|
Whether the button is disabled or not. |
False
|
error(label=None, *, name=None, id=None, classes=None, disabled=False)
classmethod
¶
Utility constructor for creating an error Button variant.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
TextType | None
|
The text that appears within the button. |
None
|
disabled |
bool
|
Whether the button is disabled or not. |
False
|
name |
str | None
|
The name of the button. |
None
|
id |
str | None
|
The ID of the button in the DOM. |
None
|
classes |
str | None
|
The CSS classes of the button. |
None
|
disabled |
bool
|
Whether the button is disabled or not. |
False
|
Returns:
Type | Description |
---|---|
Button
|
A Button widget of the 'error' variant. |
press()
¶
Respond to a button press.
success(label=None, *, name=None, id=None, classes=None, disabled=False)
classmethod
¶
Utility constructor for creating a success Button variant.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
TextType | None
|
The text that appears within the button. |
None
|
disabled |
bool
|
Whether the button is disabled or not. |
False
|
name |
str | None
|
The name of the button. |
None
|
id |
str | None
|
The ID of the button in the DOM. |
None
|
classes |
str | None
|
The CSS classes of the button. |
None
|
disabled |
bool
|
Whether the button is disabled or not. |
False
|
Returns:
Type | Description |
---|---|
Button
|
A Button widget of the 'success' variant. |
validate_label(label)
¶
Parse markup for self.label
warning(label=None, *, name=None, id=None, classes=None, disabled=False)
classmethod
¶
Utility constructor for creating a warning Button variant.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
TextType | None
|
The text that appears within the button. |
None
|
disabled |
bool
|
Whether the button is disabled or not. |
False
|
name |
str | None
|
The name of the button. |
None
|
id |
str | None
|
The ID of the button in the DOM. |
None
|
classes |
str | None
|
The CSS classes of the button. |
None
|
disabled |
bool
|
Whether the button is disabled or not. |
False
|
Returns:
Type | Description |
---|---|
Button
|
A Button widget of the 'warning' variant. |