kivy入门之布局(二)

创建盒子布局加之嵌套布局

复制代码
 1 from kivy.app import App
 2 from kivy.core.text import LabelBase
 3 from kivy.uix.boxlayout import BoxLayout
 4 
 5 LabelBase.register("Roboto", "msyhl.ttc")
 6 
 7 
 8 class Test7Layout(BoxLayout):
 9     """盒子布局之嵌套布局"""
10 
11     def __init__(self, **kwargs):
12         super(Test7Layout, self).__init__(**kwargs)
13 
14 
15 class Test7App(App):
16     def build(self):
17         return Test7Layout()
18 
19 
20 if __name__ == '__main__':
21     Test7App().run()
复制代码

kv语言:

复制代码
 1 <Test7Layout>:
 2     orientation:'vertical'
 3     Button:
 4         text:'只有永不遏止的奋斗'
 5     Button:
 6         text:'才能使青春之花'
 7     BoxLayout:
 8         orientation:'horizontal'
 9         Button:
10             text:'即便是凋谢'
11         Button:
12             text:'也是壮丽地凋谢'
复制代码

运行界面显示:

posted on   默玖  阅读(177)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示