controller¶
-
class
Controls
(slider_formats=None, play_buttons=False, play_button_pos='right', use_ipywidgets=None, use_cache=True, **kwargs)[source]¶ Bases:
object
-
add_kwargs
(kwargs, slider_formats=None, play_buttons=None, allow_duplicates=False)[source]¶ If you pass a redundant kwarg it will just be overwritten maybe should only raise a warning rather than an error?
need to implement matplotlib widgets also a big question is how to dynamically update the display of matplotlib widgets.
-
control_figures
¶ Storage for figures made of matplotlib sliders.
-
params
¶ Parameters in the controller, see Custom Callbacks and Accessing Parameter Values.
-
register_callback
(callback, params=None, eager=False)[source]¶ Register a callback to be called anytime one of the specified params changes.
- Parameters
- callbackcallable
A function called. Should accept all of the parameters specified by params as a kwargs.
- paramsstr, list of str, or None
The params to be passed to the callback. If None then all params currently registered with this controls object will be used.
- eagerbool, default: False
If True, call the callback immediately upon registration
-
save_animation
(filename, fig, param, interval=20, func_anim_kwargs={}, N_frames=None, **kwargs)[source]¶ Save an animation over one of the parameters controlled by this
Controls
object.- Parameters
- filenamestr
- figfigure
- paramstr
the name of the kwarg to use to animate
- intervalint, default: 2o
interval between frames in ms
- func_anim_kwargsdict
kwargs to pass the creation of the underlying FuncAnimation
- N_framesint
Only used if the param is a matplotlib slider that was created without a valstep argument. This will only be relevant if you passed your own matplotlib slider as a kwarg when plotting. If needed but not given it will default to a value of 200.
- **kwargs
Passed through to anim.save
- Returns
- animmatplotlib.animation.FuncAniation
-
-
gogogo_controls
(kwargs, controls, display_controls, slider_formats, play_buttons, extra_controls=None, allow_dupes=False)[source]¶
-
prep_scalars
(kwarg_dict, **kwargs)[source]¶ Process potentially scalar arguments. This allows for passing in slider shorthands for these arguments, and for passing indexed controls objects for them.
- Parameters
- kwarg_dictdict
The kwargs passed to the calling functions
- kwargs :
The arguments to process
- Returns
- funcsdict
The processed arguments. Re-assign the args as
s = funcs['s']
to make use of any autogenerated functions to connect callbacks to these scalar values.- extra_ctrlslist of Controls
Any extra controls objects that need to be used. Useful for
gogogo_controls
- param_excluderfunction
A function to exclude any scalar kwargs we added from params. Use this in the update functions to avoid calling user provided functions with the kwargs that we added here.