Behaviors¶
Provides various mixin-classes for kivy widgets.
-
class
acg.custom_widgets.behaviors.CallbackBehavior[source]¶ Bases:
kivy.event.EventDispatcherMixin Class to implement a number of callbacks.
Useful e.g. in combination with
RecycleView. There, the content is generated dynamically from a dictionary such that this class can be used to bind multiple callbacks to different events of the widgets.Warning
Callbacks are not unbound by
on_callbacks(). Does this pose a problem?
-
class
acg.custom_widgets.behaviors.CheckBehavior(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.MultiStateBehaviorTwo-State-Behavior with states
TrueandFalse.
-
class
acg.custom_widgets.behaviors.ChildrenFromDataBehavior(**kwargs)[source]¶ Generates widgets dynamically from
dataand adds them toroot_for_children.Bindings can be applied and other functions executed by the definition of
before_add_child()andafter_add_child().-
after_add_child(self, child)[source]¶ Do something after child is added to
parent_widget. Placeholder.
-
before_add_child(self, child)[source]¶ Do something before child is added to
parent_widget. Placeholder.
-
child_bindings[source]¶ binding_fn}.
Type: DictPropertyof the form {“on_event”
-
child_class_name[source]¶ StringPropertyclass name for children. Needs to be available viaget().
-
data[source]¶ ListPropertycontaining the dictionaries from which the child-widgets are constructed.
-
root_for_children[source]¶ ObjectPropertythe widget, where the children should be added to Defaults to self.
-
-
class
acg.custom_widgets.behaviors.LongPressBehavior(**kwargs)[source]¶ Bases:
kivy.uix.behaviors.ButtonBehaviorDispatches “on_long_press” if pressed for longer than
long_press_timeelse “on_short_press”.-
on_state(self, instance, value)[source]¶ Dispatches
on_long_pressif thestatestays down for longer thanlong_press_time.
-
-
class
acg.custom_widgets.behaviors.MultiStateBehavior(**kwargs)[source]¶ Bases:
kivy.uix.widget.WidgetChanges properties of widget based on
current_stateand the corresponding entry instate_dict.The properties in
animated_propertieschange via animation.-
animated_properties[source]¶ ListPropertycontaining the list of property-names that get changed via animation.
-
state_dicts[source]¶ DictProperty. E.g.,state_dicts = { state_1 : {"some_property": some_value, ...}, ... }
-
-
class
acg.custom_widgets.behaviors.ThemableColorChangeBehavior(**kwargs)[source]¶ Bases:
kivymd.theming.ThemableBehavior,acg.custom_widgets.behaviors.CheckBehaviorChanges
bg_colortext_colorbased oncurrent_state.-
bg_color[source]¶ ListProperty. Background color in rgba.
-
text_color[source]¶ ListProperty. Text color in rgba.
-
-
class
acg.custom_widgets.behaviors.TranslationOnCheckBehavior(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.CheckBehaviorSwitches
textbetweentext_origandtext_transdepending oncurrent_state.-
on_text_trans(self, *_)[source]¶ Update
state_dictwith newtext_trans.
-
text_orig[source]¶ StringProperty. Original Text.
-
text_trans[source]¶ StringProperty. Translated Text.
-