Last active
May 20, 2019 23:21
-
-
Save alexhrescale/82cf4f0ace20bc7fd62b88e0f10f3cde to your computer and use it in GitHub Desktop.
Jupyter tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.core.display import display, HTML | |
from lib.renderer import browser as brend | |
import ipywidgets as widgets | |
from IPython.display import display | |
def jupyter_display_table(entries, exclude_headers=None): | |
headers = list(set([k for entry in entries for k in entry.keys()])) | |
for hdr in (exclude_headers or []): | |
headers.remove(hdr) | |
trs = [] | |
for entry in entries: | |
trs.append('''<tr>{}</tr>'''.format('\n'.join( | |
'<td>{}</td>'.format(entry.get(k, '')) | |
for k in headers | |
))) | |
display(HTML('''\ | |
<table> | |
<tbody> | |
<tr> | |
{} | |
</tr> | |
{} | |
</tbody> | |
</table> | |
'''.format( | |
'\n'.join(['<th>{}</th>'.format(h) for h in headers]), | |
'\n'.join(sorted(trs)), | |
))) | |
def ta_widget_demo(): | |
# https://ipywidgets.readthedocs.io/en/stable/user_install.html | |
ta = widgets.Textarea( | |
value='something goes here', | |
placeholder='Type something', | |
description='String:', | |
disabled=False) | |
return ta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment