Address more PyQt6 enum type shenanigans

This commit is contained in:
Ogi Moore 2021-01-31 21:17:44 -08:00
parent 0495f1dcce
commit d70a009c29

View File

@ -395,7 +395,7 @@ if QT_LIB == PYSIDE6:
if QT_LIB == PYQT6:
# module.Class.EnumClass.Enum -> module.Class.Enum
def promote_enums(module):
class_names = [x for x in dir(module) if x[0] == 'Q']
class_names = [x for x in dir(module) if x.startswith('Q')]
for class_name in class_names:
klass = getattr(module, class_name)
if not isinstance(klass, sip.wrappertype):
@ -418,6 +418,18 @@ if QT_LIB == PYQT6:
for e in QtCore.Qt.Key:
setattr(QtCore.Qt, e.name, e.value)
# TextFlags are not accepted as appropriate types
# Example:
# TypeError: QFontMetric.size(
# self,
# int,
# str,
# tabStops: int = 0,
# tabArray: Optional[List[int]] = 0
# ): argument 1 has unexpected type 'TextFlag'
for e in QtCore.Qt.TextFlag:
setattr(QtCore.Qt, e.name, e.value)
# shim the old names for QPointF mouse coords
QtGui.QSinglePointEvent.localPos = lambda o : o.position()
QtGui.QSinglePointEvent.windowPos = lambda o : o.scenePosition()