简体   繁体   English

无法在 kivy 的滚动视图中滚动

[英]Can't scroll in scroll view in kivy

I need a screen with many buttons,which i am creating in cycle.It should be scrollable.我需要一个带有许多按钮的屏幕,我正在循环创建它。它应该是可滚动的。 But when i am executing this code, it works like the page size equal to scroll view widget, so i can't scroll down, it's reacting like i am overscrolling through border.Python code:但是当我执行此代码时,它的工作原理就像页面大小等于滚动视图小部件,所以我无法向下滚动,它的反应就像我正在通过边框过度滚动一样。Python 代码:

class List_of_days(Screen):
    date = date
    days = get_last_n(7,date)
    def on_enter(self, *args):
        print(self.days)
        for i in range(0,100):
            self.grid.add_widget(Button(text='ура'))

kivy file: kivy 文件:

<List_of_days>:
grid:grid
ScrollView:
    do_scroll_x: False
    BoxLayout:
        size_hint_y: None
        orientation: 'vertical'
        Button:
            size_hint_y: None
            text: "Назад"
            on_press:
                app.sm.current = 'menu'
        BoxLayout:
            size_hint_y: None
            ToggleButton:
                text: '7 дней'
                group:'number_of_days'
                id: btn_7days
            ToggleButton:
                id:btn_30days
                text: '30 дней'
                group:'number_of_days'
            ToggleButton:
                id:btn_all_days
                text: 'Все'
                group:'number_of_days'
        GridLayout:
            size_hint_y:None
            id:grid
            padding: 10,10
            spacing: 5
            row_default_height:100
            cols: 3

In you kv , add:在你kv中,添加:

height: self.minimum_height

to both the top level BoxLayout and the GridLayout .到顶层BoxLayoutGridLayout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM