滚动视图甚至无法在KV文件中实例化-Kivy

时间:2018-12-06 13:26:00

标签: python kivy kivy-language

我试图基于csv文件中的数据构建布局。 尽管成功创建了BoxLayout,但是scrollview无法正常工作。也许我的代码令人困惑,这是因为我尝试了很多形式来证明正确。 KV文件:

<testeCsv>
    BoxLayout:
        orientation:'vertical'
        ScrollView:
            id:scroll
            BoxLayout:
                id:boxCsv
                orientation:'vertical'
                spacing:30
                height:self.minimum_height
        BoxLayout:
            size_hint_y:None
            height:60
            Button:
                id:botaoVoltar
                text:'voltar'
                size_hint_x:None
                width:60
                on_release:root.sair()

PY文件:

class testeCsv(Screen):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.df1 = pandas.read_csv('Roteiros\Enderecos.csv')
        self.df1["Address"] = self.df1["Address"] + "," + self.df1["City"] + "," + self.df1["State"] + "," + self.df1["Country"]
        self.tarefas = list()
        for x in range(len(self.df1)):
            self.tarefas.append(self.df1.iloc[x])

    def on_enter(self, **kwargs):
        if len(self.ids) == 0:
            Clock.schedule_once(self.criarWidget())
        else:
            self.criarWidget()
    def criarWidget(self):

        for x in range(len(self.df1)):
            self.tarefas.append(self.df1.iloc[x])
        for z in range(len(self.df1)):
            self.ids.boxCsv.add_widget(Label(text=str(self.tarefas[z]), font_size=10, id=str(z)))

0 个答案:

没有答案