def question_code(): try: result = proxy.question(code) except RemoteError: handle_remote_error(proxy) return window = view.window() panel = window.get_output_panel('ipython_object_info') window.run_command( "show_panel", {"panel": "output.ipython_object_info"} ) window.focus_view(panel) set_view_text(panel, result) panel.settings().set("syntax", "Packages/IPython/ipython_output.tmLanguage") panel.show(panel.size(), False) # scroll to bottom def foo(): view.show_at_center(view.sel()[0].begin()) sublime.set_timeout(foo, 10)
def handle_remote_error(proxy, view, row_offset=0): print proxy.error window = view.window() panel = window.get_output_panel('ipython_traceback') set_view_text(panel, proxy.error) window.run_command( 'show_panel', {'panel': 'output.ipython_traceback'}) window.focus_view(panel) tb = proxy.traceback if '<ipython-input' in tb[0][0]: line = tb[0][1] + row_offset select_line(view, line) redraw_view(view) if len(tb) > 1: detailed_tb = [] for filename, line, t in tb: if '<ipython-input' in filename: line += row_offset x = 'Line {0} of {1}'.format(line, filename) lines = t.splitlines() lines.insert(0, x) detailed_tb.append(lines) sublime.active_window().show_quick_panel(detailed_tb, sys)