You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently ported pycode to support PySide6, including removing the pyqode.qt compatibility module and using qtpy instead. To complete that, I needed to add some additional support:
import os
from qtpy import PYSIDE6_API
qt_api = os.environ['QT_API'].lower()
if qt_api in PYSIDE6_API:
from PySide6.QtGui import *
from PySide6.QtWidgets import *
QFontMetrics.width = lambda self, *args, **kwargs: self.horizontalAdvance(*args, **kwargs)
QFontMetricsF.width = lambda self, *args, **kwargs: self.horizontalAdvance(*args, **kwargs)
QLineEdit.getTextMargins = lambda self: (self.textMargins().left(), self.textMargins().top(), self.textMargins().right(), self.textMargins().bottom())
Additionally I needed to add in a single source file (I didn't modify my qtpy files at all):
try:
from qtpy import QtGui
QtWidgets.QUndoCommand = QtGui.QUndoCommand
except:
pass
The text was updated successfully, but these errors were encountered:
Checking the linked files you can see that there are alredy some of the changes you need implemented (like for the QFontMetricsF.width method aliasing). Most probably these changes should also be added to the logic to handle PyQt6.
Also, do you know if this alising is needed starting from and specific version of PySide6?
If you want to helps us with these additions let us know!
dalthviz
changed the title
Additions needed for PySide6 support
Additions needed for PySide6 support (QFontMetricsF.width, QLineEdit.getTextMargins and QtWidgets.QUndoCommand)
Sep 1, 2022
Hi @dalthviz, I don't know if there's a specific version of PySide6 where this becomes necessary. (I happen to be using 6.3.1 and have only previously used PyQt5.)
I've never created a GitHub PR before but I'll give it a shot with these changes! To do that, do I need to clone the repo to my own account first, submit there, then request a merge? (Something else I've never done on GitHub), or do I just clone the repo here locally, commit my changes locally (in a new branch?) and then push them?
dalthviz
changed the title
Additions needed for PySide6 support (QFontMetricsF.width, QLineEdit.getTextMargins and QtWidgets.QUndoCommand)
Additions needed for PySide6/PyQt6 support (QFontMetricsF.width, QLineEdit.getTextMargins and QtWidgets.QUndoCommand)
Sep 6, 2022
I recently ported pycode to support PySide6, including removing the pyqode.qt compatibility module and using qtpy instead. To complete that, I needed to add some additional support:
Additionally I needed to add in a single source file (I didn't modify my qtpy files at all):
The text was updated successfully, but these errors were encountered: