Is there a way to suppress output of ipywidgets.interact() function?

889 views
Skip to first unread message

David Powell

unread,
Aug 16, 2015, 9:55:55 PM8/16/15
to Project Jupyter
Hello all,

I have just upgraded my conda installation to the latest version of jupyter. I am now having a problem with ipywidgets.interact, in that it is impossible to hide the output value (which is often None), even when terminating the line with a semi-colon ';'

This is particularly problematic for widgets which generate matplotlib figures, because the combination of both text and graphic outputs causes heavy flickering. Previously I was able to resolve this by ensuring that no text output appeared, and everything worked quite smoothly.

So I would welcome any method of suppressing this text.

regards
David

Message has been deleted

David Powell

unread,
Aug 17, 2015, 12:21:57 AM8/17/15
to Project Jupyter
I tried assigning the results of interact to a variable, but this doesn't help.

I also ran Jake Vanderplas's "Hipster Effect" https://jakevdp.github.io/blog/2014/11/11/the-hipster-effect-interactive/ example notebook, and I observed the same problem.

In both cases, I get much smoother results with the IPython Notebook v3.2.1.

Any suggestions as to how to workaround this problem would be appreciated.

Benjamin Bowen

unread,
Jun 30, 2016, 11:42:54 AM6/30/16
to Project Jupyter
Here is a potential workaround:

from ipywidgets import interact

def any_function_returning_value(word1,word2):
    new_word = 'Combining words is easy: %s %s'%(word1,word2)
    return new_word

class interact_workaround():
    def __init__(self, param1 = 'a word', param2 = 'another word'):
        self.p1 = param1
        self.p2 = param2
        self.w = interact(self.interact_bridge,word1=self.p1,word2=self.p2)
        
    def interact_bridge(self,word1,word2):
        self.new_word = any_function_returning_value(word1,word2)

f = interact_workaround(param1 = 'try this word')

printing f.new_word will show the return of the function outside the class.  Some creative messing around with kwargs and you could probably make something that implements as simply as interact.
Reply all
Reply to author
Forward
0 new messages