Selection Widgets

Implements various elements to get user selection.

class acg.custom_widgets.selection_widgets.CardCarousel(**kwargs)[source]

Bases: acg.custom_widgets.selection_widgets.MyCarousel

Carousel of TransCard.

To use it with different objects, change viewclass and modal_data_cls_name.

update_height(self, *_)[source]

Update height via animation, so that Widget has height of currently displayed card.

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

Bases: acg.custom_widgets.behaviors.MultiStateBehavior

Two-State-Behavior with states True and False.

class acg.custom_widgets.selection_widgets.CheckContainer(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.ChildrenFromDataBehavior

Container for widgets with CheckBehavior.

check_one[source]

BooleanProperty defaults to False. If True only one child can be selected.

conditional_uncheck(self, instance, value)[source]

Uncheck other widgets if check_one is True.

get_checked(self, attribute_name=None)[source]

Return current selection.

Parameters:attribute_name – Name of attribute to return. Defaults to None.
Returns:
  • If attribute_name is None: List of selected children
  • Else: List of attribute values
class acg.custom_widgets.selection_widgets.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)

Add one child-widget.

after_add_child(self, child)

Do something after child is added to parent_widget. Placeholder.

before_add_child(self, child)

Do something before child is added to parent_widget. Placeholder.

child_bindings

binding_fn}.

