我宣告我已經閱讀了其他用戶對這個問題的回答,但沒有一個對我有幫助。我正在嘗試使用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
uj5u.com熱心網友回復:
您的問題是您正在設定size_hintButtons 相對于其 parent BoxLayout。因此,實際上您的 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相應
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/365034.html
上一篇:在Tkinter中隱藏元素
