mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
improve PyQt5.Qt compatibility
- support 'from PyQt5 import Qt' case - alias it to aqt.qt modules instead of relying on getattr, so that 'from PyQt5.Qt import *' case works.
This commit is contained in:
parent
61aa8a5bc9
commit
3868e1e4a6
2 changed files with 3 additions and 19 deletions
|
@ -401,6 +401,6 @@ PyQt6.QtCore.QRegExp = PyQt6.QtCore.QRegularExpression
|
||||||
# Mock the removed PyQt5.Qt module
|
# Mock the removed PyQt5.Qt module
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
from . import qt5_qt_module
|
sys.modules["PyQt5.Qt"] = sys.modules["aqt.qt"]
|
||||||
|
# support 'from PyQt5 import Qt', as it's an alias to PyQt6
|
||||||
sys.modules["PyQt5.Qt"] = qt5_qt_module
|
PyQt6.Qt = sys.modules["aqt.qt"]
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
||||||
|
|
||||||
# pylint: skip-file
|
|
||||||
|
|
||||||
"""
|
|
||||||
Compatibility shim for PyQt5.Qt
|
|
||||||
"""
|
|
||||||
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
def __getattr__(name: str) -> Any:
|
|
||||||
import aqt.qt
|
|
||||||
|
|
||||||
return getattr(aqt.qt, name)
|
|
Loading…
Reference in a new issue