【发布时间】:2014-01-29 08:36:09
【问题描述】:
使用以下代码,在我将信息输入到我的应用程序的文本框中后,offset_back 返回一个列表和 self.main,我的 .kv 文件中用于创建滚动视图的 id 添加了布局,但是当我再次尝试重新输入数据时,会发生这种情况:“引发异常('ScrollView 只接受一个小部件')”
我是否需要以某种方式重置 self.main,如果需要,我该如何实现? 谢谢。
def set_back_offset(self):
layout = GridLayout(cols=1, spacing=10, size_hint_y=None)
layout.bind(minimum_height=layout.setter('height'))
# catch empty box input which is a str, as Decimal will throw error.
if self.initial_bet.text == str() or self.initial_odds.text == str():
pop_warning().open()
#make sure entered unicode text is numeric, if not throw pop-up warning
elif not unicode.isnumeric(self.initial_bet.text) or not unicode.isnumeric(self.initial_odds.text):
pop_warning().open()
else:# all is good, create widgets
for details in offset_back(Decimal(self.initial_bet.text), Decimal(self.initial_odds.text)):
btn = Button(text=str(details[0]), size_hint_y=None, height=40,background_color= (255,0,0,1))
layout.add_widget(btn)
self.main.add_widget(layout)
`
【问题讨论】:
标签: python user-interface kivy