Python 如何使Kivy屏幕的一部分可滚动

Python 如何使Kivy屏幕的一部分可滚动,python,kivy,kivy-language,Python,Kivy,Kivy Language,我希望使用以下格式的Kivy库在Python中创建一个页面 ________________________ | | | title | |______________________| >>| Example 1 |<< |______________________| | | |

我希望使用以下格式的Kivy库在Python中创建一个页面

    ________________________
    |                      |
    |        title         |
    |______________________|
  >>|       Example 1      |<<
    |______________________|
    |           |          |
    |___________|__________|
    |           |          |
    |___________|__________|
    |           |          |
  >>|___________|__________|<<
    |         Home         |
    |______________________|
    |       Settings       |
    |______________________|         

我尝试了几种方法来实现这一点,但没有任何效果。其他人是否有这方面的经验/是否知道这是可能的?谢谢你的帮助

是的,如果压痕和尺寸提示正确,这是可能的。

试试这个:

<MyLabel@Label>:
    size_hint:1,None

<ExampleScreen>:
    BoxLayout:
        orientation: 'vertical'
        Label:
            text: 'title'
        ScrollView:
            size_hint: 1,None
            GridLayout:
                size_hint: 1,None
                height: self.minimum_height
                cols: 1
                MyLabel:
                    text: 'Example 1'
                GridLayout:
                    size_hint: 1,None
                    height: self.minimum_height
                    cols: 2
                    rows: 4                
                    MyLabel:
                        text: 'Filler' 
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel: 
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'

        Button: 
            text: 'Home'
            size_hint: 1, .1
            on_press: root.manager.current = 'home'
        Button:
            text: 'Settings'
            size_hint: 1, .1
            on_press: root.manager.current = 'settings'
:
大小提示:1,无
:
盒子布局:
方向:“垂直”
标签:
文本:“标题”
滚动视图:
大小提示:1,无
网格布局:
大小提示:1,无
高度:自身最小高度
科尔斯:1
MyLabel:
文本:“示例1”
网格布局:
大小提示:1,无
高度:自身最小高度
科尔斯:2
行数:4
MyLabel:
文本:“填充”
MyLabel:
文本:“填充”
MyLabel:
文本:“填充”
MyLabel:
文本:“填充”
MyLabel:
文本:“填充”
MyLabel:
文本:“填充”
MyLabel:
文本:“填充”
MyLabel:
文本:“填充”
按钮:
文字:“家”
大小提示:1、.1
按:root.manager.current='home'
按钮:
文本:“设置”
大小提示:1、.1
按:root.manager.current='settings'
from kivy.uix.gridlayout import GridLayout
from kivy.uix.scrollview import ScrollView
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.button import Button
from kivy.lang import Builder

Builder.load_file('example.kv')

class ExampleScreen(Screen):
    pass

sm = ScreenManager()

sm.add_widget(ExampleScreen(name = 'example'))

class TestApp(App):
    def build(self):
        return sm

if __name__ == '__main__':
    TestApp().run()
<MyLabel@Label>:
    size_hint:1,None

<ExampleScreen>:
    BoxLayout:
        orientation: 'vertical'
        Label:
            text: 'title'
        ScrollView:
            size_hint: 1,None
            GridLayout:
                size_hint: 1,None
                height: self.minimum_height
                cols: 1
                MyLabel:
                    text: 'Example 1'
                GridLayout:
                    size_hint: 1,None
                    height: self.minimum_height
                    cols: 2
                    rows: 4                
                    MyLabel:
                        text: 'Filler' 
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel: 
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'

        Button: 
            text: 'Home'
            size_hint: 1, .1
            on_press: root.manager.current = 'home'
        Button:
            text: 'Settings'
            size_hint: 1, .1
            on_press: root.manager.current = 'settings'