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

Qtconsole quits when trying to drag in PyQt6 #583

Closed
dschueler-exos opened this issue Aug 8, 2023 · 12 comments · Fixed by #584
Closed

Qtconsole quits when trying to drag in PyQt6 #583

dschueler-exos opened this issue Aug 8, 2023 · 12 comments · Fixed by #584
Assignees
Milestone

Comments

@dschueler-exos
Copy link

I'm on an Apple Silicon Mac, running Ventura 13.5 (also confirmed on an Intel Mac running Big Sur 11.7.9), and in jupyter qtconsole, whenever I select a bit of text and then click and hold the mouse as if to drag that text somewhere, the console aborts.

@rayosborn
Copy link
Contributor

rayosborn commented Aug 8, 2023

I couldn't reproduce this in PyQt5, but it looks as if there may have been changes in PyQt6 that need addressing. If I try to drag a selection in qtconsole 5.4.3, I get the following:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File ~/opt/miniconda3/envs/pyqt6/lib/python3.9/site-packages/qtconsole/console_widget.py:400, in ConsoleWidget.dragMoveEvent(self, e)
    398     pass
    399 elif e.mimeData().hasText():
--> 400     cursor = self._control.cursorForPosition(e.pos())
    401     if self._in_buffer(cursor.position()):
    402         e.setDropAction(QtCore.Qt.CopyAction)

AttributeError: 'QDragMoveEvent' object has no attribute 'pos'

2023-08-08 13:51:08,444 - ERROR - Exception in GUI event loop
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File ~/opt/miniconda3/envs/pyqt6/lib/python3.9/site-packages/qtconsole/console_widget.py:400, in ConsoleWidget.dragMoveEvent(self, e)
    398     pass
    399 elif e.mimeData().hasText():
--> 400     cursor = self._control.cursorForPosition(e.pos())
    401     if self._in_buffer(cursor.position()):
    402         e.setDropAction(QtCore.Qt.CopyAction)

AttributeError: 'QDragMoveEvent' object has no attribute 'pos'

2023-08-08 13:51:16,031 - ERROR - Exception in GUI event loop
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File ~/opt/miniconda3/envs/pyqt6/lib/python3.9/site-packages/qtconsole/console_widget.py:400, in ConsoleWidget.dragMoveEvent(self, e)
    398     pass
    399 elif e.mimeData().hasText():
--> 400     cursor = self._control.cursorForPosition(e.pos())
    401     if self._in_buffer(cursor.position()):
    402         e.setDropAction(QtCore.Qt.CopyAction)

AttributeError: 'QDragMoveEvent' object has no attribute 'pos'

@rayosborn
Copy link
Contributor

According to https://stackoverflow.com/questions/67496362/qmouseevent-object-has-no-attribute-pos, the fix may be as simple as changing e.pos to e.position, or at least catching the AttributeError and switching to the correct attribute. This will need a little looking into.

@rayosborn
Copy link
Contributor

By the way, if your whole application aborts with this bug, then you might be experiencing the issue discussed here. Customizing sys.excepthook in qtconsole might be worth thinking about, although it might interfere with other applications using the library. Such errors should produce an exception, not a core dump.

@dschueler-exos
Copy link
Author

dschueler-exos commented Aug 8, 2023

I am indeed on PyQt6, on both machines. And thanks for taking a look!

@ccordoba12
Copy link
Collaborator

ccordoba12 commented Aug 9, 2023

the fix may be as simple as changing e.pos to e.position

I think this case is already covered in Qtpy so the code is compatible between Qt5 and 6, right @dalthviz?

@dalthviz
Copy link
Collaborator

dalthviz commented Aug 9, 2023

I think some handling was added but only for QMouseEvent at spyder-ide/qtpy#408 and in general all the child classes of QSinglePointEvent at spyder-ide/qtpy#417

@ccordoba12
Copy link
Collaborator

Thanks for checking @dalthviz.

@rayosborn, then a fix for this would require adding to Qtpy something similar to spyder-ide/qtpy#408 for QDragMoveEvent.

@dalthviz
Copy link
Collaborator

Hi, just in case, updating to QtPy 2.4.0 should fix this issue (at least the issues/traceback related with the drag and drop event)

@ccordoba12 ccordoba12 added this to the 5.4.4 milestone Aug 30, 2023
@ccordoba12 ccordoba12 changed the title jupyter qconsole quits when trying to drag Qtconsole quits when trying to drag in PyQt6 Aug 30, 2023
@ccordoba12
Copy link
Collaborator

Thanks @dalthviz! I'll bump our QtPy requirement and release a new Qtconsole version shortly so the fix can reach more users.

@dschueler-exos
Copy link
Author

Hi, just in case, updating to QtPy 2.4.0 should fix this issue (at least the issues/traceback related with the drag and drop event)

That worked. Thanks!

@ccordoba12 ccordoba12 self-assigned this Aug 30, 2023
@rayosborn
Copy link
Contributor

Just for the record, upgrading to QtPy v2.4.0 does indeed fix the issue in NeXpy when using PyQt6. @dalthviz, thanks for the fix! I'll update our dependencies.

@ccordoba12
Copy link
Collaborator

I released 5.4.4 with an increased requirement on QtPy.

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.

4 participants