[英]How to remove the space between two BoxLayouts in Kivy?
I state that I have already read the answers of other users to this question but none of them helped me.我 state 我已经阅读了其他用户对这个问题的回答,但他们都没有帮助我。 I'm trying to program a calculator in python with the kivy GUI interface ,he problem is that i can't remove that space highlighted in red in the attached photo down here.
我正在尝试使用kivy GUI 界面在 python 中编写一个计算器,他的问题是我无法删除此处所附照片中以红色突出显示的空间。 I have already tried with:
size_hint: None,None
and size:root.size[0], "5dp"
to scale the BoxLayouts but it doesn't worked我已经尝试过:
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
Your problem is that you are setting size_hint
of the Buttons relative to its parent BoxLayout
.您的问题是您正在设置 Buttons 相对于其父
BoxLayout
的size_hint
。 So in effect your BoxLayout's are taking up 1/3 of the available space (because there are three widgets in BoxLayoutExample
.因此,实际上您的 BoxLayout 占用了 1/3 的可用空间(因为
BoxLayoutExample
中有三个小部件。
Here is how to fix it:以下是解决方法:
<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: "="
Adjust the size of the Label
and the BoxLayout
accordingly相应调整
Label
和BoxLayout
的大小
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.