Selection Widgets¶
Implements various elements to get user selection.
-
class
acg.custom_widgets.selection_widgets.CardCarousel(**kwargs)[source]¶ Bases:
acg.custom_widgets.selection_widgets.MyCarouselCarousel of
TransCard.To use it with different objects, change
viewclassandmodal_data_cls_name.
-
class
acg.custom_widgets.selection_widgets.CheckBehavior(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.MultiStateBehaviorTwo-State-Behavior with states
TrueandFalse.
-
class
acg.custom_widgets.selection_widgets.CheckContainer(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.ChildrenFromDataBehaviorContainer for widgets with
CheckBehavior.-
check_one[source]¶ BooleanPropertydefaults toFalse. IfTrueonly one child can be selected.
-
-
class
acg.custom_widgets.selection_widgets.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().-
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: DictPropertyof the form {“on_event”
-
child_class_name¶ StringPropertyclass name for children. Needs to be available viaget().
-
data¶ ListPropertycontaining the dictionaries from which the child-widgets are constructed.
-
get_child(self, name)¶ Return child with name
name.
-
remove_child(self)¶ Remove one child-widget.
-
root_for_children¶ ObjectPropertythe 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.MyCarouselCarousel of images.
-
get_modal_content(self, size_hint=(1, 1))[source]¶ Call
MyCarousel.get_modal_content()withsize_hint=(1,1).
-
-
class
acg.custom_widgets.selection_widgets.LongPressBehavior(**kwargs)[source]¶ Bases:
kivy.uix.behaviors.ButtonBehaviorDispatches “on_long_press” if pressed for longer than
long_press_timeelse “on_short_press”.-
long_press_time¶
-
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_pressif thestatestays down for longer thanlong_press_time.
-
-
class
acg.custom_widgets.selection_widgets.LongPressImage(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.LongPressBehavior,kivy.uix.image.AsyncImageAsyncImagewith 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.ChildrenFromDataBehaviorCarousel 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 ofwidth.
-
get_checked(self, attribute_name=None)[source]¶ If
attribute_nameisNone, return currently selected widget, else return a property thereof.
-
on_data(self, *_)[source]¶ Override
behaviors.ChildrenFromDataBehavior.on_data()with correct list of children.The children are in
carousel.slidesas opposed tocarousel.children.
Open
kivy.uix.modalview.ModalViewwith content given byget_modal_content().
-
remove_child(self)[source]¶ Override
behaviors.ChildrenFromDataBehavior.remove_child()with correct list of children.The children are in
carousel.slidesas opposed tocarousel.children.
-
-
class
acg.custom_widgets.selection_widgets.MyCheckCard(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.ThemableColorChangeBehavior,kivymd.uix.card.MDCardSelectable :~kivymd.uix.card.MDCard`. Select by click. Changes color on selection.
-
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.BoxLayoutSelectable Chip. Select by click. Change color on selection.
-
icon[source]¶ StringPropertydefaults to “”.
-
text[source]¶ StringPropertydefaults to “”.
-
-
class
acg.custom_widgets.selection_widgets.MyCheckChipContainer(**kwargs)[source]¶ Bases:
acg.custom_widgets.selection_widgets.CheckContainer,kivymd.theming.ThemableBehavior,kivy.uix.stacklayout.StackLayoutContainer for
MyCheckChips. Usechild_dictto populate.
-
class
acg.custom_widgets.selection_widgets.MyCheckImageTile(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.CheckBehavior,kivymd.uix.imagelist.SmartTileSelectable
SmartTile.Select by click. Changes
opacityandboarder_widthon selection.-
border_width[source]¶ NumericPropertydescribing boarder-width of image tile.
-
-
class
acg.custom_widgets.selection_widgets.MyTransCard(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.TranslationOnCheckBehavior,acg.custom_widgets.selection_widgets.MyCheckCardSelectable
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.MyCheckChipSelectable Chip. Select by click. Change color and text on selection.
-
class
acg.custom_widgets.selection_widgets.RecycleCarousel(**kwargs)[source]¶ Bases:
kivy.uix.floatlayout.FloatLayoutWrapper class for a
Carouselthat uses only 3 slides to update content dynamically.The
indexis updated according to the change of the carousel index and each time one of the slides is updated with data fromdata. The content of the slides is constructed as instances ofviewclass.-
carousel[source]¶ kivy.properties.ObjectPropertydefaults toNone.
-
current_slide[source]¶ kivy.properties.ObjectProperty. Reference tocarousel.current_slide.
-
data[source]¶ kivy.properties.ListPropertydefaults toNone. List of dictionaries from which the content is generated.
-
dynamic_height[source]¶ kivy.properties.BooleanPropertydefaults toFalse. IfTrueupdates 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_nameisNone, return currently selected widget, else return a property thereof.
-
index[source]¶ kivy.properties.NumericPropertydefaults to0. Current (virtual) index.
-
last_carousel_index[source]¶ kivy.properties.NumericPropertydefaults to0. Last index that thecarouselhad. Used to determine whether the user did slide right or left.
-
modal[source]¶ kivy.properties.ObjectPropertydefaults toModalView().
-
modal_data_cls_name[source]¶ kivy.properties.StringPropertydefaults toNone. Class name for children ofmodal.
-
modal_layout_name[source]¶ kivy.properties.StringPropertydefaults toNone. Class name for root widget ofmodal.
-
on_data(self, *_)[source]¶ Set up
carouselby initializing 3 widgets, adding them and binding some Properties.
Open
kivy.uix.modalview.ModalViewwith content given bysetup_modal().
-
slide_width[source]¶ kivy.properties.NumericPropertydefaults toNone. 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
indexaccording to change incarousel_indexand update one of the three slides.
-
update_slide(self, carousel_index, index)[source]¶ Update slide with index
carousel_indexby content fromdata[index].Modulo function applied to indices guarantees values to be in the correct range.
-
viewclass[source]¶ kivy.properties.StringPropertydefaults 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.FloatLayoutTwo
MDSeparators with a heading in between.-
heading[source]¶ StringPropertywith string used as heading.
-
-
class
acg.custom_widgets.selection_widgets.ThemableColorChangeBehavior(**kwargs)[source]¶ Bases:
kivymd.theming.ThemableBehavior,acg.custom_widgets.behaviors.CheckBehaviorChanges
bg_colortext_colorbased oncurrent_state.-
bg_color¶ ListProperty. Background color in rgba.
-
set_colors(self, *_)¶ Update
state_dictswith 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.RectangularRippleBehaviorDisplays
text_origandtext_trans, separated by a line.-
orientation[source]¶ OptionPropertypossible values [“vertical”, “horizontal”] defaults to “vertical”.
-
text_orig[source]¶ StringPropertyfirst text.
-
text_trans[source]¶ StringPropertysecond text.
-
-
class
acg.custom_widgets.selection_widgets.TranslationOnCheckBehavior(**kwargs)[source]¶ Bases:
acg.custom_widgets.behaviors.CheckBehaviorSwitches
textbetweentext_origandtext_transdepending oncurrent_state.-
on_text_trans(self, *_)¶ Update
state_dictwith newtext_trans.
-
text_orig¶ StringProperty. Original Text.
-
text_trans¶ StringProperty. Translated Text.
-