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.
- class kivy.uix.carousel.Carousel(**kwargs)¶
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 , default to 0.3
- anim_move_duration¶
Defines the duration of the carousel animation between pages.
anim_move_duration is a NumericProperty, default to 0.5
- current_slide¶
The currently shown slide.
current_slide is an AliasProperty.
Changed in version 1.5.0.
- direction¶
Specifies the direction in which the slides are orderd / from which the user swipes to go from one to the next slide. 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, default to ‘right’.
- index¶
Get/Set the current visible slide based on index.
index is a NumericProperty, default to 0 (first item)
- load_next(mode='next')¶
Animate next slide in.
New in version 1.7.0.
- load_previous()¶
Animate previous slide in.
New in version 1.7.0.
- loop¶
Allow carousel to swipe infinitely. When the user reach the last page, he will get the first page when trying to swipe next. Same effect when trying to swipe the first page.
loop is a BooleanProperty, default to False.
- min_move¶
Defines the minimal distance from the edge where the movement is considered a swipe gesture and the carousel will change his content. This is a percentage of the carousel width. If the movement doesn’t reach this minimal value, then the movement is canceled and the content is restored to its preceding position.
min_move is a NumericProperty, default to 0.2
- next_slide¶
The next slide in the Carousel, 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.
- previous_slide¶
The previous slide in the Carousel, 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.
- 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, default 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, default 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, read-only.