我是 python 和 kivy 的新手,所以请温柔:)
我有 3 个选项卡,并希望应用程序在按下按钮 1 和按钮 2 时显示下一个选项卡,并在按下按钮 3 时自行关闭。如果可能的话,我想使用 kivy builder 来做到这一点。
请帮忙 :/
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.lang import Builder
class Root(TabbedPanel):
pass
Builder.load_string('''
<Root>
do_default_tab: False
size_hint: 1, 1
post_hint: {'center_x': .5, 'y': .5}
do_default_tab: False
TabbedPanelItem:
text: 'Step 1'
FloatLayout:
Button:
id: button1
size_hint: .10, .10
pos: 1350, 40
orientation: 'vertical'
text: 'Next!'
on_press: print("go to next step") #need help
TabbedPanelItem:
text: 'Step 2'
FloatLayout:
Button:
id: button2
size_hint: .10, .10
pos: 1350, 40
orientation: 'vertical'
text: 'Next!'
on_press: print("go to next step") #need help
TabbedPanelItem:
text: 'Step 3'
FloatLayout:
Button:
id: button3
size_hint: .10, .10
pos: 1350, 40
orientation: 'vertical'
text: 'The End.'
on_press: print("exiting") #need help
''')
class TabbedPanelApp(App):
def build(self):
return Root()
if __name__ == '__main__':
TabbedPanelApp().run()