diff --git a/IPython/qt/console/magic_helper.py b/IPython/qt/console/magic_helper.py index 95c310a..17c3e20 100644 --- a/IPython/qt/console/magic_helper.py +++ b/IPython/qt/console/magic_helper.py @@ -25,6 +25,7 @@ class MagicHelper(QtGui.QDockWidget): pasteRequested = QtCore.pyqtSignal(str, name = 'pasteRequested') runRequested = QtCore.pyqtSignal(str, name = 'runRequested') + readyForUpdate = QtCore.pyqtSignal(name = 'readyForUpdate') #--------------------------------------------------------------------------- # 'object' interface @@ -34,11 +35,6 @@ class MagicHelper(QtGui.QDockWidget): super(MagicHelper, self).__init__(name, parent) - # this is a hack. The main_window reference will be used for - # explicit interface to kernel that must be hidden by signal/slot - # mechanism in the future - self.main_window = parent - self.data = None class MinListWidget(QtGui.QListWidget): @@ -94,21 +90,9 @@ class MagicHelper(QtGui.QDockWidget): self.data = {} self.search_class.clear() self.search_class.addItem("Populating...") - self.main_window.active_frontend._silent_exec_callback( - 'get_ipython().magic("lsmagic")', - self.populate_magic_helper - ) + self.readyForUpdate.emit() def populate_magic_helper(self, data): - if not data: - return - - if data['status'] != 'ok': - self.main_window.log.warn( - "%%lsmagic user-expression failed: {}".format(data) - ) - return - self.search_class.clear() self.search_list.clear() diff --git a/IPython/qt/console/mainwindow.py b/IPython/qt/console/mainwindow.py index aac8a76..905421c 100644 --- a/IPython/qt/console/mainwindow.py +++ b/IPython/qt/console/mainwindow.py @@ -713,6 +713,9 @@ class MainWindow(QtGui.QMainWindow): self.magic_helper.runRequested[str].connect( self.magic_helper_run_requested ) + self.magic_helper.readyForUpdate.connect( + self.magic_helper_update_requested + ) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.magic_helper) @@ -732,8 +735,23 @@ class MainWindow(QtGui.QMainWindow): self.active_frontend.execute(text) self._set_active_frontend_focus() + def magic_helper_update_requested(self): + def _handle_data(data): + if not data: + return + + if data['status'] != 'ok': + self.log.warn( + "%%lsmagic user-expression failed: {}".format(data) + ) + return + self.magic_helper.populate_magic_helper(data) + + self.active_frontend._silent_exec_callback( + 'get_ipython().magic("lsmagic")', + _handle_data + ) - # minimize/maximize/fullscreen actions: def toggle_menu_bar(self):