Skip to content

Commit

Permalink
Merge pull request #125 from rkern/fix/console-width-height
Browse files Browse the repository at this point in the history
BUG: Rename width/height traits to avoid QWidget override.
  • Loading branch information
rkern committed May 6, 2016
2 parents 12450f5 + f2bca64 commit f3e7f9a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 11 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
Changes in Jupyter Qt console
=============================

.. _4.3:

4.3
---

`4.3 on GitHub <https://github.com/jupyter/qtconsole/milestones/4.3>`__

- Rename `ConsoleWidget.width/height` traits to `console_width/console_height`
to avoid a name clash with the `QWidget` properties.
WARNING: possibly, but unlikely code-breaking.

.. _4.2:

4.2
Expand Down
8 changes: 4 additions & 4 deletions qtconsole/console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ def _font_family_default(self):
with the size of the font.
""")

width = Integer(81, config=True,
console_width = Integer(81, config=True,
help="""The width of the console at start time in number
of characters (will double with `hsplit` paging)
""")

height = Integer(25, config=True,
console_height = Integer(25, config=True,
help="""The height of the console at start time in number
of characters (will double with `vsplit` paging)
""")
Expand Down Expand Up @@ -472,12 +472,12 @@ def sizeHint(self):
# a fudge factor of one character here.
# Note 2: QFontMetrics.maxWidth is not used here or anywhere else due
# to a Qt bug on certain Mac OS systems where it returns 0.
width = font_metrics.width(' ') * self.width + margin
width = font_metrics.width(' ') * self.console_width + margin
width += style.pixelMetric(QtGui.QStyle.PM_ScrollBarExtent)
if self.paging == 'hsplit':
width = width * 2 + splitwidth

height = font_metrics.height() * self.height + margin
height = font_metrics.height() * self.console_height + margin
if self.paging == 'vsplit':
height = height * 2 + splitwidth

Expand Down
7 changes: 6 additions & 1 deletion qtconsole/tests/test_console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@ def test_link_handling(self):
w.eventFilter(obj, stillOverTextEvent)
self.assertEqual(tip.isVisible(), True)
self.assertEqual(tip.text(), "http://python.org")


def test_width_height(self):
# width()/height() QWidget properties should not be overridden.
w = ConsoleWidget()
self.assertEqual(w.width(), QtGui.QWidget.width(w))
self.assertEqual(w.height(), QtGui.QWidget.height(w))

0 comments on commit f3e7f9a

Please sign in to comment.