【发布时间】:2021-03-19 21:55:00
【问题描述】:
我正在尝试构建一个结构,该结构将包含多列数据,这些数据将被更新并且必须一起滚动。
整个应用程序有多个页面,等等。它的标签构建部分看起来确实有效,因为它将“hello world”放在页面的右侧部分。但是,即使我使用的是“索引”属性,它似乎也将所有数据都填充在彼此之上。以下是 py 和 kv 文件中的一些 sn-ps:
class RV(FloatLayout):
def re_build(self):
label_list = [Label(text = "Label {}".format(x)) for x in range(20)]
for count, x in enumerate(label_list):
self.add_widget(Label(text='Hello World'), index = count)'
class MainScreen(Screen):
pass
class ScreenManagement(ScreenManager):
pass
class TestApp(App):
def build(self):
return ScreenManagement()
if __name__ == '__main__':
# Here the class MyApp is initialized
# and its run() method called.
TestApp().run()
<ScreenManagement>:
padding: 10
MainScreen:
id: main_screen
name: 'main_screen'
<MainScreen>:
GridLayout:
rows:3
cols:1
Button:
size_hint: 1, None
height: 50
text: "just setting up"
on_press:
root.ids.rv.re_build()
RV:
id: rv
GridLayout:
rows:3
cols:2
size_hint : None, None
CheckBox:
active:False
Label:
text: 'item 1'
CheckBox:
active:False
Label:
text: 'item 2'
CheckBox:
active:False
Label:
text: 'item 3'
任何帮助表示赞赏
【问题讨论】: