Displaying to output widget from button click callback throws exception
See original GitHub issueHere’s a minimal example:
%matplotlib inline
from IPython.html import widgets
from IPython.display import display
def click(b):
with out:
print 'Hello world'
out=widgets.Output()
button=widgets.Button(description='Click Me')
button.on_click(click)
display(out)
display(button)
Executing a notebook cell with this code and clicking the button results in the following exception being thrown:
NameError: global name 'get_ipython' is not defined
This is with the Anaconda ipython / ipython-notebook version 3.2.1 packages on Windows.
This issue can be resolved by adding
from IPython import get_ipython
to IPython/html/widgets/widget_output.py
, but I’m not familiar enough with the code to be sure if this is the correct place to make that change, or if the fix should be further upstream.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Output widgets: leveraging Jupyter's display system
The Output widget can capture and display stdout, stderr and rich output ... Button( description='click me to raise an exception', layout={'width': '300px'} ) ......
Read more >Python Panel Button Callback Function - Stack Overflow
I have two functions which I want to be executed when a respective button is clicked. The first one is a function to...
Read more >Motif Programming Manual (Volume 6A): 27 - IST
The callback ** for this button displays a new dialog that gives help. ... If the user does not click on a valid...
Read more >Button | Android Developers
A user interface element the user can tap or click to perform an action. To display a button in an activity, add a...
Read more >Error Boundaries - React
Event handlers (learn more); Asynchronous code (e.g. setTimeout or requestAnimationFrame callbacks); Server side rendering; Errors thrown in the error boundary ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also, here’s a more functional example of updating an output widget from a button click callback, to show how this can be used to position output (e.g. a matplotlib plot) relative to other widgets:
Thanks for clarifying @minrk