Better Stack Layout kivy python

Viewed 55

I'm new in kivy, and creating my own app i had a question how to create a better stack layout. I wanted to create a stack layout like in Pinterest

[Something like that]

1

I simplified my code very much, just to realize main methods

from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivymd.app import MDApp
from kivy.uix.button import Button
import random

KV = '''
MyScreen:
    id1:id1
    MDBoxLayout:
        orientation:'vertical'
        Button:
            size_hint_y:0.2
            text:'add'
            on_release:
                root.custom_add_widget(root.id1)
        StackLayout:
            id:id1
            orientation:'lr-tb'
'''

class MyScreen(Screen):
    counter = 0
    def custom_add_widget(self,id):
        MyWidget=Button()
        MyWidget.text=str(MyScreen.counter)
        MyScreen.counter=MyScreen.counter+1
        MyWidget.size_hint_x=1/3
        MyWidget.size_hint_y=1/random.randint(2,10)
        id.add_widget(MyWidget)


class TestCard(MDApp):
    def build(self):
        return Builder.load_string(KV)


TestCard().run()

How can i move those buttons [like that]

2

Does anyone have any ideas?

P.s: I understand that i can change orientation to 'tb-lr', but i want something like infinite ScrollView and to fill it with new objects by lines

0 Answers
Related