Behaviors

Provides various mixin-classes for kivy widgets.

class acg.custom_widgets.behaviors.CallbackBehavior[source]

Bases: kivy.event.EventDispatcher

Mixin 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?

callback_wrapper(self, callback, *_)[source]

Call callback with first argument as self in new thread.

callbacks[source]

callback_fn}. callback_fn(self) -> Any

Type:DictProperty of the form {“on_event”
on_callbacks(self, *_)[source]

Binds the callbacks to the specified events on definition.

class acg.custom_widgets.behaviors.CheckBehavior(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.MultiStateBehavior

Two-State-Behavior with states True and False.

class acg.custom_widgets.behaviors.ChildrenFromDataBehavior(**kwargs)[source]

Generates widgets dynamically from data and adds them to root_for_children.

Bindings can be applied and other functions executed by the definition of before_add_child() and after_add_child().

add_child(self, child_dict=None)[source]

Add one child-widget.

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:DictProperty of the form {“on_event”
child_class_name[source]

StringProperty class name for children. Needs to be available via get().

data[source]

ListProperty containing the dictionaries from which the child-widgets are constructed.

get_child(self, name)[source]

Return child with name name.

on_data(self, *_)[source]

Update children on change of data.

remove_child(self)[source]

Remove one child-widget.

root_for_children[source]

ObjectProperty the widget, where the children should be added to Defaults to self.

update_num_children(self)[source]

Add/remove children until correct number is reached.

class acg.custom_widgets.behaviors.LongPressBehavior(**kwargs)[source]

Bases: kivy.uix.behaviors.ButtonBehavior

Dispatches “on_long_press” if pressed for longer than long_press_time else “on_short_press”.

long_press_time[source]

NumericProperty

on_long_press(self, *largs)[source]

Implement in sub class. Placeholder.

on_short_press(self, *largs)[source]

Implement in sub class. Placeholder.

on_state(self, instance, value)[source]

Dispatches on_long_press if the state stays down for longer than long_press_time.

class acg.custom_widgets.behaviors.MultiStateBehavior(**kwargs)[source]

Bases: kivy.uix.widget.Widget

Changes properties of widget based on current_state and the corresponding entry in state_dict.

The properties in animated_properties change via animation.

animated_properties[source]

ListProperty containing the list of property-names that get changed via animation.

current_state[source]

Property current state of the widget.

default_state[source]

Property current state of the widget.

state_dicts[source]

DictProperty. E.g.,

state_dicts = {
        state_1 : {"some_property": some_value, ...},
        ...
    }
update_properties(self, *_)[source]

Update properties if they differ from the corresponding entry in current_properties.

class acg.custom_widgets.behaviors.ThemableColorChangeBehavior(**kwargs)[source]

Bases: kivymd.theming.ThemableBehavior, acg.custom_widgets.behaviors.CheckBehavior

Changes bg_color text_color based on current_state.

bg_color[source]

ListProperty. Background color in rgba.

set_colors(self, *_)[source]

Update state_dicts with colors from theme.

text_color[source]

ListProperty. Text color in rgba.

class acg.custom_widgets.behaviors.TranslationOnCheckBehavior(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.CheckBehavior

Switches text between text_orig and text_trans depending on current_state.

on_text_orig(self, *_)[source]

Update state_dict with new text_orig.

on_text_trans(self, *_)[source]

Update state_dict with new text_trans.

text_orig[source]

StringProperty. Original Text.

text_trans[source]

StringProperty. Translated Text.