繁体   English   中英

如何去除 Kivy 中两个 BoxLayout 之间的空格?

[英]How to remove the space between two BoxLayouts in Kivy?

我 state 我已经阅读了其他用户对这个问题的回答,但他们都没有帮助我。 我正在尝试使用kivy GUI 界面在 python 中编写一个计算器,他的问题是我无法删除此处所附照片中以红色突出显示的空间 我已经尝试过: size_hint: None,Nonesize: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 相对于其父BoxLayoutsize_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: "="

相应调整LabelBoxLayout的大小

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM