[英]How can I put a button to be always in the center and bottom of my App?
我想在应用程序的中央和底部放置一个“更新按钮”,但是我还需要在屏幕上添加一些小部件。 我将BoxLayout始终放置在应用程序的中央和底部,但是我需要在其中放置一个Button,并且它也必须始终位于BoxLayout中央的底部。 我做了什么:
我的.kv源代码:
<WindowMain>:
orientation: 'horizontal'
BoxLayout:
orientation: 'vertical'
size_hint: .1, .1
pos_hint: {"x":1., "bottom":1.}
padding: 2
Button:
size_hint: .2, 1.
pos_hint: {'x': .5, 'y': 1.}
font_name: 'consola'
text: 'Update'
您可以在按钮的左侧和右侧添加两个空标签,并使用size_hint
属性将其size_hint
。
您可以使用“ FloatLayout”相对于主窗口定位小部件。
在py中:
from kivy.uix.floatlayout import FloatLayout
class MainWindow(FloatLayout):
pass
在kv中:
<WindowMain>:
Button:
size_hint: .2, .1
pos_hint: {'x': .4, 'y': 0}
font_name: 'consola'
text: 'Update'
这应该使按钮开始于40%,结束于60%,即高10%。 然后,您可以在FloatLayout中的任意位置添加其他小部件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.