我想知道在创建小部件期间在哪里可以查看和使用数据上给出的参数。
问题:看起来__init__
没有信息,所以必须在调用之后,所以我想知道什么时候可以使用我的自定义参数。
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.recycleview import RecycleView
from kivy.factory import Factory as F
Builder.load_string('''
<RV>:
viewclass: 'CustomLabel'
RecycleBoxLayout:
default_size: None, dp(56)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
''')
class CustomLabel(F.Label):
def __init__(self, **kwargs):
super().__init__(**kwargs)
print(kwargs, "why can't I see the stuff from data ???")
class RV(RecycleView):
def __init__(self, **kwargs):
super(RV, self).__init__(**kwargs)
self.data = [{'text': str(x), "new_parameter":"idk where am I"} for x in range(100)]
class TestApp(App):
def build(self):
return RV()
if __name__ == '__main__':
TestApp().run()