title: How to get a kivy variable added to Screen from add widget()
body: <p>So im trying to get a variable added to screen and the id fro that is in a widget Im going to add,
  so if for example I have this:</p>
  <pre><code>from kivy.app import App
  from kivy.lang import Builder
  from kivy.properties import StringProperty
  
  kv = &quot;&quot;&quot;
  Screen:
      cal:cal
      side: side
  
      GridLayout:
          rows: 1
          cols:2
          spacing:0
  
          GridLayout:
              rows: 5
              cols:1
              Button:
                  text: &quot;Cube&quot;
                  # on_press: app.mode = self.text
                  on_press: app.setMode(self)
              Button:
                  text: &quot;Cuboid&quot;
                  on_press: app.setMode(self)
              Button:
                  text: &quot;Cylinder&quot;
                  on_press: app.setMode(self)
              Button:
                  text: &quot;Cone&quot;
                  on_press: app.setMode(self)
              Button:
                  text: &quot;Sphere&quot;
                  on_press: app.setMode(self)
  
          FloatLayout:
  
              Label:
                  text: &quot;The Volume and surface area of a {}:&quot;.format(app.mode)
                  pos_hint: {&quot;x&quot;:0.1, &quot;y&quot;:0.8}
                  text_size: self.size
              FloatLayout:
                  id:cal
                  Label:
                      text:&quot;Side:&quot;
                      pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.7}
                      text_size: self.size
                  Label:
                      text:&quot;Volume:&quot;                
                      pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.65}
                      text_size: self.size
                  Label:
                      text:&quot;Surface Area:&quot;                
                      pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.6}
                      text_size: self.size
                  TextInput:
                      size_hint: (.4, None)
                      height: 26
                      multiline: False
                      pos_hint: {&quot;x&quot;:1.24, &quot;y&quot;:0.7}
                      id: side
                      text: app.sideText
                      on_text_validate: app.Cube_on_side_change(self)
                  Label:                
                      text: app.volume
                      pos_hint: {&quot;x&quot;:1.27, &quot;y&quot;:0.65}
                      text_size: self.size
                  Label:
                      text: app.surface_area
                      pos_hint: {&quot;x&quot;:1.355, &quot;y&quot;:0.6}
                      text_size: self.size
  &quot;&quot;&quot;
  cube = &quot;&quot;&quot;
  FloatLayout:
      Label:
          text:&quot;Side:&quot;
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.7}
          text_size: self.size
      Label:
          text:&quot;Volume:&quot;                
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.65}
          text_size: self.size
      Label:
          text:&quot;Surface Area:&quot;                
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.6}
          text_size: self.size
      TextInput:
          size_hint: (.4, None)
          height: 26
          multiline: False
          pos_hint: {&quot;x&quot;:1.24, &quot;y&quot;:0.7}
          id: side
          text: app.sideText
          on_text_validate: app.Cube_on_side_change(self)
      Label:                
          text: app.volume
          pos_hint: {&quot;x&quot;:1.27, &quot;y&quot;:0.65}
          text_size: self.size
      Label:
          text: app.surface_area
          pos_hint: {&quot;x&quot;:1.355, &quot;y&quot;:0.6}
          text_size: self.size&quot;&quot;&quot;
  
  cuboid = &quot;&quot;&quot;
  FloatLayout:
      id:main
      Label:
          text:&quot;Length:&quot;
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.7}
          text_size: self.size
      Label:
          text:&quot;Breadth:&quot;                
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.65}
          text_size: self.size
      Label:
          text:&quot;Height:&quot;                
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.6}
          text_size: self.size
      TextInput:
          size_hint: (.4, None)
          height: 26
          multiline: False
          pos_hint: {&quot;x&quot;:1.24, &quot;y&quot;:0.7}
          id: length
          text: app.sideText
          on_text_validate: app.Cuboid_on_side_change(self)
      TextInput:
          size_hint: (.4, None)
          height: 26
          multiline: False
          pos_hint: {&quot;x&quot;:1.24, &quot;y&quot;:0.65}
          id: breadth
          text: app.sideText
          on_text_validate: app.Cube_on_side_change(self)
      TextInput:
          size_hint: (.4, None)
          height: 26
          multiline: False
          pos_hint: {&quot;x&quot;:1.24, &quot;y&quot;:0.6}
          id: height
          text: app.sideText
          on_text_validate: app.Cuboid_on_side_change()
      Label:                
          text: &quot;Volume:&quot;
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.55}
          text_size: self.size
      Label:
          text: &quot;Surface Area:&quot;
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.5}
          text_size: self.size
      Label:                
          text: app.volume
          pos_hint: {&quot;x&quot;:1.27, &quot;y&quot;:0.55}
          text_size: self.size
      Label:
          text: app.surface_area
          pos_hint: {&quot;x&quot;:1.355, &quot;y&quot;:0.5}
          text_size: self.size&quot;&quot;&quot;
  cone = &quot;&quot;&quot;
  FloatLayout:
      Label:
          text:&quot;Radius:&quot;
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.7}
          text_size: self.size
      Label:
          text:&quot;Height:&quot;                
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.65}
          text_size: self.size
      TextInput:
          size_hint: (.4, None)
          height: 26
          multiline: False
          pos_hint: {&quot;x&quot;:1.24, &quot;y&quot;:0.7}
          id: Radius
          text: app.sideText
          on_text_validate: app.Cuboid_on_side_change(self)
      TextInput:
          size_hint: (.4, None)
          height: 26
          multiline: False
          pos_hint: {&quot;x&quot;:1.24, &quot;y&quot;:0.65}
          id: height
          text: app.sideText
          on_text_validate: app.Cube_on_side_change(self)
      Label:                
          text: &quot;Volume:&quot;
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.6}
          text_size: self.size
      Label:
          text: &quot;Surface Area:&quot;
          pos_hint: {&quot;x&quot;:1.1, &quot;y&quot;:0.55}
          text_size: self.size
      Label:                
          text: app.volume
          pos_hint: {&quot;x&quot;:1.27, &quot;y&quot;:0.6}
          text_size: self.size
      Label:
          text: app.surface_area
          pos_hint: {&quot;x&quot;:1.355, &quot;y&quot;:0.55}
          text_size: self.size
  &quot;&quot;&quot;
  screens = {
      &quot;Cube&quot;: cube,
      &quot;Cuboid&quot;: cuboid,
      &quot;Cone&quot;: cone
  }
  class MyApp(App):
      sideText = StringProperty(&quot;&quot;)
      surface_area = StringProperty(&quot;0 cm²&quot;)
      volume = StringProperty(&quot;0 cm³&quot;)
      mode = StringProperty(&quot;Cube&quot;)
  
      def build(self):
          self.screen = Builder.load_string(kv)
  
          return self.screen
  
      def setMode(self, btn):
          self.volume = &quot;0 cm³&quot;
          self.surface_area = &quot;0 cm³&quot;
          self.mode = btn.text
          self.screen.cal.clear_widgets()
          self.screen.cal.add_widget(Builder.load_string(screens[self.mode]))
  
      def Cube_on_side_change(self, instance):
  
          try:
              value = float(instance.text)
              num = True
          except ValueError:
              # failed to convert
              num = False
              print(&quot;Numbers only idiot.&quot;)
  
          def cubeCalc(val):
              return {
                  &quot;volume&quot;: val * val * val,
                  &quot;surface_area&quot;: (val * val) * 6
              }
  
          if num:
              result = cubeCalc(value)
              self.volume = &quot;{:.2f} cm³&quot;.format(result[&quot;volume&quot;])
              self.surface_area = &quot;{:.2f} cm²&quot;.format(result[&quot;surface_area&quot;])
  
      def Cuboid_on_side_change(self):
          height = self.screen.cal.ids.main.height.text
          try:
              value = float(height)
              num = True
          except ValueError:
              # failed to convert
              num = False
              print(&quot;Numbers only idiot.&quot;)
  
          def cubeCalc(val):
              return {
                  &quot;volume&quot;: val * val * val,
                  &quot;surface_area&quot;: (val * val) * 6
              }
  
          if num:
              result = cubeCalc(value)
              self.volume = &quot;{:.2f} cm³&quot;.format(result[&quot;volume&quot;])
              self.surface_area = &quot;{:.2f} cm²&quot;.format(result[&quot;surface_area&quot;])
  
  
  if __name__ == &quot;__main__&quot;:
      MyApp().run() 
  </code></pre>
  <p><code>on_text_validate</code> of the <code>TextInput</code> with <code>id:height</code> in the string cuboid, I want to get the text from the text input with something like: <code>self.screen.main.height.text</code>, however, to do that I would have to add <code>main:main</code> and <code>height:height</code> to <code>Screen</code>. How would I do this?</p>