I'm playing with the Reddit API and I'd like to have a basic text box for the user to input a subreddit to search. I want this interactivity so that I can (hopefully) post my notebook on github or nbviewer and have someone else try it. When I try to run my code, several things happen:
- The notebook continues to execute code cells instead of waiting for user to input a subreddit
- If I execute the cells manually, I can get the text box to appear, but then nothing happens when I hit 'Enter'.
Below is my code:
def onchange(change):
with caption:
print(change.value)
sub = widgets.Text(placeholder='Enter subreddit', description='r/')
caption = widgets.Output()
display(sub)
sub.on_submit(onchange)
And here is what it looks like when I execute the cell manually:
