pythonkivycarousel

Disable Swipe Actions on Kivy Carousel


I am using Kivy Carousel to build an App.

However I would like to maintain Manual control of the carousel and disable the swipe action (I will manually call carousel.load_next)

I have looked through the Documentation but cannot see any way to disable the swipe action.

If anyone could help me I would appreciate it.

Many thanks, Seotha.


Solution

  • You can disable the user swipe by controling the scroll_timeout. If you simply set it to 0 the user will be unable to trigger the scroll event.

    from kivy.app import App
    from kivy.uix.carousel import Carousel
    from kivy.uix.image import AsyncImage
    
    
    class CarouselApp(App):
        def build(self):
            carousel = Carousel(direction='right', scroll_timeout=0)
            for i in range(10):
                src = "http://placehold.it/480x270.png&text=slide-%d&.png" % i
                image = AsyncImage(source=src, allow_stretch=True)
                carousel.add_widget(image)
            return carousel
    
    
    CarouselApp().run()