【发布时间】:2021-07-24 21:19:47
【问题描述】:
这是运行 kivy 的 python 脚本的一部分:
class someclass(Widget):
# code
# code
Clock.schedule_interval(self.timeandlog, 0.1)
self.x = 20
def timeandlog(self,dt):
if condition == True: #
self.ids.pofchild.add_widget(Label(text=logmsg, pos = (10, self.x)))
self.x = self.x + 10 ### just playing with position
condition = False
kv 文件:
<someclass>
#somelabels and buttons:
ScrollView:
do_scroll_x: False
do_scroll_y: True
pos: root.width*0.3, root.height*0.7
size: root.width*0.8, root.height*0.7
Widget:
cols: 1
spacing: 10
id: pofchild
现在我知道ScrollView 接受一个Widget,所以我只添加了一个id: pofchild,然后我在其中添加了self.ids.pofchild.add_widget(Label() 的标签,并将每个新标签的pos 更改为pos=(20, self.x),但标签不可滚动,仅填充小部件高度然后停止出现。什么是正确的属性,以便它们可以滚动?
【问题讨论】:
标签: python kivy scrollview