title: Kivy: Variable in a class?
body: <p>I'm currently working to update a bunch of labels with a button press, which I was able to get an answer with through <a href="https://stackoverflow.com/questions/47503913/kivy-how-to-refernce-kv-id-in-python">Kivy: How to refernce kv ID in Python?</a></p>
  
  <p>However, now that I'm in my actual app, I need the functionality to be able to take a <em>user input</em> value and update existing labels. I've modified the example slightly where I'm just taking a user input for a starting number, adding one with each button click and displaying the running total to the right of all of this. </p>
  
  <p>The code I have now is shown below, but the addition of 1 doesn't seem to be processing (it's just staying with the same total after a click). Any ideas why? Thanks very much!</p>
  
  <p>This is the display before the button is clicked (running total is just the user input): </p>
  
  <p><a href="https://i.stack.imgur.com/iDUlk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iDUlk.png" alt="enter image description here"></a></p>
  
  <p>My Python file: </p>
  
  <pre><code>from kivy.app import App
  from kivy.uix.boxlayout import BoxLayout
  from kivy.uix.widget import Widget
  from kivy.properties import StringProperty
  
  import random
  
  class TestingWidget(BoxLayout):
  
      # This is the kv id of the Label I would like to update
      starting_number = StringProperty('Put your Starting Number here')
      running_total = StringProperty(str(0))
  
      #default text set
      # This is the action I would like to happen when the button is pressed
      def button_pressed(self):
          self.running_total = str(int(self.running_total) + 1)
  
  class TestButtonApp(App):
      def build(self):
          return TestingWidget()
  
  if __name__ == '__main__':
      TestButtonApp().run()
  </code></pre>
  
  <p>My kv file: </p>
  
  <pre><code>&lt;TestingWidget&gt;:
      BoxLayout:
          orientation: 'horizontal'
          TextInput:
              id: starting_number
              hint_text: root.starting_number
          Button: 
              id: add_one_button
              text: 'Add 1 to Starting Number'
              on_press: root.button_pressed()
          Label:
              id: running_total
              text: starting_number.text
  </code></pre>