我用Kivy创建了一个嵌套的盒子布局,这很有效。但是我需要在Python代码中调用三个类。有没有更优雅的方法?例如,在Python中只有一个类
Python代码:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
class HorizLayout1(BoxLayout):
pass
class HorizLayout2(BoxLayout):
pass
class VertLayout(BoxLayout):
pass
class KivyTestsApp(App):
def build(self):
return VertLayout()
if __name__ == '__main__':
KivyTestsApp().run()
千伏安:
<HorizLayout1>:
orientation: "horizontal"
Button:
text: "1"
Button:
text: "2"
<HorizLayout2>:
orientation: "horizontal"
Button:
text: "3"
Button:
text: "4"
<VertLayout>:
orientation: "vertical"
HorizLayout1:
HorizLayout2:
您的
py
可以是:。。。你的
kv
可能是这样的:相关问题 更多 >
编程相关推荐