获取 ReferenceListProperty kivy 的 NumericProperty
Get NumericProperty of ReferenceListProperty kivy
我有一些代码:
A = NumericProperty(1)
B = NumericProperty(2)
C = ReferenceListProperty(A, B)
如何取回 ReferenceListProperty 的 NumericProperty?
C[0]
returnsA 和C[1]
returnsB
这是一个包含您的值的小型示例应用程序,它从 C (.py) 打印 A 和 B
from kivy.app import App
from kivy.base import Builder
from kivy.properties import NumericProperty, ReferenceListProperty
from kivy.uix.boxlayout import BoxLayout
Builder.load_string("""
<rootwi>:
Button:
text: 'print A via ReferenceListProperty'
on_press: print(root.C[0])
Button:
text: 'print B via ReferenceListProperty'
on_press: print(root.C[1])
""")
class rootwi(BoxLayout):
A = NumericProperty(1)
B = NumericProperty(2)
C = ReferenceListProperty(A, B)
class MyApp(App):
def build(self):
return rootwi()
if __name__ == '__main__':
MyApp().run()
class MyApp(App):
def build(self):
return rootwi()
if __name__ == '__main__':
MyApp().run()
我有一些代码:
A = NumericProperty(1)
B = NumericProperty(2)
C = ReferenceListProperty(A, B)
如何取回 ReferenceListProperty 的 NumericProperty?
C[0]
returnsA 和C[1]
returnsB
这是一个包含您的值的小型示例应用程序,它从 C (.py) 打印 A 和 B
from kivy.app import App
from kivy.base import Builder
from kivy.properties import NumericProperty, ReferenceListProperty
from kivy.uix.boxlayout import BoxLayout
Builder.load_string("""
<rootwi>:
Button:
text: 'print A via ReferenceListProperty'
on_press: print(root.C[0])
Button:
text: 'print B via ReferenceListProperty'
on_press: print(root.C[1])
""")
class rootwi(BoxLayout):
A = NumericProperty(1)
B = NumericProperty(2)
C = ReferenceListProperty(A, B)
class MyApp(App):
def build(self):
return rootwi()
if __name__ == '__main__':
MyApp().run()
class MyApp(App):
def build(self):
return rootwi()
if __name__ == '__main__':
MyApp().run()