I have three PyGTK SpinButtons that are mutually dependent on each other: call them A, B, and C. There is another button D that toggles between two reciprocal definitions of C, such that the value of C is defined as A/B unless D has been pressed an odd number of times.
I want to be able, for example, to change A and have B or C update immediately according to this relationship. I also want to be able to change B and have A or C update immediately. Same goes for C. I’ve decided that when one is changed, the SpinButton that was least recently changed should be updated, and that if no SpinButtons have been changed since the program began, it should be assumed that C was changed most recently.
Everything above has been implemented. My application listens for the value-changed signals for each of the SpinButtons, performs the calculations above, and then updates the value of the other two as described. However, the application picks up its own changes and responds to them. When I change A, my program changes B, which is handled by changing C, and so on. I have tried the change-value signal too but it does not respond to changes to the SpinButton.
How do I listen for a change in value of a SpinButton in a way that will not be triggered by the program itself?
You can disable the signal handler for a given spinner before calling
set_valueon it. This ensures that the signal is only fired in reaction to mouse and keyboard events, not programmatic changes. Here is a quick example: