From 9eb9c0f91b08ee954154e79876a5c2769bc767e0 Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Sun, 19 May 2013 18:21:14 +0200 Subject: [PATCH] fix magic menu in qtconsole with new user_exp user_exp is now a dict based on mimetype, update qtconsole in consequence --- IPython/frontend/qt/console/mainwindow.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/IPython/frontend/qt/console/mainwindow.py b/IPython/frontend/qt/console/mainwindow.py index 2d73355f67d..cfbe8bb4fd1 100644 --- a/IPython/frontend/qt/console/mainwindow.py +++ b/IPython/frontend/qt/console/mainwindow.py @@ -615,25 +615,29 @@ def inner_dynamic_magic(): inner_dynamic_magic.__name__ = "dynamics_magic_s" return inner_dynamic_magic - def populate_all_magic_menu(self, listofmagic=None): - """Clean "All Magics..." menu and repopulate it with `listofmagic` + def populate_all_magic_menu(self, user_exp_result=None): + """Clean "All Magics..." menu and repopulate it with `user_exp_result` Parameters ---------- - listofmagic : string, - repr() of a list of strings, send back by the kernel + user_exp_result : dict, + + user_Expression result that contain the + repr() of a list of strings, send back by the kernel under the data > plain/text + key. Cf IPython protocol for the structure of the dict. - Notes - ----- - `listofmagic`is a repr() of list because it is fed with the result of - a 'user_expression' """ for k,v in self._magic_menu_dict.items(): v.clear() self.all_magic_menu.clear() - mlist=ast.literal_eval(listofmagic) + if user_exp_result.get('status') != 'ok': + self.log.info("Something went wrong retriving the list of availlable magics") + return + + mlist=ast.literal_eval(user_exp_result['data']['text/plain']) + for magic in mlist: cell = (magic['type'] == 'cell') name = magic['name']