The ids are not set at the time __init__ executes.
The method on_kv_post is passed the base_widget, in this case MainRoot.
In kv, the root widget (there is no root widget defined in the kv in this example), and each rule have their own ids dict.
Try the example below:
The output:
{'sm': <WeakProxy to <kivy.uix.screenmanager.ScreenManager object at 0x0457D6F8>>, 'first_screen': <WeakProxy to <Screen name=''>>, 'root2_screen': <WeakProxy to <Screen name=''>>}
{'smr2': <WeakProxy to <kivy.uix.screenmanager.ScreenManager object at 0x09F788F0>>, 'nav_drawer': <WeakProxy to <kivy.uix.button.Button object at 0x09F9C2D0>>}
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
kv = """
<First@Screen>:
<MainRoot>:
ScreenManager:
id: sm
First:
id: first_screen
Root2:
id: root2_screen
<Root2>:
BoxLayout:
ScreenManager:
id:smr2
Button:
id: nav_drawer
"""
Builder.load_string(kv)
class Root2(Screen):
def on_kv_post(self, obj):
print(obj.ids)
print(self.ids)
class MainRoot(Screen):
pass
class PhysicsExam(App):
def build(self):
return MainRoot()
PhysicsExam().run()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e22bb1d3-43d2-47f0-8d6b-38a1e99bb530o%40googlegroups.com.