Created
October 22, 2020 11:35
-
-
Save basnijholt/3da8ea769f84aba198bbba34dab70dce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipywidgets as widgets | |
class SelectMultipleInteract(widgets.HBox): | |
def __init__(self, combos, **plot_kwargs): | |
self.W1 = widgets.SelectMultiple( | |
options={str(x): x for x in combos}, | |
description="Combinations", | |
disabled=False, | |
) | |
self.selectors = [self.W1] | |
self.plot_kwargs = plot_kwargs | |
super().__init__(children=self.selectors) | |
self._set_observes() | |
self._out = widgets.Output() | |
display(self._out) | |
def _set_observes(self): | |
for widg in self.selectors: | |
widg.observe(self._observed_function, names="value") | |
def _observed_function(self, widg): | |
with self._out: | |
self._out.clear_output() | |
for widg in self.selectors: | |
plot(combos=widg.get_interact_value(), **self.plot_kwargs) | |
SelectMultipleInteract( | |
combos, | |
xy=xy, | |
figsize=(9, 3), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment