[英]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.