Table Of Contents
Carousel¶
New in version 1.4.0.
The Carousel widget provides the classic mobile-friendly carousel view where you can swipe between slides. You can add any content to the carousel and use it horizontally or verticaly. The carousel can display pages in loop or not.
Example:
class Example1(App):
def build(self):
carousel = Carousel(direction='right')
for i in range(10):
src = "http://placehold.it/480x270.png&text=slide-%d&.png" % i
image = Factory.AsyncImage(source=src, allow_stretch=True)
carousel.add_widget(image)
return carousel
Example1().run()
Changed in version 1.5.0: The carousel now supports active children, like the ScrollView. It will detect a swipe gesture according to Carousel.scroll_timeout and Carousel.scroll_distance.
In addition, the container used for adding a slide is now hidden in the API. We made a mistake by exposing it to the user. The impacted properties are: Carousel.slides, Carousel.current_slide, Carousel.previous_slide and Carousel.next_slide.
- class kivy.uix.carousel.Carousel(**kwargs)[source]¶
Bases: kivy.uix.stencilview.StencilView
Carousel class. See module documentation for more information.
- anim_cancel_duration¶
Defines the duration of the animation when a swipe movement is not accepted. This is generally when the user doesnt swipe enough. See min_move.
anim_cancel_duration is a NumericProperty and defaults to 0.3.
- anim_move_duration¶
Defines the duration of the Carousel animation between pages.
anim_move_duration is a NumericProperty and defaults to 0.5.
- anim_type¶
Type of animation to use while animating in the next/previous slide.
New in version 1.8.0.
- current_slide¶
The currently shown slide.
current_slide is an AliasProperty.
Changed in version 1.5.0: The property doesn’t expose the container used for storing the slide. It returns widget you have added.
- direction¶
Specifies the direction in which the slides are ordered i.e. the direction from which the user swipes to go from one slide to the next. Can be right, left, ‘top’, or bottom. For example, with the default value of right, the second slide is to the right of the first and the user would swipe from the right towards the left to get to the second slide.
direction is a OptionProperty and defaults to ‘right’.
- index¶
Get/Set the current visible slide based on the index.
index is a NumericProperty and defaults to 0 (the first item).
- load_slide(slide)[source]¶
Animate to the slide that is passed as the argument.
Changed in version 1.8.0.
- loop¶
Allow the Carousel to swipe infinitely. When the user reaches the last page, they will return to first page when trying to swipe to the next.
loop is a BooleanProperty and defaults to False.
- min_move¶
Defines the minimal distance from the edge where the movement is considered a swipe gesture and the Carousel will change its content. This is a percentage of the Carousel width. If the movement doesn’t reach this minimal value, then the movement is cancelled and the content is restored to its original position.
min_move is a NumericProperty and defaults to 0.2.
- next_slide¶
The next slide in the Carousel. It is None if the current slide is the last slide in the Carousel. If orientation is ‘horizontal’, the next slide is to the right. If orientation is ‘vertical’, the previous slide is towards the top.
previous_slide is a AliasProperty.
Changed in version 1.5.0: The property doesn’t expose the container used for storing the slide. It returns the widget you have added.
- previous_slide¶
The previous slide in the Carousel. It is None if the current slide is the first slide in the Carousel. If orientation is ‘horizontal’, the previous slide is to the left. If orientation is ‘vertical’, the previous slide towards the bottom.
previous_slide is a AliasProperty.
Changed in version 1.5.0: This property doesn’t expose the container used for storing the slide. It returns the widget you have added.
- scroll_distance¶
Distance to move before scrolling the ScrollView in pixels. As soon as the distance has been traveled, the ScrollView will start to scroll, and no touch event will go to children. It is advisable that you base this value on the dpi of your target device’s screen.
scroll_distance is a NumericProperty and defaults to 20dp.
New in version 1.5.0.
- scroll_timeout¶
Timeout allowed to trigger the scroll_distance, in milliseconds. If the user has not moved scroll_distance within the timeout, the scrolling will be disabled and the touch event will go to the children.
scroll_timeout is a NumericProperty and defaults to 200 (milliseconds)
New in version 1.5.0.
- slides¶
List of slides inside the Carousel. The slides are added when a widget is added to Carousel using add_widget().
slides is a ListProperty and is read-only.