Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: Error with QFontMetrics on PySide6 in console widget #1146

Closed
corranwebster opened this issue Jul 8, 2022 · 0 comments · Fixed by #1148
Closed

Bug report: Error with QFontMetrics on PySide6 in console widget #1146

corranwebster opened this issue Jul 8, 2022 · 0 comments · Fixed by #1148

Comments

@corranwebster
Copy link
Contributor

Environment

OS: all
Python version: 3.8
Toolkit: Qt
Qt API: PyQt6/PySide6

Description

When pressing the tab key in the Mayavi Python console, we get the following exception:

Traceback (most recent call last):
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 243, in eventFilter
    return self._event_filter_console_keypress(event)
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/python_shell.py", line 366, in _event_filter_console_keypress
    return super()._event_filter_console_keypress(event)
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 1329, in _event_filter_console_keypress
    intercepted = not self._tab_pressed()
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/python_shell.py", line 338, in _tab_pressed
    self._complete()
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/python_shell.py", line 450, in _complete
    self._complete_with_items(cursor, completions)
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 1025, in _complete_with_items
    self._page(self._format_as_columns(items))
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 1514, in _format_as_columns
    char_width = QtGui.QFontMetrics(self.font).width(" ")
AttributeError: 'PySide6.QtGui.QFontMetrics' object has no attribute 'width'

See enthought/mayavi#1158

Steps to Reproduce

Start Mayavi, enter from mayavi import mlab, type mlab. and then tab.

Probably simpler reproduction is possible.

corranwebster added a commit that referenced this issue Jul 8, 2022
corranwebster added a commit that referenced this issue Jul 8, 2022
* Add regression test for #1146.

* Make tests fail for the right reasons.

* Add a regression test for #1147.

* Fix calls to font metrics width and cursor movePosition.

Fixes #1146 and #1147.

* Add a comment about #1147.
corranwebster added a commit that referenced this issue Jul 8, 2022
* Add regression test for #1146.

* Make tests fail for the right reasons.

* Add a regression test for #1147.

* Fix calls to font metrics width and cursor movePosition.

Fixes #1146 and #1147.

* Add a comment about #1147.
corranwebster added a commit that referenced this issue Jul 11, 2022
* Add regression test for #1146.

* Make tests fail for the right reasons.

* Add a regression test for #1147.

* Fix calls to font metrics width and cursor movePosition.

Fixes #1146 and #1147.

* Add a comment about #1147.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant