【发布时间】:2015-05-07 21:23:12
【问题描述】:
我有以下代码可以生成行条目的滚动视图。
import ...
class DigestApp(App):
def build(self):
s = ScrollView()
b = BoxLayout(orientation='vertical', size_hint=[1, 5])
header = BoxLayout(orientation='horizontal')
header1 = Label(text='#', size_hint=[.35, 1])
header2 = Label(text='header', size_hint=[6, 1])
checkAll = BoxLayout(orientation='horizontal')
header3 = Label(text='Check All')
header4 = CheckBox()
checkAll.add_widget(header3)
checkAll.add_widget(header4)
header.add_widget(header1)
header.add_widget(header2)
header.add_widget(checkAll)
b.add_widget(header)
for i in range(100):
b1 = BoxLayout(orientation='horizontal')
n = Label(text=str(i+1), size_hint=[.35, 1])
l = Button(text='> test header 01 02 03 04 050000000000000000000000000000000000', size_hint=[6, 1])
c = CheckBox()
b1.add_widget(n)
b1.add_widget(l)
b1.add_widget(c)
b.add_widget(b1)
s.add_widget(b)
return(s)
if __name__ == '__main__':
DigestApp().run()
产生以下输出(滚动查看所有 100 行):
这看起来很棒,只有 100 行(对于 i in range(100)),但是当我尝试添加 1000 行时,我得到以下结果。
需要注意的是,滚动功能是工作的,但显示显然是不可取的。
似乎即使我的滚动视图在 100 行中按预期工作,它也不能正确扩展到更大的数字。这是必要的,因为我可能需要一个有数万行的窗口。
我忽略了什么参数来解释这种缩放?
【问题讨论】:
标签: python scrollview kivy