Search code examples
enthought

delay on_trait_change() when cycling through values - only execute when mouse is unclicked


If you have a Range trait setup how do you make it only carry out the change once the user has stopped moving through the range?

ie. some range is changed:

some_trait_changed(self):
    wait for user to finish selection
    complex calculation.

Every time the user drags the Range tool, it calculates a new value for every single value in the range. I only want it to run once they have settled on a value... i.e. once the mouse has 'unclicked'.


Solution

  • Use Range(..., auto_set=False). The auto_set keyword gets passed to the RangeEditor which will configure the slider appropriately.