kivy入门之布局(三)

创建锚点布局

复制代码
 1 from kivy.app import App
 2 from kivy.core.text import LabelBase
 3 from kivy.uix.anchorlayout import AnchorLayout
 4 
 5 LabelBase.register("Roboto", "msyhl.ttc")
 6 
 7 
 8 class Test8layout(AnchorLayout):
 9     """锚点布局"""
10     ...
11 
12 
13 class Test8App(App):
14     def build(self):
15         return Test8layout()
16 
17 
18 if __name__ == '__main__':
19     Test8App().run()
复制代码

kv语言:

复制代码
 1 <Test8layout>:
 2     padding:20
 3     AnchorLayout:
 4         anchor_x:'left'
 5         anchor_y:'top'
 6         Button:
 7             text:'只有永不遏止的奋斗'
 8             size_hint: .3, .2
 9     AnchorLayout:
10         anchor_x:'right'
11         anchor_y:'bottom'
12         Button:
13             text:'才能使青春之花'
14             size_hint:.3,.2
复制代码

运行界面显示:

 

posted on   默玖  阅读(104)  评论(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

导航

统计

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