From d90eee994369ce703e3b7a3c1fce440341e637b1 2014-10-18 12:43:08 From: Kalibri Date: 2014-10-18 12:43:08 Subject: [PATCH] Fix QtConsole tooltip formatting remove string mangling, and turn on QT wordWrap --- diff --git a/IPython/qt/console/call_tip_widget.py b/IPython/qt/console/call_tip_widget.py index 378a138..bfb364d 100644 --- a/IPython/qt/console/call_tip_widget.py +++ b/IPython/qt/console/call_tip_widget.py @@ -1,6 +1,5 @@ # Standard library imports import re -import textwrap from unicodedata import category # System library imports @@ -37,6 +36,7 @@ class CallTipWidget(QtGui.QLabel): QtGui.QStyle.PM_ToolTipLabelFrameWidth, None, self)) self.setWindowOpacity(self.style().styleHint( QtGui.QStyle.SH_ToolTipLabel_Opacity, None, self, None) / 255.0) + self.setWordWrap(True) def eventFilter(self, obj, event): """ Reimplemented to hide on certain key presses and on text edit focus @@ -244,16 +244,6 @@ class CallTipWidget(QtGui.QLabel): def _format_tooltip(self, doc): doc = re.sub(r'\033\[(\d|;)+?m', '', doc) - - # make sure a long argument list does not make - # the first row overflow the width of the actual tip body - rows = doc.split("\n") - # An object which is not a callable has '' as doc - if len(rows) == 1: - return doc - max_text_width = max(80, max([len(x) for x in rows[1:]])) - rows= textwrap.wrap(rows[0],max_text_width) + rows[1:] - doc = "\n".join(rows) return doc #------ Signal handlers ----------------------------------------------------