Skip to content

Instantly share code, notes, and snippets.

@robertlugg
Last active March 5, 2020 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertlugg/0add523f965a11aa051dd5dc296ed923 to your computer and use it in GitHub Desktop.
Save robertlugg/0add523f965a11aa051dd5dc296ed923 to your computer and use it in GitHub Desktop.
ipywidgets output
# Goal is to capture output from print() to a nice box with scrollbars
# These print statements are proxies for what really does the printing, so I can't change them.
import ipywidgets as widgets
from ipywidgets import HBox, IntSlider, Text, Label, Output
# Attempt #1
a = Output()
with a:
for i in range (50):
print(f"Hello {i}")
# Attempt #2
# This seems to work
a = Output(layout={'border': '1px solid black', 'height': '200px', 'overflow_y': 'auto'})
display(a)
with a:
for i in range (50):
print(f"Hello {i}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment