我试图将方法绑定到微调器的文本值。它需要在显示TestScreen之前绑定。如果我不使用屏幕管理器(例如如果测试应用程序构建返回TestScreen而不是TestScreenManager)。什么时候测试应用程序构建返回TestScreenManager当我引用自我.ids在TestScreen.__init__
AttributeError: 'super' object has no attribute '__getattr__'
在测试.py在
^{pr2}$在试验电压在
<TestScreen>:
name: "World Screen"
BoxLayout:
orientation: 'vertical'
Label:
text: "Name"
font_size: 30
BoxLayout:
Label:
text: "Active Selection"
size_hint_x: .5
Spinner:
id: test_spinner
text: "Value1"
values: ["Value1", "Value2"]
Button:
text: "Print spinner value"
on_press: root.print_spinner_value()
<TestScreenManager>:
TestScreen:
我已经尝试在on_enter方法中绑定该方法,但是我得到了相同的错误。然而,自我.ids如果我注释掉自我.ids初始化函数中的语句。在
目前,每次按下微调器时,我都可以通过绑定函数来找到解决方法。但这似乎不是解决问题的最佳方法
on_press: self.bind(text=root.on_spinner_select)
所以我的问题是:在使用ScreenManager时,如何在加载时将方法绑定到微调器?在
尝试使用
__init__(self, *args, **kwargs)
。 使用**kwargs只假设输入总是某种关键字参数(例如dicts)。这几乎就是错误的意思,因为它试图从您传递的参数中获取所有属性。在我想当你尝试绑定这个方法时,你的屏幕初始化还没有完成。试试这个:
相关问题 更多 >
编程相关推荐