If I have a kivy-widget with an observed property like this:
class SampleClass(BoxLayout):
state = StringProperty("idle")
(...)
def on_state(self, instance, value):
print("State changed to " + value)
The on_state method will be called, every time the state-property changes. The value argument will contain the new string or the value, the state-property is changed to.
But now I want to execute a function only, if the value of the state-property changes from one value to another. E.g. I want to execute a function, when the state-property changes from "idle" to "running" but not when it changes from "stopped" to "running".
The problem is that I can't find any way, to access the old or the previous value. I could write my own setter function and track the old values myself, but maybe there is another, more elegant way of doing this.
enter code here