Beispiel #1
0
class __getattr__:
    ETS = _api.deprecated("3.5")(property(lambda self: dict(
        pyqt5=(QT_API_PYQT5, 5), pyside2=(QT_API_PYSIDE2, 5))))
    QT_RC_MAJOR_VERSION = _api.deprecated("3.5")(
        property(lambda self: int(QtCore.qVersion().split(".")[0])))
Beispiel #2
0
    for _setup, QT_API in _candidates:
        try:
            _setup()
        except ImportError:
            continue
        break
    else:
        raise ImportError("Failed to import any qt binding")
else:  # We should not get there.
    raise AssertionError(f"Unexpected QT_API: {QT_API}")

# Fixes issues with Big Sur
# https://bugreports.qt.io/browse/QTBUG-87014, fixed in qt 5.15.2
if (sys.platform == 'darwin'
        and parse_version(platform.mac_ver()[0]) >= parse_version("10.16")
        and parse_version(QtCore.qVersion()) < parse_version("5.15.2")
        and "QT_MAC_WANTS_LAYER" not in os.environ):
    os.environ["QT_MAC_WANTS_LAYER"] = "1"

# PyQt6 enum compat helpers.

_to_int = operator.attrgetter("value") if QT_API == "PyQt6" else int


@functools.lru_cache(None)
def _enum(name):
    # foo.bar.Enum.Entry (PyQt6) <=> foo.bar.Entry (non-PyQt6).
    return operator.attrgetter(name if QT_API ==
                               'PyQt6' else name.rpartition(".")[0])(
                                   sys.modules[QtCore.__package__])