Search code examples
pythonpython-3.xkivykivy-language

Python Kivy ScrollViev


Could someone send me an example of code in kivy language if possible, containing simple horizontal boxlayout where's on one side a scrollview with buttons and on the other side just a label named "test label". I cant figure how the scrollview works and im sure that'd help. I've found this, but that looks really compicated to me and i can't understand it.


Solution

  • the scrollview most contain one widget and commonly will be a Layout contains many widgets or one big widget here a simple example

    main.py :

    
    from kivy.app import App
    
    
    class Main(App):
        pass
    Main().run()
    

    main.kv file

    BoxLayout:
        orientation:'horizontal'
        Label:
            text:'test label'
        ScrollView:
            BoxLayout:
                orientation:"vertical"
                size_hint_y:None
                height:self.minimum_height
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
    
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'
                Button:
                    size_hint_y:None
                    height:'100dp'