Created
July 17, 2014 16:50
-
-
Save gparuthi/6053228000755897fdc2 to your computer and use it in GitHub Desktop.
Variable inspector for ipython notebook
This file contains hidden or 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.html import widgets # Loads the Widget framework. | |
from IPython.core.magics.namespace import NamespaceMagics | |
def _fill(): | |
v = _var_name.value | |
try: | |
ve = eval(v) | |
vtype = type(ve).__name__ | |
_modal_body_label.value = str(ve)[:20] | |
if vtype == 'DataFrame': | |
_modal_body_label.value += ve[:10].to_html() | |
except: | |
_modal_body_label.value = '{0} {1}'.format(v, 'try') | |
def go(clicked): | |
_fill() | |
_popout = widgets.PopupWidget() | |
_popout.description = "Variable Inspector" | |
_popout.button_text = _popout.description | |
# _popout.set_css({'position':'absolute', 'top': 0, 'right': 0, 'width': '300px', 'height': 400}) | |
_modal_body = widgets.ContainerWidget() | |
_modal_body.set_css({'overflow-y':'scroll'}) | |
_modal_body_label = widgets.HTMLWidget(value = 'Not hooked') | |
_modal_body.children = [_modal_body_label] | |
_vars = widgets.ContainerWidget() | |
_var_name = widgets.TextWidget() | |
_gob = widgets.ButtonWidget(description='go') | |
_vars.set_css({'overflow-y':'scroll'}) | |
_vars.children=[_var_name, _gob] | |
_gob.on_click(go) | |
_var_output = widgets.HTMLWidget(value= '') | |
_popout.children = [ | |
_vars, | |
_modal_body, | |
_var_output | |
] | |
_ipython= get_ipython() | |
_ipython.events.register('post_execute', _fill) | |
_popout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment