'How to access widget ID in nested widget in kivy

Hello i have trouble with my code in kivy.

When i added Finance2(screen) inside boxlt, i put new value inside textinput, but value from textinput wont update. When i print box2 value this has only old value. When i change value in screen1 textinput the value wont get assign in box2.

I want to know what i need to do to access id box2 throught screen1 to get updated values.

Screen 1
  boxlayout
  id:boxlt
  self.ids.boxlt.add_widget(Finance2())

Finance2(screen)
  Textinput
    id: box2


Solution 1:[1]

widgets are objects consider this example.

in ur kivy file u have something like this:

<first_screen>
    ScrollView:    
        size: root.width*0.12, root.height*0.7
        pos: root.width*1.1, root.height*0.2
        GridLayout:
            id: scrolled_grid
            height: self.minimum_height
            size_hint_y: None
            spacing: 10  
            clos: 1

In ur main.py u have this:

class first_screen(Widget):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.list_of_btns = []
        for i in range(4):            
            self.obj_btn = Button(text= 'test '+str(i), font_size='0',size_hint_x=1, size_hint_y=None, pos=(0,self.height/i), on_press=self.test)
            self.ids.scrolled_grid.add_widget(self.obj_btn)
            ### now there are 5 objectes appended to the scrolled_grid 
            ##  to keep track append them
            #   to a list  self.list_of_btns

    def test(self, instance):
        print(instance.text)  ## output is 'test' + str(i) 

    ## if u want to delete any of them u just 
           
        self.ids.scrolled_grid.remove(self.list_of_btns[0]) 
        ## this delets the first item u can loop to delete them all
   

Just remeber to keep them in a list so u can handle them later

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1