Search code examples
scrollviewkivyeffectskivy-language

what is the proper way to set kivy scrollview effects_cls property?


I want to stop the user from over scrolling. kivy doc say that the effects_cls property will change this behavior, but I have not found a way to make it work.


Solution

  • Although you have solved your problem I will provide an example for future users.

    You can change what effect is being used by setting effect_cls to any effect class. If you want to disable the overscroll effect to prevent the scroll bouncing effect ScrollEffect solve the problem.

    Example using kivy Language:

    from kivy.app import App
    from kivy.uix.scrollview import ScrollView
    from kivy.lang import Builder
    
    
    Builder.load_string('''
    #:import ScrollEffect  kivy.effects.scroll.ScrollEffect
    #:import Button kivy.uix.button.Button
    <RootWidget>
        effect_cls: ScrollEffect
        GridLayout:
            size_hint_y: None
            height: self.minimum_height
            cols: 1
            on_parent:
                for i in range(10): self.add_widget(Button(text=str(i), size_hint_y=None))
    ''')
    
    class RootWidget(ScrollView):
        pass
    
    class MainApp(App):
        def build(self):
            root = RootWidget()
            return root
    
    if __name__ == '__main__':
        MainApp().run()
    

    Output:

    enter image description here