diff --git a/IPython/frontend/qt/console/console_widget.py b/IPython/frontend/qt/console/console_widget.py index 1cfa695..235481d 100644 --- a/IPython/frontend/qt/console/console_widget.py +++ b/IPython/frontend/qt/console/console_widget.py @@ -1773,6 +1773,32 @@ class ConsoleWidget(LoggingConfigurable, QtGui.QWidget): else: self._append_plain_text(text) + def _set_paging(self, paging): + """ + Change the pager to `paging` style. + + XXX: currently, this is limited to switching between 'hsplit' and + 'vsplit'. + + Parameters: + ----------- + paging : string + Either "hsplit", "vsplit", or "inside" + """ + if self._splitter is None: + raise NotImplementedError("""can only switch if --paging=hsplit or + --paging=vsplit is used.""") + if paging == 'hsplit': + self._splitter.setOrientation(QtCore.Qt.Horizontal) + elif paging == 'vsplit': + self._splitter.setOrientation(QtCore.Qt.Vertical) + elif paging == 'inside': + raise NotImplementedError("""switching to 'inside' paging not + supported yet.""") + else: + raise ValueError("unknown paging method '%s'" % paging) + self.paging = paging + def _prompt_finished(self): """ Called immediately after a prompt is finished, i.e. when some input will be processed and a new prompt displayed. diff --git a/IPython/frontend/qt/console/mainwindow.py b/IPython/frontend/qt/console/mainwindow.py index c53446a..4778b1b 100644 --- a/IPython/frontend/qt/console/mainwindow.py +++ b/IPython/frontend/qt/console/mainwindow.py @@ -528,7 +528,25 @@ class MainWindow(QtGui.QMainWindow): statusTip="Clear the console", triggered=self.clear_magic_active_frontend) self.add_menu_action(self.view_menu, self.clear_action) - + + self.pager_menu = self.view_menu.addMenu("&Pager") + + hsplit_action = QtGui.QAction(".. &Horizontal Split", + self, + triggered=lambda: self.set_paging_active_frontend('hsplit')) + + vsplit_action = QtGui.QAction(" : &Vertical Split", + self, + triggered=lambda: self.set_paging_active_frontend('vsplit')) + + inside_action = QtGui.QAction(" &Inside Pager", + self, + triggered=lambda: self.set_paging_active_frontend('inside')) + + self.pager_menu.addAction(hsplit_action) + self.pager_menu.addAction(vsplit_action) + self.pager_menu.addAction(inside_action) + def init_kernel_menu(self): self.kernel_menu = self.menuBar().addMenu("&Kernel") # Qt on OSX maps Ctrl to Cmd, and Meta to Ctrl @@ -829,6 +847,9 @@ class MainWindow(QtGui.QMainWindow): self.maximizeAct.setEnabled(True) self.minimizeAct.setEnabled(True) + def set_paging_active_frontend(self, paging): + self.active_frontend._set_paging(paging) + def close_active_frontend(self): self.close_tab(self.active_frontend)