From d70a009c298d7c9a8b6acbab1d0b6f06f89bb1d0 Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Sun, 31 Jan 2021 21:17:44 -0800 Subject: [PATCH] Address more PyQt6 enum type shenanigans --- pyqtgraph/Qt.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 83654c93..52883262 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -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()