[IPython-dev] How to have independent call backs for single widget

Jason Moore moorepants at gmail.com
Tue May 6 17:31:39 EDT 2014


If I have a function that makes a plot, for example:

def plot_something(parameter=1.0, view=1.0):
    axes = expensive_function(plt.gca(), parameter)
    less_expensive_function(axes, view)

And I make it interactive:

interactive(plot_something, parameter=(0.0, 1.0), view=(0.0, 1.0))

As it stands, both the expensive_function and the less_expensive_function
run whether I drag the slider for either parameter, even though if I only
drag the view parameter I could theoretically only call the
less_expensive_function, thus making the widget respond faster.

What is a good design to have a widget depend on two or more parameters and
be able to have internal knowledge in the callback function on what
parameter changed? So that you can avoid overhead in computation?

Jason
moorepants.info
+01 530-601-9791
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140506/78f56f16/attachment.html>


More information about the IPython-dev mailing list