what I am trying to achieve is a boolean that switches every time a value is increased by 1. Example: I have a button. The number the button is pressed is stored in a list and every time it is pressed increased by one. How can a boolean state be switched every time the button is pressed and thus the number increased by.
Thanks for your solutions, however I think I explained it wrong. The button an counter stuff I got already. Now I want to have a boolean switching every time the number is increased.
One thing to bear in mind is that sticky is a global dictionary, so if you have two components both using ‘a’ as the key they will share the value and interact - which may or may not be what you want.
If you don’t want it, an easy way to avoid it is to use the component guid as the key, like so:
g = ghenv.Component.InstanceGuid
if g in sc.sticky.keys():
a = sc.sticky[g]
else:
…