Dynamically update label text in kivy program (Python)
<p>New to the kivy library and having some trouble dynamically updating a property.  The label here is just a place-holder.  Ultimately I want the displayed image to change sequentially based on which quadrant the user clicks/touches.</p>

<p>The program runs fine with no errors, hover the label (label2) does not update (label1 does update).  When I click on the four quadrants the quadrant number is displayed to the console as I would expect.  I'm also printing out the self.incr whenever the user clicks on Q1 and this also displays and increases which means the incr attribute is increasing as it should.</p>

<p>So, I can't figure out why it doesn't update for the label.</p>

<p>main.py</p>

<pre><code>from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.image import Image

class TouchInput(Widget):

    def __init__(self,**kwargs):
        self.incr = 5
        super(TouchInput,self).__init__(**kwargs)

    def on_touch_up(self, touch):

        if touch.x &lt; self.width / 2:
            lateral = 'left'
        elif touch.x &gt; self.width / 2:
            lateral = 'right'
        else:
            lateral = None

        if touch.y &lt; self.height / 2:
            vertical = 'bottom'
        elif touch.y &gt; self.height / 2:
            vertical = 'top'
        else:
            vertical = None

        if vertical and lateral:
            if lateral == 'left' and vertical == 'top':
                quadrant = 1
                print 'Q1'
                self.incr += 1
                print self.incr
            elif lateral == 'right' and vertical == 'top':
                quadrant = 2
                print 'Q2'
            elif lateral == 'left' and vertical == 'bottom':
                quadrant = 3
                print 'Q3'
            elif lateral == 'right' and vertical == 'bottom':
                quadrant = 4
                print 'Q4'

class PPVT(App):

    def build(self):
        t = TouchInput()
        print t.incr
        return t


if __name__ == "__main__":
    PPVT().run()
</code></pre>

<p>main.kv</p>

<pre><code>&lt;TouchInput&gt;:
    Image:
        source: 'img1.jpg'
        size: root.width, root.height
    Label:
        id: label1
        text: str(root.width)
        pos: root.width / 2, root.height / 2
    Label:
        id: label2
        text: str(root.incr)
</code></pre>

<p>Use a numeric property, so kivy can track its changes.</p>

<pre><code>from kivy.properties import NumericProperty
...
class TouchInput(Widget):

    incr = NumericProperty(5)
    ...
</code></pre>

python dynamic kivy