我正在寻找使用以下格式的 Kivy 库在 Python 中创建一个页面
________________________
| |
| title |
|______________________|
>>| Example 1 |<<
|______________________|
| | |
|___________|__________|
| | |
|___________|__________|
| | |
>>|___________|__________|<<
| Home |
|______________________|
| Settings |
|______________________|
箭头之间的屏幕部分应该是可滚动的。到目前为止,我对此的代码如下:
.kv 文件:
<ExampleScreen>:
BoxLayout:
orientation: 'vertical'
Label:
text: 'title'
ScrollView:
GridLayout:
cols: 1
Label:
text: 'Example 1'
GridLayout:
cols: 2
rows: 4
Label:
text: 'Filler'
Label:
text: 'Filler'
Label:
text: 'Filler'
Label:
text: 'Filler'
Label:
text: 'Filler'
Label:
text: 'Filler'
Label:
text: 'Filler'
Label:
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'
py文件:
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()
我尝试了几种方法,但没有任何效果。有没有其他人有这方面的经验/知道这是否可能?谢谢你的帮助!