ae.kivy.tours
ae.kivy.tours module
this module provides the following classes to augment the user interface of your apps with animated product tours, tutorials, walkthroughs and user onboarding/welcome features:
the class TourOverlay
is implementing an overlay layout widget to display the animations,
shaders, tour page texts, tooltip text and the navigation buttons of an active/running app tour.
the AnimatedTourMixin
can be mixed-into a tour class that inherits from
TourBase
to extend it with animation and glsl shader features.
the class AnimatedOnboardingTour
is based on OnboardingTour
and
AnimatedTourMixin
to extend the generic app onboarding tour
class with animations. it provides a generic app onboarding tour that covers the core features, that can be easily
extended with app-specific tour pages.
to integrate a more app-specific onboarding tour into your app, simply declare a class with a name composed by the name
of your app (app_name
) in camel-case, followed by the suffix ‘OnboardingTour’.
Module Attributes
tuple of a widget id string and an |
|
tuple of |
|
a key of this dict specifies the name, the dict value the value of a widget property/attribute. |
|
default of tour layout fade out app screen factor |
Functions
|
start animation if needed else skip animation start. |
|
determine from a widget the attribute/property values animated/changed by an animation. |
|
restore property values of a widget. |
Classes
|
onboarding tour, extended with animations and glsl shaders. |
|
tour class mixin to add individual shaders to the tour layout and their children widgets. |
|
tour layout/view overlay singleton class to display an active/running modal app tour with optional glsl shaders. |
- PageAnimationType
tuple of a widget id string and an
Animation
instance/evaluation-expression.if the first character of the widget id is a @ then the
repeat
attribute of theAnimation
instance will be set to True. the rest of the widget id string specifies the widget to be animated which is either:one of the widgets of the
TourOverlay
layout class, identified by the on of the following strings: ‘next_but’, ‘page_lbl’, ‘tap_pointer’, ‘prev_but’, ‘title_lbl’, ‘tooltip’, ‘tour_page_texts’.the explained widget if an empty string is given.
the
TourOverlay
layout class instance for any other string (e.g. ‘layout’ or ‘overlay’).
alternative to an animation instance, a evaluation string can be specified. these evaluations allow to use the following globals:
Animation
(also abbreviated as A),Clock
,layout
,sp
,Window
and a reference to the instance of this app tour via tour.
- PageAnimationsType
tuple of
PageAnimationType
items
- WidgetValues
a key of this dict specifies the name, the dict value the value of a widget property/attribute.
- DEF_FADE_OUT_APP = 0.39
default of tour layout fade out app screen factor
- animated_widget_values(wid, ani)[source]
determine from a widget the attribute/property values animated/changed by an animation.
- Parameters:
- Return type:
- Returns:
dict with widget property names and values.
- class AnimatedTourMixin(main_app)[source]
Bases:
object
tour class mixin to add individual shaders to the tour layout and their children widgets.
-
pages_animations:
Dict
[Optional
[str
],Tuple
[Tuple
[str
,Union
[Animation
,str
]],...
]] dict of compound animation instances of the pages of this tour.
the key of this dict is the page id or None (for animations available in all pages of this tour). each value of this dict is of the type
PageAnimationsType
.
-
pages_shaders:
Dict
[Optional
[str
],Tuple
[Tuple
[str
,Dict
[str
,Any
]],...
]] dict of widget shaders for the pages of this tour.
the key of this dict is the page id or None (for shaders available in all pages of this tour). each value of this dict is a tuple of tuples of widget id and add_shader()-kwargs.
the widget id string specifies the widget to which a shader will be added, which is either:
one of the widgets of the
TourOverlay
layout class, identified by the on of the following strings: ‘next_but’, ‘page_lbl’, ‘tap_pointer’, ‘prev_but’, ‘title_lbl’, ‘tooltip’, ‘tour_page_texts’.the explained widget if an empty string is given.
the
TourOverlay
layout class instance for any other string (e.g. ‘layout’ or ‘overlay’).
before the add_shader()-kwargs dict will be passed to the
add_shader()
method, all their non-string values, specifying as strings, will be evaluated/converted automatically. the evaluation provides the following globals:layout
,sp
,Clock
,Window
and the tour instance.
-
switch_next_animations:
Dict
[Optional
[str
],Tuple
[Tuple
[str
,Union
[Animation
,str
]],...
]] dict of compound animation instances for the next page switch transition of the pages of this tour.
the key of this dict is the page id or None (for animations available in all pages of this tour). each value of this dict is of the type
PageAnimationsType
.
- _add_animations(animations)[source]
add animations to the tour page currently displayed in the tour layout/overlay.
- setup_explained_widget()[source]
overridden to bind pos/size of explained widget(s) to the tour layout/overlay placeholder.
- Return type:
- Returns:
list of explained widget instances.
- setup_page_shaders_and_animations()[source]
setup shaders and animations of the current page.
specified in
pages_shaders
andpages_animations
.
- simulate_text_input(text_input, text_to_delay, text_to_insert='', deltas=(1.8, 0.6, 0.3))[source]
simulate the typing of texts by a user entered into an explained TextInput widget of a tour page.
- Parameters:
text_input¶ (
TextInput
) – text input widget, either of typeTextInput
orFlowInput
.text_to_delay¶ (
str
) – text string to be inserted delayed by the seconds specified in deltas[0].text_to_insert¶ (
str
) – text string to be inserted directly into the passed text input widget.deltas¶ (
Tuple
[float
,...
]) – delay deltas in seconds between each character to simulate text inputted by a user. first delta default is a bit higher to finish navigation button y-pos-animation.
- tap_animation(wid_id='', pos_delay=2.34, press_delay=0.69, release_delay=0.39)[source]
create a compound animation instance simulating a user touch/tap on the specified widget.
- Parameters:
wid_id¶ (
str
) – specifies the widget to be tap simulated: either a widget id string (first item of thePageAnimationType
tuple), or (if prefixed with a column character) tap/focus/ state id of a widget, or an empty string (specifies the currently explained widget).pos_delay¶ (
float
) – time in seconds to position/move the pointer from the next button to the widget.press_delay¶ (
float
) – time in seconds of the button press simulation animation.release_delay¶ (
float
) – time in seconds of the button release simulation animation.
- Return type:
- Returns:
compound animation instance simulating a tap.
Note
use as animation evaluation expression, to get the widget values on setup-time of the page (not tour).
-
pages_animations:
- class AnimatedOnboardingTour(main_app)[source]
Bases:
AnimatedTourMixin
,OnboardingTour
onboarding tour, extended with animations and glsl shaders.
- next_page()[source]
overriding to remove next button size animation only visible in the first tour after app re/start.
- setup_layout()[source]
overridden to update layout texts if app window/screen orientation (app.landscape) changes.
- teardown_shaders_and_animations()[source]
overridden to unbind setup_texts() on leaving the responsible_layout tour page.
-
page_ids:
List
[str
] list of tour page ids, either initialized via this class attribute or dynamically.
- _added_animations: List[Tuple[Widget, Animation, WidgetValues]]
- _added_shaders: List[Tuple[Widget, ShaderIdType]]
- pages_animations: Dict[Optional[str], PageAnimationsType]
dict of compound animation instances of the pages of this tour.
the key of this dict is the page id or None (for animations available in all pages of this tour). each value of this dict is of the type
PageAnimationsType
.
- pages_shaders: Dict[Optional[str], Tuple[Tuple[str, ShaderIdType], ...]]
dict of widget shaders for the pages of this tour.
the key of this dict is the page id or None (for shaders available in all pages of this tour). each value of this dict is a tuple of tuples of widget id and add_shader()-kwargs.
the widget id string specifies the widget to which a shader will be added, which is either:
one of the widgets of the
TourOverlay
layout class, identified by the on of the following strings: ‘next_but’, ‘page_lbl’, ‘tap_pointer’, ‘prev_but’, ‘title_lbl’, ‘tooltip’, ‘tour_page_texts’.the explained widget if an empty string is given.
the
TourOverlay
layout class instance for any other string (e.g. ‘layout’ or ‘overlay’).
before the add_shader()-kwargs dict will be passed to the
add_shader()
method, all their non-string values, specifying as strings, will be evaluated/converted automatically. the evaluation provides the following globals:layout
,sp
,Clock
,Window
and the tour instance.
- switch_next_animations: Dict[Optional[str], PageAnimationsType]
dict of compound animation instances for the next page switch transition of the pages of this tour.
the key of this dict is the page id or None (for animations available in all pages of this tour). each value of this dict is of the type
PageAnimationsType
.
- class TourOverlay(main_app, tour_class=None, **kwargs)[source]
Bases:
ModalBehavior
,ShadersMixin
,FloatLayout
tour layout/view overlay singleton class to display an active/running modal app tour with optional glsl shaders.
- ani_value
animated float value between 0.0 and 1.0, used e.g. by
AnimatedTourMixin.pages_animations
.ani_value
is aNumericProperty
and is read-only.
- explained_pos
window position (absolute x, y window coordinates) of the targeted/explained/highlighted widget.
explained_pos
is aListProperty
and is read-only.
- explained_size
widget size (width, height) of the targeted/explained/highlighted widget.
explained_size
is aListProperty
and is read-only.
- fade_out_app
fade out app screen factor: 0.0 prevents fade out of the areas around TourPageTexts and the explained widget.
1.0 results in maximum app screen fade out. configurable for individual tour page via page_data[‘fade_out_app’].
fade_out_app
is aNumericProperty
and defaults to 0.39.
- label_height
height in pixels of the page text labels and text lines.
label_height
is aNumericProperty
and is read-only.
if this flag is True then the back/next buttons in the tour layout/overlay are disabled.
navigation_disabled
is aBooleanProperty
and is read-only.
- tour_instance
holding the
TourBase
instance of the current tour, initialized bystart_tour()
.tour_instance
is aObjectProperty
and is read-only.
- __init__(main_app, tour_class=None, **kwargs)[source]
prepare app and tour overlay (singleton instance of this class) to start tour.
- explained_widget
explained widget instance on actual tour (page).
explained_widget
is aObjectProperty
and is read-only.
navigation button disabled change event, used to hide page texts (blend-in-anim in page_updated()).
- page_updated()[source]
callback from
setup_layout()
for UI-specific patches, after tour layout/overlay setup.