[英]How to remove the space between two BoxLayouts in Kivy?
我 state 我已經閱讀了其他用戶對這個問題的回答,但他們都沒有幫助我。 我正在嘗試使用kivy GUI 界面在 python 中編寫一個計算器,他的問題是我無法刪除此處所附照片中以紅色突出顯示的空間。 我已經嘗試過: size_hint: None,None
和size:root.size[0], "5dp"
來縮放 BoxLayouts 但它不起作用
[1]: https://i.stack.imgur.com/y1ZwF.png
BoxLayoutExample:
<BoxLayoutExample>:
orientation: "vertical"
Label:
text: "0"
font_size: "30dp"
BoxLayout:
orientation: "horizontal"
Button:
text: "7"
size_hint: .1, .3
Button:
text: "4"
size_hint: .1, .3
Button:
text: "1"
size_hint: .1, .3
BoxLayout:
orientation: "horizontal"
Button:
text: ","
size_hint: .1, .3
Button:
text: "0"
size_hint: .1, .3
Button:
text: "="
size_hint: .1, .3
您的問題是您正在設置 Buttons 相對於其父BoxLayout
的size_hint
。 因此,實際上您的 BoxLayout 占用了 1/3 的可用空間(因為BoxLayoutExample
中有三個小部件。
以下是解決方法:
<BoxLayoutExample>:
orientation: "vertical"
Label:
text: "0"
font_size: "30dp"
size_hint: 1, .8
BoxLayout:
orientation: "horizontal"
size_hint: 1, .1
Button:
text: "7"
Button:
text: "4"
Button:
text: "1"
BoxLayout:
orientation: "horizontal"
size_hint: 1, .1
Button:
text: ","
Button:
text: "0"
Button:
text: "="
相應調整Label
和BoxLayout
的大小
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.