Button¶
Pyglet-gui ships a standard button and two variations of it. A Button is a mixing of:
TwoStateController
Viewer
because it is a controllable viewer with two states (“is pressed” and “is not pressed”).
A
TwoStateController
andViewer
represented as a label and texture drawn on top of each other.Parameters: - label – The string written in the button.
- is_pressed – True if the button starts pressed
- on_press – A callback function of one argument called when the button is pressed (optional).
Attributes:
The label of the button (a string).
Accepted events:
Switches the state of the button.
-
[button, down], [button, up]:
default path in the theme.
A
Button
that changes back to its original state when the mouse is released.Parameters: - label – The string written in the button.
- on_release – A callback function of one argument called when the button is released (optional).
Accepted events:
Switches the state back and calls the callback if the mouse was released inside the button.
-
[button, down], [button, up]
default path in the theme.
- A button drawn as a checkbox icon with the label on the side.
Parameters: - label – A string written in the button graphics.
- is_pressed – True if the button starts pressed
- on_press – A callback function of one argument called when the button is pressed (optional).
- align – Whether the label is left or right of the checkbox.
- padding – The distance from the label to the checkbox.
-
['checkbox', 'checked'], ['checkbox', 'unchecked']
default path in the theme.
A
Button
that is focusable and thus can be selected with TAB.Parameters: - label – The string written in the button.
- is_pressed – True if the button starts pressed
- on_press – A callback function of one argument called when the button is pressed (optional).
Accepted events:
Switches the state of the button.
If the Button have focus and ENTER is pressed the state of the button is switched.
-
[button, down], [button, up]
default path in the theme.