Type:DictProperty of the form {“on_event”
child_class_name

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

data

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

get_child(self, name)

Return child with name name.

on_data(self, *_)

Update children on change of data.

remove_child(self)

Remove one child-widget.

root_for_children

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

update_num_children(self)

Add/remove children until correct number is reached.

class acg.custom_widgets.selection_widgets.ImageCarousel(**kwargs)[source]

Bases: acg.custom_widgets.selection_widgets.MyCarousel

Carousel of images.

get_modal_content(self, size_hint=(1, 1))[source]

Call MyCarousel.get_modal_content() with size_hint=(1,1).

on_error(self, *_)[source]

Placeholder-function.

class acg.custom_widgets.selection_widgets.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

NumericProperty

on_long_press(self, *largs)

Implement in sub class. Placeholder.

on_short_press(self, *largs)

Implement in sub class. Placeholder.

on_state(self, instance, value)

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

class acg.custom_widgets.selection_widgets.LongPressImage(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.LongPressBehavior, kivy.uix.image.AsyncImage

AsyncImage with additional “on_press” and “on_long_press” event.

class acg.custom_widgets.selection_widgets.MyCarousel(**kwargs)[source]

Bases: kivy.uix.floatlayout.FloatLayout, acg.custom_widgets.behaviors.ChildrenFromDataBehavior

Carousel that constructs contents from data.

On click, opens a modal with list of content.

after_add_child(self, child)[source]

Call set_child_width() after adding child.

before_add_child(self, child)[source]

Bind set_child_width() to change of width.

carousel[source]

ObjectProperty

get_checked(self, attribute_name=None)[source]

If attribute_name is None, return currently selected widget, else return a property thereof.

get_modal_content(self, size_hint=(1, None))[source]

Return root widget to display on the modal.

modal_data_cls_name[source]

StringProperty

modal_layout_name[source]

StringProperty

on_data(self, *_)[source]

Override behaviors.ChildrenFromDataBehavior.on_data() with correct list of children.

The children are in carousel.slides as opposed to carousel.children.

open_menu(self, *_)[source]

Open kivy.uix.modalview.ModalView with content given by get_modal_content().

remove_child(self)[source]

Override behaviors.ChildrenFromDataBehavior.remove_child() with correct list of children.

The children are in carousel.slides as opposed to carousel.children.

set_child_width(self, child, *_)[source]

Set width of child to width - width of left and right-icon.

update_height(self, *_)[source]

Implement in sub class. Placeholder.

class acg.custom_widgets.selection_widgets.MyCheckCard(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.ThemableColorChangeBehavior, kivymd.uix.card.MDCard

Selectable :~kivymd.uix.card.MDCard`. Select by click. Changes color on selection.

on_press(self)[source]

Change boolean value of self.current_state.

text[source]

StringProperty.

class acg.custom_widgets.selection_widgets.MyCheckChip(**kwargs)[source]

Bases: kivymd.uix.behaviors.CircularRippleBehavior, kivy.uix.behaviors.ButtonBehavior, acg.custom_widgets.behaviors.ThemableColorChangeBehavior, kivy.uix.boxlayout.BoxLayout

Selectable Chip. Select by click. Change color on selection.

icon[source]

StringProperty defaults to “”.

on_press(self)[source]

Change boolean value of current_state.

text[source]

StringProperty defaults to “”.

class acg.custom_widgets.selection_widgets.MyCheckChipContainer(**kwargs)[source]

Bases: acg.custom_widgets.selection_widgets.CheckContainer, kivymd.theming.ThemableBehavior, kivy.uix.stacklayout.StackLayout

Container for MyCheckChips. Use child_dict to populate.

class acg.custom_widgets.selection_widgets.MyCheckImageTile(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.CheckBehavior, kivymd.uix.imagelist.SmartTile

Selectable SmartTile.

Select by click. Changes opacity and boarder_width on selection.

border_width[source]

NumericProperty describing boarder-width of image tile.

on_press(self)[source]

Change boolean value of current state on press.

class acg.custom_widgets.selection_widgets.MyTransCard(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.TranslationOnCheckBehavior, acg.custom_widgets.selection_widgets.MyCheckCard

Selectable MDCard. Select by click. Changes color and displayed text on click.

class acg.custom_widgets.selection_widgets.MyTransChip(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.TranslationOnCheckBehavior, acg.custom_widgets.selection_widgets.MyCheckChip

Selectable Chip. Select by click. Change color and text on selection.

class acg.custom_widgets.selection_widgets.RecycleCarousel(**kwargs)[source]

Bases: kivy.uix.floatlayout.FloatLayout

Wrapper class for a Carousel that uses only 3 slides to update content dynamically.

The index is updated according to the change of the carousel index and each time one of the slides is updated with data from data. The content of the slides is constructed as instances of viewclass.

carousel[source]

kivy.properties.ObjectProperty defaults to None.

current_slide[source]

kivy.properties.ObjectProperty. Reference to carousel.current_slide.

data[source]

kivy.properties.ListProperty defaults to None. List of dictionaries from which the content is generated.

dynamic_height[source]

kivy.properties.BooleanProperty defaults to False. If True updates the height of the root widget to the height of the object on the current slide + 24. Only possible if size_hint_y of the widget on the slide is not set.

get_checked(self, attribute_name=None)[source]

If attribute_name is None, return currently selected widget, else return a property thereof.

index[source]

kivy.properties.NumericProperty defaults to 0. Current (virtual) index.

kivy.properties.NumericProperty defaults to 0. Last index that the carousel had. Used to determine whether the user did slide right or left.

modal[source]

kivy.properties.ObjectProperty defaults to ModalView().

modal_data_cls_name[source]

kivy.properties.StringProperty defaults to None. Class name for children of modal.

modal_layout_name[source]

kivy.properties.StringProperty defaults to None. Class name for root widget of modal.

on_data(self, *_)[source]

Set up carousel by initializing 3 widgets, adding them and binding some Properties.

open_menu(self, *_)[source]

Open kivy.uix.modalview.ModalView with content given by setup_modal().

set_index(self, index)[source]

Set index to index and updates carousel accordingly.

setup_modal(self)[source]

Return root widget to display on the modal.

slide_width[source]

kivy.properties.NumericProperty defaults to None. Width that the content of the slides should have.

update_height(self, *_)[source]

Update height via animation, so that Widget has height of currently displayed card.

update_index(self, _, carousel_index)[source]

Change index according to change in carousel_index and update one of the three slides.

update_modal_content(self)[source]

Update content of modal.

update_slide(self, carousel_index, index)[source]

Update slide with index carousel_index by content from data [index].

Modulo function applied to indices guarantees values to be in the correct range.

viewclass[source]

kivy.properties.StringProperty defaults to "TransCard". Class name of the widgets that are added to the carousel.

class acg.custom_widgets.selection_widgets.SeparatorWithHeading(**kwargs)[source]

Bases: kivy.uix.floatlayout.FloatLayout

Two MDSeparators with a heading in between.

heading[source]

StringProperty with string used as heading.

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

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

Changes bg_color text_color based on current_state.

bg_color

ListProperty. Background color in rgba.

set_colors(self, *_)

Update state_dicts with colors from theme.

text_color

ListProperty. Text color in rgba.

class acg.custom_widgets.selection_widgets.TransCard(**kwargs)[source]

Bases: acg.custom_widgets.behaviors.LongPressBehavior, kivymd.uix.card.MDCard, kivymd.uix.behaviors.RectangularRippleBehavior

Displays text_orig and text_trans, separated by a line.

orientation[source]

OptionProperty possible values [“vertical”, “horizontal”] defaults to “vertical”.

text_orig[source]

StringProperty first text.

text_trans[source]

StringProperty second text.

class acg.custom_widgets.selection_widgets.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, *_)

Update state_dict with new text_orig.

on_text_trans(self, *_)

Update state_dict with new text_trans.

text_orig

StringProperty. Original Text.

text_trans

StringProperty. Translated Text.