[MouseFox logo]
The MouseFox Project
Join The Community Discord Server
[Discord logo]
Edit on GitHub

kvex.widgets.checkbox

Home of XCheckBox.

 1"""Home of `XCheckBox`."""
 2
 3from .. import kivy as kv
 4from .. import util
 5from ..behaviors import XFocusBehavior
 6from .widget import XWidget
 7
 8
 9class XCheckBox(XFocusBehavior, XWidget, kv.CheckBox):
10    """CheckBox with focus."""
11
12    def __init__(self, *args, **kwargs):
13        """See class documentation for details."""
14        super().__init__(*args, **kwargs)
15        self.make_bg(source=util.from_atlas("button_disabled"))
16        self._kvex_bg_color.a = int(self.focus)
17
18    def toggle(self, *a):
19        """Toggle the active state."""
20        self.active = not self.active
21
22    def on_focus(self, w, focus):
23        """Set background alpha."""
24        self._kvex_bg_color.a = int(focus)
25
26    def keyboard_on_key_down(self, w, key_pair, text, mods):
27        """Implement toggling."""
28        keycode, key = key_pair
29        if key in {"enter", "numpadenter", "spacebar"}:
30            self.toggle()
31        return super().keyboard_on_key_down(w, key_pair, text, mods)
32
33
34__all__ = (
35    "XCheckBox",
36)
class XCheckBox(kvex.behaviors.XFocusBehavior, kvex.widgets.widget.XWidget, kivy.uix.checkbox.CheckBox):
10class XCheckBox(XFocusBehavior, XWidget, kv.CheckBox):
11    """CheckBox with focus."""
12
13    def __init__(self, *args, **kwargs):
14        """See class documentation for details."""
15        super().__init__(*args, **kwargs)
16        self.make_bg(source=util.from_atlas("button_disabled"))
17        self._kvex_bg_color.a = int(self.focus)
18
19    def toggle(self, *a):
20        """Toggle the active state."""
21        self.active = not self.active
22
23    def on_focus(self, w, focus):
24        """Set background alpha."""
25        self._kvex_bg_color.a = int(focus)
26
27    def keyboard_on_key_down(self, w, key_pair, text, mods):
28        """Implement toggling."""
29        keycode, key = key_pair
30        if key in {"enter", "numpadenter", "spacebar"}:
31            self.toggle()
32        return super().keyboard_on_key_down(w, key_pair, text, mods)

CheckBox with focus.

XCheckBox(*args, **kwargs)
13    def __init__(self, *args, **kwargs):
14        """See class documentation for details."""
15        super().__init__(*args, **kwargs)
16        self.make_bg(source=util.from_atlas("button_disabled"))
17        self._kvex_bg_color.a = int(self.focus)

See class documentation for details.

def toggle(self, *a):
19    def toggle(self, *a):
20        """Toggle the active state."""
21        self.active = not self.active

Toggle the active state.

def on_focus(self, w, focus):
23    def on_focus(self, w, focus):
24        """Set background alpha."""
25        self._kvex_bg_color.a = int(focus)

Set background alpha.

def keyboard_on_key_down(self, w, key_pair, text, mods):
27    def keyboard_on_key_down(self, w, key_pair, text, mods):
28        """Implement toggling."""
29        keycode, key = key_pair
30        if key in {"enter", "numpadenter", "spacebar"}:
31            self.toggle()
32        return super().keyboard_on_key_down(w, key_pair, text, mods)

Implement toggling.

Inherited Members
kivy.uix.behaviors.focus.FocusBehavior
ignored_touch
keyboard
is_focusable
focus
focused
keyboard_suggestions
focus_next
focus_previous
keyboard_mode
input_type
unfocus_on_touch
keyboard_on_textinput
on_touch_down
get_focus_next
get_focus_previous
show_keyboard
hide_keyboard
kivy.uix.checkbox.CheckBox
active
background_checkbox_normal
background_checkbox_down
background_checkbox_disabled_normal
background_checkbox_disabled_down
background_radio_normal
background_radio_down
background_radio_disabled_normal
background_radio_disabled_down
color
on_group
kivy.uix.behaviors.togglebutton.ToggleButtonBehavior
group
allow_no_selection
get_widgets
kivy.uix.behaviors.button.ButtonBehavior
state
last_touch
min_state_time
always_release
cancel_event
on_touch_move
on_touch_up
on_press
on_release
trigger_action
kivy.uix.widget.Widget
proxy_ref
apply_class_lang_rules
collide_point
collide_widget
on_motion
on_kv_post
add_widget
remove_widget
clear_widgets
register_for_motion_event
unregister_for_motion_event
export_to_png
export_as_image
get_root_window
get_parent_window
walk
walk_reverse
to_widget
to_window
to_parent
to_local
get_window_matrix
x
y
width
height
pos
size
get_right
set_right
right
get_top
set_top
top
get_center_x
set_center_x
center_x
get_center_y
set_center_y
center_y
center
cls
children
parent
size_hint_x
size_hint_y
size_hint
pos_hint
size_hint_min_x
size_hint_min_y
size_hint_min
size_hint_max_x
size_hint_max_y
size_hint_max
ids
opacity
on_opacity
canvas
get_disabled
set_disabled
inc_disabled
dec_disabled
disabled
motion_filter
kivy._event.EventDispatcher
register_event_type
unregister_event_types
unregister_event_type
is_event_type
bind
unbind
fbind
funbind
unbind_uid
get_property_observers
events
dispatch
dispatch_generic
dispatch_children
setter
getter
property
properties
create_property
apply_property