我是python和kivy的新手,所以请温柔:)
我有3个标签,希望应用程序在按下button1和button2时显示下一个标签,并在按下按钮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()
答案 0 :(得分:0)
TabbedPanel.switch_to对我来说似乎很简单。只需在这三个using (FileStream fsSourceDDS = new FileStream(strDDSFilename, FileMode.Open, FileAccess.Read))
using (BinaryReader binaryReader = new BinaryReader(fsSourceDDS))
{
fsSourceDDS.Seek(0x0c, SeekOrigin.Begin);
ushort with = binaryReader.ReadUInt16();
fsSourceDDS.Seek(0x10, SeekOrigin.Begin);
ushort height = binaryReader.ReadUInt16();
}
中使用它:
on_press
root.switch_to(root.tab_list[1])
root.switch_to(root.tab_list[0])
root.switch_to(root.tab_list[2])
处于“反转”状态 - 最后添加的tab_list
是列表中的第一项。