Kivy问题中的中心单选按钮

时间:2020-03-10 00:48:14

标签: python kivy kivy-language

我想将kv文件中的单选按钮(带有组和文本标签的复选框)居中。我已将它们添加到ScrollView中,但是这些小部件之间有很多空间。

代码:

        ScrollView:
            size_hint: (1, 1)

            GridLayout:
                cols: 1
                padding: 0
                spacing: 0, 0
                size_hint: (1, None)
                height: self.minimum_height

                BoxLayout:
                    orientation: "horizontal"
                    size_hint_x: 0.60
                    spacing: 0
                    padding: 0
                    pos_hint: {"center_x": 0.5}
                    size_hint_y: None

                    CheckBox:
                        group: "notIdentReason"
                    Label:
                        text: "Sample rejected"
                        font_size: 24
                        color: 0, 0, 0, 1

                BoxLayout:
                    orientation: "horizontal"
                    size_hint_x: 0.60
                    spacing: 0
                    padding: 0
                    pos_hint: {"center_x": 0.5}
                    size_hint_y: None

                    CheckBox:
                        group: "notIdentReason"
                    Label:
                        text: "Unsubtyping"
                        font_size: 24
                        color: 0, 0, 0, 1

                BoxLayout:
                    orientation: "horizontal"
                    size_hint_x: 0.60
                    spacing: 0
                    padding: 0
                    pos_hint: {"center_x": 0.5}
                    size_hint_y: None

                    CheckBox:
                        group: "notIdentReason"
                    Label:
                        text: "Other"
                        font_size: 24
                        color: 0, 0, 0, 1

截屏:

enter image description here

如何删除单选按钮和标签之间的空间?谢谢。

1 个答案:

答案 0 :(得分:1)

我认为关键是为您的minimum_sizeGridLayout使用BoxLayouts,并设置其子级CheckBox和{{1} }。像这样:

Label