Skip to content

Easier method to programmatically change the current param value #183

Open
@ianhi

Description

@ianhi

Problem

If you want to directly modify the current value of a slider generated by this package it is very difficult. Currently it is undocumented, and confusingly/difficult would be a kind way of putting it. For example see the discussion in #181 about using controls.controls['tau'].children[0].

There needs to be an easier (and documented!!) way to change the attributes of the sliders.

Proposed Solutions

Create an abstract Slider class
Create a Slider like object that abstracts over matplotlib and ipywidgets sliders. It could have it's own set of documented methods or take on the important methods of both maptlotlib sliders and ipywidgets sliders

pros:

  1. Uniform user facing API for matplotlib and ipywidgets sliders
  2. Don't have to replicate every method, just the important ones
  3. Is perhaps a reasonable way to leave the door open to other slider libs in the future
  4. Less need to explain the nightmare of HBoxes for ipywidgets sliders

cons:

  1. Have to replicate two different APIs
  2. users will not get direct access to the slider
    • well they could with some explanation
  3. using type on this may be a confusing experience
    • relatedly, what if it gets passed back into a controls object

I think the last point really only matters if you pass in an explicitly created slider, and then expect to get it back. Though hopefully this isn't too common.

Methods for setting on the controls object
e.g. controls.set_param_value('tau', 5)

pros:

  1. Easiest to implement

cons:

  1. Doesn't really give full functionality (what about setting the slider label)
  2. What about non-slider widgets?

Easy access to the underlying sliders
pros:

  1. pretty easy to implement

cons:

  1. Do we give back the whole hbox for ipywidgets sliders?

Looking at this there might be argument for doing all three. Or perhaps just the first two.
If we don't go with the first option then there will need to be a docs page explaining the nonsense with HBoxs for ipywidgets sldiers.

Additional context

I have no idea how if theres any reasonable way to have a depcreation path here, I suppose it would require keeping the .controls attribute with a warning on access and moving to some

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions