【发布时间】:2020-03-08 23:20:25
【问题描述】:
我想使用kv 语言向radiobuttons 添加滚动视图。
我的代码:
main.py
from kivymd.app import MDApp
from kivy.lang import Builder
class MyKivyApp(MDApp):
def build(self):
self.root = Builder.load_file("main.kv")
return self.root
if __name__ == "__main__":
MyKivyApp().run()
main.kv
<RadioButton@CheckBox>:
group: "radioButtons"
size_hint_y: None
height: 40
<TestLabel@Label>:
text: "Test"
color: (1, 0, 0, 1)
ScrollView:
size_hint: (1, 1)
pos_hint: {"x": 0.45}
GridLayout:
cols: 1
padding: 10
spacing: 15
size_hint_y: None
size_hint_x: None
width: dp(100)
height: self.minimum_height
TestLabel:
text: "Main Label"
TextInput:
id: oneTxt
pos_hint: {"top": 0.1}
size_hint: (1, 1)
Button:
id: btn1
text: "Button 1"
pos_hint: {"top": 0.4}
GridLayout:
cols: 2
padding: 0
spacing: 0
size_hint_y: None
size_hint_x: None
height: self.minimum_height
RadioButton:
TestLabel:
text: "Test1"
RadioButton:
TestLabel:
text: "Test2"
RadioButton:
TestLabel:
text: "Test3"
RadioButton:
TestLabel:
text: "Test4"
RadioButton:
TestLabel:
text: "Test5"
RadioButton:
TestLabel:
text: "Test6"
RadioButton:
TestLabel:
text: "Test7"
RadioButton:
TestLabel:
text: "Test8"
RadioButton:
TestLabel:
text: "Test9"
RadioButton:
TestLabel:
text: "Test10"
RadioButton:
TestLabel:
text: "Test11"
RadioButton:
TestLabel:
text: "Test12"
RadioButton:
TestLabel:
text: "Test13"
RadioButton:
TestLabel:
text: "Test14"
RadioButton:
TestLabel:
text: "Test15"
RadioButton:
TestLabel:
text: "Test16"
RadioButton:
TestLabel:
text: "Test17"
RadioButton:
TestLabel:
text: "Test18"
RadioButton:
TestLabel:
text: "Test19"
RadioButton:
TestLabel:
text: "Test20"
RadioButton:
TestLabel:
text: "Test21"
RadioButton:
TestLabel:
text: "Test22"
RadioButton:
TestLabel:
text: "Test23"
RadioButton:
TestLabel:
text: "Test24"
RadioButton:
TestLabel:
text: "Test25"
RadioButton:
TestLabel:
text: "Test26"
RadioButton:
TestLabel:
text: "Test27"
RadioButton:
TestLabel:
text: "Test28"
RadioButton:
TestLabel:
text: "Test29"
RadioButton:
TestLabel:
text: "Test30"
RadioButton:
TestLabel:
text: "Test31"
RadioButton:
TestLabel:
text: "Test32"
TestLabel:
text: "End Label"
Button:
id: btn2
text: "Button 2"
pos_hint: {"top": 0.8}
滚动有效,但其他小部件很小并且相互重叠。查看下图:
如何解决?谢谢。
【问题讨论】:
标签: python kivy kivy-language