Using IPython Widgets

Hi,

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"])

And got:

#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!

Bill

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Donna McGahan I'm assuming ipython widgets are not supported in Mode?

    Reply Like
  • Hi Vincent ,

    It seems we do have the library ipywidgets version 4.1.1 but I don't think Python Notebook is supporting it really.  Sorry about that!  I can make a request for this on your behalf so the product team will see it.  

    Reply Like
  • 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 Like 1
Like4 Follow
  • Status Answered
  • 4 Likes
  • 4 mths agoLast active
  • 3Replies
  • 1028Views
  • 6 Following