Using IPython Widgets
I was hoping to replicate some sort of filters/dropdown menu so that charts generated in the Python notebook can change according to the user's selection. This feature would be very helpful - collapses many plots into one area, and instead of scrolling endlessly the user can simply point and click to change the plot to the plot of interest.
But I wasn't successful, here are my steps:
I imported the following packages:
from ipywidgets import interact, interactive, fixed, interact_manual import ipywidgets as widgets from IPython.display import display as display_widget
Wrote a simple function that generates plots based on some user input:
def fake_function(user_input): ... plot something
And tried interact:
interact(fake_function,user_input=["Option 1","Option 2"])
#missing button for user input #default plot here <function __main__.fake_function>
Using the function interactive and display seems to only result in the same error without the <function__main__.fake_function> line in the output.
The plotting function (fake_function) is fine - I've tested it separately.
I'm unsure if this is a problem with the way that I'm using the widgets, possibly because the version in Mode is outdated and I'm following the instructions from a tutorial using the updated version of ipywidgets, or is it something intrinsic to the Mode python notebooks.
I'm aware of dynamic parameters, but I'm hoping for post-querying filtering capabilities, such that the report does not need to run again depending on the user's input.
Would appreciate any help or comments!
As far as I can tell, the ipywidgets need to be enabled for this to work:
jupyter nbextension enable --py --sys-prefix widgetsnbextension
See this URL for more info.
I'd love to see this in Mode, is it possible to add this to environment building?Reply