kvex.widgets.spinner
Home of XSpinner
and XSpinnerOption
.
1"""Home of `XSpinner` and `XSpinnerOption`.""" 2 3from .. import kivy as kv 4from .. import assets 5from ..behaviors import XThemed 6from .widget import XWidget 7from .dropdown import XDropDown 8 9 10BG_NORMAL = str(assets.get_image("spinner")) 11BG_DOWN = str(assets.get_image("button_down")) 12 13 14class XSpinnerOption(XThemed, XWidget, kv.SpinnerOption): 15 """SpinnerOption.""" 16 17 def __init__(self, *args, **kwargs): 18 """Initialize the class with defaults.""" 19 kwargs = dict( 20 background_normal=BG_NORMAL, 21 background_down=BG_DOWN, 22 ) | kwargs 23 super().__init__(*args, **kwargs) 24 25 def on_subtheme(self, subtheme): 26 """Apply colors.""" 27 self.background_color = subtheme.bg.rgba 28 self.color = subtheme.fg.rgba 29 30 31class XSpinner(XThemed, XWidget, kv.Spinner): 32 """Spinner.""" 33 34 def __init__(self, *args, **kwargs): 35 """Initialize the class with defaults.""" 36 kwargs = dict( 37 dropdown_cls=XDropDown, 38 option_cls=XSpinnerOption, 39 background_normal=BG_NORMAL, 40 background_down=BG_DOWN, 41 ) | kwargs 42 super().__init__(*args, **kwargs) 43 self.register_event_type("on_select") 44 45 def on_select(self, index: int, text: str): 46 """Called when an item is selected.""" 47 pass 48 49 def _on_dropdown_select(self, w, text, *largs): 50 if self.text_autoupdate: 51 self.text = text 52 self.is_open = False 53 self.dispatch("on_select", self.values.index(text), text) 54 55 def on_subtheme(self, subtheme): 56 """Apply colors.""" 57 self.background_color = subtheme.bg.rgba 58 self.color = subtheme.fg.rgba 59 60 61__all__ = ( 62 "XSpinner", 63 "XSpinnerOption", 64)
32class XSpinner(XThemed, XWidget, kv.Spinner): 33 """Spinner.""" 34 35 def __init__(self, *args, **kwargs): 36 """Initialize the class with defaults.""" 37 kwargs = dict( 38 dropdown_cls=XDropDown, 39 option_cls=XSpinnerOption, 40 background_normal=BG_NORMAL, 41 background_down=BG_DOWN, 42 ) | kwargs 43 super().__init__(*args, **kwargs) 44 self.register_event_type("on_select") 45 46 def on_select(self, index: int, text: str): 47 """Called when an item is selected.""" 48 pass 49 50 def _on_dropdown_select(self, w, text, *largs): 51 if self.text_autoupdate: 52 self.text = text 53 self.is_open = False 54 self.dispatch("on_select", self.values.index(text), text) 55 56 def on_subtheme(self, subtheme): 57 """Apply colors.""" 58 self.background_color = subtheme.bg.rgba 59 self.color = subtheme.fg.rgba
Spinner.
XSpinner(*args, **kwargs)
35 def __init__(self, *args, **kwargs): 36 """Initialize the class with defaults.""" 37 kwargs = dict( 38 dropdown_cls=XDropDown, 39 option_cls=XSpinnerOption, 40 background_normal=BG_NORMAL, 41 background_down=BG_DOWN, 42 ) | kwargs 43 super().__init__(*args, **kwargs) 44 self.register_event_type("on_select")
Initialize the class with defaults.
def
on_subtheme(self, subtheme):
56 def on_subtheme(self, subtheme): 57 """Apply colors.""" 58 self.background_color = subtheme.bg.rgba 59 self.color = subtheme.fg.rgba
Apply colors.
Inherited Members
- kivy.uix.spinner.Spinner
- values
- text_autoupdate
- option_cls
- dropdown_cls
- is_open
- sync_height
- on_is_open
- kivy.uix.button.Button
- background_color
- background_normal
- background_down
- background_disabled_normal
- background_disabled_down
- border
- kivy.uix.behaviors.button.ButtonBehavior
- state
- last_touch
- min_state_time
- always_release
- cancel_event
- on_touch_down
- on_touch_move
- on_touch_up
- on_press
- on_release
- trigger_action
- kivy.uix.label.Label
- texture_update
- on_ref_press
- disabled_color
- text
- text_size
- base_direction
- text_language
- font_context
- font_family
- font_name
- font_size
- font_features
- line_height
- bold
- italic
- underline
- strikethrough
- padding_x
- padding_y
- padding
- halign
- valign
- color
- outline_width
- outline_color
- disabled_outline_color
- texture
- texture_size
- mipmap
- shorten
- shorten_from
- is_shortened
- split_str
- ellipsis_options
- unicode_errors
- markup
- refs
- anchors
- max_lines
- strip
- font_hinting
- font_kerning
- font_blended
- 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
class
XSpinnerOption(kvex.behaviors.XThemed, kvex.widgets.widget.XWidget, kivy.uix.spinner.SpinnerOption):
15class XSpinnerOption(XThemed, XWidget, kv.SpinnerOption): 16 """SpinnerOption.""" 17 18 def __init__(self, *args, **kwargs): 19 """Initialize the class with defaults.""" 20 kwargs = dict( 21 background_normal=BG_NORMAL, 22 background_down=BG_DOWN, 23 ) | kwargs 24 super().__init__(*args, **kwargs) 25 26 def on_subtheme(self, subtheme): 27 """Apply colors.""" 28 self.background_color = subtheme.bg.rgba 29 self.color = subtheme.fg.rgba
SpinnerOption.
XSpinnerOption(*args, **kwargs)
18 def __init__(self, *args, **kwargs): 19 """Initialize the class with defaults.""" 20 kwargs = dict( 21 background_normal=BG_NORMAL, 22 background_down=BG_DOWN, 23 ) | kwargs 24 super().__init__(*args, **kwargs)
Initialize the class with defaults.
def
on_subtheme(self, subtheme):
26 def on_subtheme(self, subtheme): 27 """Apply colors.""" 28 self.background_color = subtheme.bg.rgba 29 self.color = subtheme.fg.rgba
Apply colors.
Inherited Members
- kivy.uix.button.Button
- background_color
- background_normal
- background_down
- background_disabled_normal
- background_disabled_down
- border
- kivy.uix.behaviors.button.ButtonBehavior
- state
- last_touch
- min_state_time
- always_release
- cancel_event
- on_touch_down
- on_touch_move
- on_touch_up
- on_press
- on_release
- trigger_action
- kivy.uix.label.Label
- texture_update
- on_ref_press
- disabled_color
- text
- text_size
- base_direction
- text_language
- font_context
- font_family
- font_name
- font_size
- font_features
- line_height
- bold
- italic
- underline
- strikethrough
- padding_x
- padding_y
- padding
- halign
- valign
- color
- outline_width
- outline_color
- disabled_outline_color
- texture
- texture_size
- mipmap
- shorten
- shorten_from
- is_shortened
- split_str
- ellipsis_options
- unicode_errors
- markup
- refs
- anchors
- max_lines
- strip
- font_hinting
- font_kerning
- font_blended
- 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