I have a tkinter spinbox widget.
val = IntVar()
Spinbox(from_=1, to=10, textvariable=val, command=lambda:self.Fn(val.get()))
def Fn(self, v):
print v
When the spinbox is clicked, it prints value of new spin box value.
Instead I want the previous spinbox value - which could be one above or one below the current value.
Is there a way i can get the previous value ?
You just need to store the value, and print it the next time the function is called:
def Fn(self, v):
result = self._oldvalue
self._oldvalue = v
print(result)
Don't forget to initialize self._oldvalue with some default value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With