wx.ToggleButton is a button that stays pressed when clicked by the user.
In other words, it is similar to wx.CheckBox in functionality but looks like a wx.Button.
Since wxWidgets version 2.9.0 this control emits an update UI event.
You can see wx.ToggleButton in action in Widgets Sample.
^^
Handlers bound for the following event types will receive a wx.CommandEvent parameter.
EVT_TOGGLEBUTTON: Handles a wxEVT_TOGGLEBUTTON event. ^^
Default constructor. |
|
Creates the toggle button for two-step construction. |
|
Gets the state of the toggle button. |
|
Sets the toggle button to the given state. |
wx.
ToggleButton
(AnyButton)¶Possible constructors:
ToggleButton() -> None
ToggleButton(parent : Window, id: int=ID_ANY, label: str='', pos:
Point=DefaultPosition, size: Size=DefaultSize, style: int=0, val:
Validator=DefaultValidator, name: str=CheckBoxNameStr) -> None
ToggleButton is a button that stays pressed when clicked by the user.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
None
__init__ (self, parent : Window, id: int=ID_ANY, label: str=’’, pos: Point=DefaultPosition, size: Size=DefaultSize, style: int=0, val: Validator=DefaultValidator, name: str=CheckBoxNameStr)
Constructor, creating and showing a toggle button.
parent (wx.Window) – Parent window. Must not be None
.
id (wx.WindowID) – Toggle button identifier. The value wx.ID_ANY
indicates a default value.
label (string) – Text to be displayed next to the toggle button.
pos (wx.Point) – Toggle button position. If wx.DefaultPosition
is specified then a default position is chosen.
size (wx.Size) – Toggle button size. If wx.DefaultSize
is specified then a default size is chosen.
style (long) – Window style. See wx.ToggleButton.
val (wx.Validator) – Window validator.
name (string) – Window name.
None
Create
(self, parent : Window, id: int=ID_ANY, label: str='', pos: Point=DefaultPosition, size: Size=DefaultSize, style: int=0, val: Validator=DefaultValidator, name: str=CheckBoxNameStr)¶Creates the toggle button for two-step construction.
See wx.ToggleButton for details.
parent (wx.Window) –
id (wx.WindowID) –
label (string) –
pos (wx.Point) –
size (wx.Size) –
style (long) –
val (wx.Validator) –
name (string) –
bool
GetClassDefaultAttributes
(variant: WindowVariant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
GetValue
(self)¶Gets the state of the toggle button.
bool
Returns True
if it is pressed, False
otherwise.
SetValue
(self, state : bool)¶Sets the toggle button to the given state.
This does not cause a EVT_TOGGLEBUTTON
event to be emitted.
state (bool) – If True
, the button is pressed.
None