在 Kivy Carousel 上禁用滑动操作

Disable Swipe Actions on Kivy Carousel

我正在使用 Kivy Carousel 构建应用程序。

但是我想保持手动控制轮播并禁用滑动操作(我会手动调用carousel.load_next)

我查看了文档,但看不到任何禁用滑动操作的方法。

如果有人能帮助我,我将不胜感激。

非常感谢, 塞萨.

您可以通过控制 scroll_timeout 来禁用用户滑动。如果简单的设置为0用户将无法触发滚动事件

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()

谢谢Authur,我会标记为答案。 我还发现我可以将 Carousel 子类化并重写 on_touch_move 什么都不用。

class MyCarousel(Carousel): def on_touch_move(self,touch): pass

以下内容可能会有帮助:

使用

scroll_distance: '<x>dp'