将小部件插入布局的开头。基维

时间:2020-05-08 22:00:59

标签: python kivy scrollview stacklayout

我试图了解StackLayout如何在Kivy的ScrollView中工作。而且我有一个问题。我不知道如何在布局的开头插入小部件。如果我使用.add_widget()方法,则它将小部件添加到布局的末尾(在底部)。如果我更改布局的方向 具有堆叠ID)到“ lr-bt”,然后添加小部件(带有“ Title”和“ Print”标签),然后从ScrollView的顶部进行填充。所以这就是我得到的:

padding from the top

请允许我们使用其他布局。如果有人可以帮助我修复顶部填充或在开始时插入小部件,那就太好了。谢谢。

以下是.py文件中的一些代码:

pln = Plan(text_label="Title", text="Print")
self.root.ids.stacking.add_widget(pln)

这是我的ScrollView和.kv文件中的StackLayout:

            BoxLayout:
                id: stack_box
                size_hint_y: 1
                pos: 2, root.height-1057
                RecycleView:
                    scroll_y: 1
                    do_scroll_x: False
                    do_scroll_y: True
                    size_hint: 1, None
                    height: 1000
                    id: scroll_plans
                    StackLayout:
                        spacing: 10
                        padding: 10
                        id: stacking
                        orientation: 'lr-bt'
                        size_hint_y: None
                        height: 9000

0 个答案:

没有答案