-1

Hi i was trying to access the property of an object from a different class using self.ids.. but i get this annoying error AttributeError: 'super' object has no attribute '__getattr__' Here is my Code when i click the "Button for boys" i get the error

.py file

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty

class Get_People(BoxLayout):
      root_lbl=ObjectProperty()

class Get_Boys(BoxLayout):
     label_b=ObjectProperty()

     def show(self):
          self.ids. root_lbl.text='i am called'


class lstApp(App):
   def build(self):
        self.load_kv('dates_test.kv')
        return Get_People()

if __name__=='__main__':
      lstApp().run() 

here is the .Kv file

<Get_People>:
      root_lbl: root_lbl
      orientation: 'vertical'

      Button:
          name: root_btn
          id: root_btn
          text: "I am Root Button"
       Label:
          id: root_lbl
          text: "I am Root Label"
       Get_Boys:

<Get_Boys>:
    label_b: label_b
    Button:
        id: button_b
        text: "Button for boys"
        on_press: root.show()

    Label:
        id: label_b
        text: "Label for boys"
Ronald Saunfe
  • 561
  • 6
  • 20

1 Answers1

0

If we observe we see that the children of Get_Boys are button_b and label_b so those are the elements that can be accessed through ids. But if we look in Get_People, Get_Boys is a child so you can access Get_People through the parent method, and then access through root_lbl:

class Get_Boys(BoxLayout):
     label_b=ObjectProperty()

     def show(self):
        self.parent.root_lbl.text='i am called'
eyllanesc
  • 235,170
  • 19
  • 170
  • 241