mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Port most remaining references to PyQt5
This commit is contained in:
parent
dae94f64ee
commit
3b79e215e8
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from PyQt5.Qt import QAction, QInputDialog
|
from qt.core import QAction, QInputDialog
|
||||||
from css_parser.css import CSSRule
|
from css_parser.css import CSSRule
|
||||||
|
|
||||||
# The base class that all tools must inherit from
|
# The base class that all tools must inherit from
|
||||||
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from PyQt5.Qt import QWidget, QHBoxLayout, QLabel, QLineEdit
|
from qt.core import QWidget, QHBoxLayout, QLabel, QLineEdit
|
||||||
|
|
||||||
from calibre.utils.config import JSONConfig
|
from calibre.utils.config import JSONConfig
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ if False:
|
|||||||
# You do not need this code in your plugins
|
# You do not need this code in your plugins
|
||||||
get_icons = get_resources = None
|
get_icons = get_resources = None
|
||||||
|
|
||||||
from PyQt5.Qt import QDialog, QVBoxLayout, QPushButton, QMessageBox, QLabel
|
from qt.core import QDialog, QVBoxLayout, QPushButton, QMessageBox, QLabel
|
||||||
|
|
||||||
from calibre_plugins.interface_demo.config import prefs
|
from calibre_plugins.interface_demo.config import prefs
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
from PyQt5.Qt import QUrl
|
from qt.core import QUrl
|
||||||
from PyQt5.QtWebEngineWidgets import QWebEngineView
|
from qt.webengine import QWebEngineView
|
||||||
|
|
||||||
from calibre.gui2 import Application
|
from calibre.gui2 import Application
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ if False:
|
|||||||
|
|
||||||
# The class that all interface action plugins must inherit from
|
# The class that all interface action plugins must inherit from
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from PyQt5.Qt import QInputDialog
|
from qt.core import QInputDialog
|
||||||
|
|
||||||
|
|
||||||
class InterfacePlugin(InterfaceAction):
|
class InterfacePlugin(InterfaceAction):
|
||||||
|
@ -16,5 +16,6 @@ combine_as_imports = True
|
|||||||
line_length = 85
|
line_length = 85
|
||||||
multi_line_output = 5
|
multi_line_output = 5
|
||||||
known_future_library = __python__
|
known_future_library = __python__
|
||||||
|
known_third_party = qt
|
||||||
known_standard_library = aes,elementmaker,encodings
|
known_standard_library = aes,elementmaker,encodings
|
||||||
known_first_party = calibre_extensions
|
known_first_party = calibre_extensions
|
||||||
|
@ -9,11 +9,7 @@ import sys
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
|
|
||||||
try:
|
from qt.core import QApplication, QEventLoop, pyqtSignal, sip
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
from qt.core import QApplication, QEventLoop, pyqtSignal
|
|
||||||
from qt.webengine import (
|
from qt.webengine import (
|
||||||
QWebEnginePage, QWebEngineProfile, QWebEngineScript
|
QWebEnginePage, QWebEngineProfile, QWebEngineScript
|
||||||
)
|
)
|
||||||
|
@ -10,11 +10,7 @@ import sys, copy
|
|||||||
from polyglot.builtins import map, range
|
from polyglot.builtins import map, range
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from qt.core import QLinearGradient, QPointF
|
from qt.core import QLinearGradient, QPointF, sip
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
from calibre.ebooks.pdf.render.common import Name, Array, Dictionary
|
from calibre.ebooks.pdf.render.common import Name, Array, Dictionary
|
||||||
|
|
||||||
|
@ -1468,7 +1468,6 @@ if is_running_from_develop:
|
|||||||
|
|
||||||
|
|
||||||
def event_type_name(ev_or_etype):
|
def event_type_name(ev_or_etype):
|
||||||
from PyQt5.QtCore import QEvent
|
|
||||||
etype = ev_or_etype.type() if isinstance(ev_or_etype, QEvent) else ev_or_etype
|
etype = ev_or_etype.type() if isinstance(ev_or_etype, QEvent) else ev_or_etype
|
||||||
for name, num in iteritems(vars(QEvent)):
|
for name, num in iteritems(vars(QEvent)):
|
||||||
if num == etype:
|
if num == etype:
|
||||||
|
@ -601,7 +601,7 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
|
|
||||||
# from calibre.utils.mem import memory
|
# from calibre.utils.mem import memory
|
||||||
# import weakref
|
# import weakref
|
||||||
# from PyQt5.Qt import QTimer
|
# from qt.core import QTimer
|
||||||
# self.dbref = weakref.ref(self.gui.library_view.model().db)
|
# self.dbref = weakref.ref(self.gui.library_view.model().db)
|
||||||
# self.before_mem = memory()
|
# self.before_mem = memory()
|
||||||
self.gui.library_moved(loc, allow_rebuild=True)
|
self.gui.library_moved(loc, allow_rebuild=True)
|
||||||
|
@ -6,11 +6,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from qt.core import Qt
|
from qt.core import Qt, sip
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2.dialogs.book_info import BookInfo
|
from calibre.gui2.dialogs.book_info import BookInfo
|
||||||
|
@ -9,11 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
Qt, QAction, QMenu, QObject, QToolBar, QToolButton, QSize, pyqtSignal, QKeySequence,
|
Qt, QAction, QMenu, QObject, QToolBar, QToolButton, QSize, pyqtSignal, QKeySequence,
|
||||||
QTimer, QPropertyAnimation, QEasingCurve, pyqtProperty, QPainter, QWidget, QPalette)
|
QTimer, QPropertyAnimation, QEasingCurve, pyqtProperty, QPainter, QWidget, QPalette, sip)
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
from calibre.constants import ismacos
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2 import gprefs, native_menubar_defaults, config
|
from calibre.gui2 import gprefs, native_menubar_defaults, config
|
||||||
|
@ -21,11 +21,7 @@ from .catalog_epub_mobi_ui import Ui_Form
|
|||||||
from qt.core import (Qt, QAbstractItemView, QCheckBox, QComboBox,
|
from qt.core import (Qt, QAbstractItemView, QCheckBox, QComboBox,
|
||||||
QDoubleSpinBox, QIcon, QInputDialog, QLineEdit, QRadioButton,
|
QDoubleSpinBox, QIcon, QInputDialog, QLineEdit, QRadioButton,
|
||||||
QSize, QSizePolicy, QTableWidget, QTableWidgetItem, QTextEdit, QToolButton,
|
QSize, QSizePolicy, QTableWidget, QTableWidgetItem, QTextEdit, QToolButton,
|
||||||
QUrl, QVBoxLayout, QWidget)
|
QUrl, QVBoxLayout, QWidget, sip)
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
|
|
||||||
class PluginWidget(QWidget,Ui_Form):
|
class PluginWidget(QWidget,Ui_Form):
|
||||||
|
@ -9,11 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
from qt.core import (
|
from qt.core import (
|
||||||
QLineEdit, QAbstractListModel, Qt, pyqtSignal, QObject, QKeySequence, QAbstractItemView,
|
QLineEdit, QAbstractListModel, Qt, pyqtSignal, QObject, QKeySequence, QAbstractItemView,
|
||||||
QApplication, QListView, QPoint, QModelIndex, QEvent,
|
QApplication, QListView, QPoint, QModelIndex, QEvent,
|
||||||
QStyleOptionComboBox, QStyle, QComboBox, QTimer)
|
QStyleOptionComboBox, QStyle, QComboBox, QTimer, sip)
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
from calibre.constants import ismacos
|
from calibre.constants import ismacos
|
||||||
from calibre.utils.icu import sort_key, primary_startswith, primary_contains
|
from calibre.utils.icu import sort_key, primary_startswith, primary_contains
|
||||||
|
@ -15,13 +15,9 @@ from qt.core import (
|
|||||||
QImageReader, QFormLayout, QVBoxLayout, QSplitter, QGroupBox, QListWidget,
|
QImageReader, QFormLayout, QVBoxLayout, QSplitter, QGroupBox, QListWidget,
|
||||||
QLineEdit, QSpinBox, QTextEdit, QSize, QListWidgetItem, QIcon, QImage,
|
QLineEdit, QSpinBox, QTextEdit, QSize, QListWidgetItem, QIcon, QImage,
|
||||||
pyqtSignal, QStackedLayout, QWidget, QLabel, Qt, QComboBox, QPixmap, QDialog,
|
pyqtSignal, QStackedLayout, QWidget, QLabel, Qt, QComboBox, QPixmap, QDialog,
|
||||||
QGridLayout, QStyledItemDelegate, QApplication, QStaticText,
|
QGridLayout, QStyledItemDelegate, QApplication, QStaticText, sip,
|
||||||
QStyle, QPen, QProgressDialog, QAbstractItemView, QDialogButtonBox
|
QStyle, QPen, QProgressDialog, QAbstractItemView, QDialogButtonBox
|
||||||
)
|
)
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
from calibre import walk, fit_image, human_readable, detect_ncpus as cpu_count
|
from calibre import walk, fit_image, human_readable, detect_ncpus as cpu_count
|
||||||
from calibre.constants import cache_dir, config_dir
|
from calibre.constants import cache_dir, config_dir
|
||||||
|
@ -43,7 +43,7 @@ class Pointer(QWidget):
|
|||||||
self.color.setAlpha(100)
|
self.color.setAlpha(100)
|
||||||
self.brush = QBrush(self.color, Qt.BrushStyle.SolidPattern)
|
self.brush = QBrush(self.color, Qt.BrushStyle.SolidPattern)
|
||||||
|
|
||||||
# from PyQt5.Qt import QTimer
|
# from qt.core import QTimer
|
||||||
# QTimer.singleShot(1000, self.start)
|
# QTimer.singleShot(1000, self.start)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -12,11 +12,7 @@ from functools import partial
|
|||||||
from qt.core import (QObject, QKeySequence, QAbstractItemModel, QModelIndex, QItemSelectionModel,
|
from qt.core import (QObject, QKeySequence, QAbstractItemModel, QModelIndex, QItemSelectionModel,
|
||||||
Qt, QStyledItemDelegate, QTextDocument, QStyle, pyqtSignal, QFrame, QAbstractItemView,
|
Qt, QStyledItemDelegate, QTextDocument, QStyle, pyqtSignal, QFrame, QAbstractItemView,
|
||||||
QApplication, QSize, QRectF, QWidget, QTreeView, QHBoxLayout, QVBoxLayout, QAbstractItemDelegate,
|
QApplication, QSize, QRectF, QWidget, QTreeView, QHBoxLayout, QVBoxLayout, QAbstractItemDelegate,
|
||||||
QGridLayout, QLabel, QRadioButton, QPushButton, QToolButton, QIcon, QEvent)
|
QGridLayout, QLabel, QRadioButton, QPushButton, QToolButton, QIcon, QEvent, sip)
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
from calibre.utils.config import JSONConfig
|
from calibre.utils.config import JSONConfig
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
|
@ -361,7 +361,7 @@ class MainWindowMixin(object): # {{{
|
|||||||
try:
|
try:
|
||||||
self.setUnifiedTitleAndToolBarOnMac(True)
|
self.setUnifiedTitleAndToolBarOnMac(True)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass # PyQt5 seems to be missing this property
|
pass # PyQt seems to be missing this property
|
||||||
|
|
||||||
# And now, start adding the real widgets
|
# And now, start adding the real widgets
|
||||||
l.addWidget(self.search_bar)
|
l.addWidget(self.search_bar)
|
||||||
|
@ -12,12 +12,8 @@ from glob import glob
|
|||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QDialog, QApplication, QLabel, QVBoxLayout, QDialogButtonBox, Qt, QAbstractItemView, QListView,
|
QDialog, QApplication, QLabel, QVBoxLayout, QDialogButtonBox, Qt, QAbstractItemView, QListView,
|
||||||
pyqtSignal, QListWidget, QListWidgetItem, QSize, QPixmap, QStyledItemDelegate
|
pyqtSignal, QListWidget, QListWidgetItem, QSize, QPixmap, QStyledItemDelegate, sip
|
||||||
)
|
)
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
from calibre.ebooks.metadata.pdf import page_images
|
from calibre.ebooks.metadata.pdf import page_images
|
||||||
|
@ -14,7 +14,7 @@ from qt.core import (
|
|||||||
QCheckBox, QComboBox, QDialog, QDialogButtonBox, QDoubleSpinBox, QFormLayout,
|
QCheckBox, QComboBox, QDialog, QDialogButtonBox, QDoubleSpinBox, QFormLayout,
|
||||||
QFrame, QHBoxLayout, QIcon, QLabel, QLineEdit, QListWidget, QPlainTextEdit, QLayout,
|
QFrame, QHBoxLayout, QIcon, QLabel, QLineEdit, QListWidget, QPlainTextEdit, QLayout,
|
||||||
QPushButton, QScrollArea, QSize, QSizePolicy, QSpinBox, Qt, QTabWidget, QTimer,
|
QPushButton, QScrollArea, QSize, QSizePolicy, QSpinBox, Qt, QTabWidget, QTimer,
|
||||||
QToolButton, QUrl, QVBoxLayout, QWidget, pyqtSignal
|
QToolButton, QUrl, QVBoxLayout, QWidget, pyqtSignal, sip
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
@ -37,11 +37,6 @@ from calibre.utils.icu import primary_sort_key
|
|||||||
from calibre.utils.shared_file import share_open
|
from calibre.utils.shared_file import share_open
|
||||||
from polyglot.builtins import as_bytes, unicode_type
|
from polyglot.builtins import as_bytes, unicode_type
|
||||||
|
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
|
|
||||||
if iswindows and not isportable:
|
if iswindows and not isportable:
|
||||||
from calibre_extensions import winutil
|
from calibre_extensions import winutil
|
||||||
|
@ -14,7 +14,7 @@ from qt.core import (
|
|||||||
QGridLayout, QIcon, QInputDialog, QLabel, QLineEdit, QListWidget, QAbstractItemView,
|
QGridLayout, QIcon, QInputDialog, QLabel, QLineEdit, QListWidget, QAbstractItemView,
|
||||||
QListWidgetItem, QMenu, QPainter, QPixmap, QRadioButton, QScrollArea, QSize,
|
QListWidgetItem, QMenu, QPainter, QPixmap, QRadioButton, QScrollArea, QSize,
|
||||||
QSpinBox, QStyle, QStyledItemDelegate, Qt, QTimer, QTreeWidget, QTreeWidgetItem,
|
QSpinBox, QStyle, QStyledItemDelegate, Qt, QTimer, QTreeWidget, QTreeWidgetItem,
|
||||||
QVBoxLayout, QWidget, pyqtSignal
|
QVBoxLayout, QWidget, pyqtSignal, sip
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import human_readable, sanitize_file_name
|
from calibre import human_readable, sanitize_file_name
|
||||||
@ -42,11 +42,6 @@ from calibre_extensions.progress_indicator import set_no_activate_on_click
|
|||||||
from polyglot.binary import as_hex_unicode
|
from polyglot.binary import as_hex_unicode
|
||||||
from polyglot.builtins import filter, iteritems, map, range, unicode_type
|
from polyglot.builtins import filter, iteritems, map, range, unicode_type
|
||||||
|
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
|
|
||||||
FILE_COPY_MIME = 'application/calibre-edit-book-files'
|
FILE_COPY_MIME = 'application/calibre-edit-book-files'
|
||||||
TOP_ICON_SIZE = 24
|
TOP_ICON_SIZE = 24
|
||||||
|
@ -10,7 +10,7 @@ from itertools import count
|
|||||||
from qt.core import (
|
from qt.core import (
|
||||||
QT_VERSION, QApplication, QBuffer, QByteArray, QEvent, QFontDatabase, QFontInfo,
|
QT_VERSION, QApplication, QBuffer, QByteArray, QEvent, QFontDatabase, QFontInfo,
|
||||||
QHBoxLayout, QIODevice, QLocale, QMimeData, QPalette, QSize, Qt, QTimer, QUrl,
|
QHBoxLayout, QIODevice, QLocale, QMimeData, QPalette, QSize, Qt, QTimer, QUrl,
|
||||||
QWidget, pyqtSignal
|
QWidget, pyqtSignal, sip
|
||||||
)
|
)
|
||||||
from qt.webengine import (
|
from qt.webengine import (
|
||||||
QWebEngineUrlRequestInfo, QWebEngineUrlRequestJob, QWebEngineUrlSchemeHandler
|
QWebEngineUrlRequestInfo, QWebEngineUrlRequestJob, QWebEngineUrlSchemeHandler
|
||||||
@ -41,11 +41,6 @@ from calibre.utils.shared_file import share_open
|
|||||||
from polyglot.builtins import as_bytes, iteritems, unicode_type
|
from polyglot.builtins import as_bytes, iteritems, unicode_type
|
||||||
from polyglot.functools import lru_cache
|
from polyglot.functools import lru_cache
|
||||||
|
|
||||||
try:
|
|
||||||
from PyQt5 import sip
|
|
||||||
except ImportError:
|
|
||||||
import sip
|
|
||||||
|
|
||||||
SANDBOX_HOST = FAKE_HOST.rpartition('.')[0] + '.sandbox'
|
SANDBOX_HOST = FAKE_HOST.rpartition('.')[0] + '.sandbox'
|
||||||
|
|
||||||
# Override network access to load data from the book {{{
|
# Override network access to load data from the book {{{
|
||||||
|
@ -286,11 +286,11 @@ class BuildTest(unittest.TestCase):
|
|||||||
|
|
||||||
@unittest.skipIf('SKIP_QT_BUILD_TEST' in os.environ, 'Skipping Qt build test as it causes crashes in the macOS VM')
|
@unittest.skipIf('SKIP_QT_BUILD_TEST' in os.environ, 'Skipping Qt build test as it causes crashes in the macOS VM')
|
||||||
def test_qt(self):
|
def test_qt(self):
|
||||||
from PyQt5.QtCore import QTimer
|
from qt.core import QTimer
|
||||||
from PyQt5.QtWidgets import QApplication
|
from qt.core import QApplication
|
||||||
from qt.webengine import QWebEnginePage
|
from qt.webengine import QWebEnginePage
|
||||||
from PyQt5.QtGui import QImageReader, QFontDatabase
|
from qt.core import QImageReader, QFontDatabase
|
||||||
from PyQt5.QtNetwork import QNetworkAccessManager
|
from qt.core import QNetworkAccessManager
|
||||||
from calibre.utils.img import image_from_data, image_to_data, test
|
from calibre.utils.img import image_from_data, image_to_data, test
|
||||||
# Ensure that images can be read before QApplication is constructed.
|
# Ensure that images can be read before QApplication is constructed.
|
||||||
# Note that this requires QCoreApplication.libraryPaths() to return the
|
# Note that this requires QCoreApplication.libraryPaths() to return the
|
||||||
|
@ -10,10 +10,9 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
# We use explicit module imports so tracebacks when importing are more useful
|
from qt.core import (
|
||||||
from PyQt5.QtCore import QBuffer, QByteArray, Qt, QIODevice
|
QBuffer, QByteArray, QColor, QImage, QImageReader, QImageWriter, QIODevice,
|
||||||
from PyQt5.QtGui import (
|
QPixmap, Qt, QTransform
|
||||||
QColor, QImage, QImageReader, QImageWriter, QPixmap, QTransform
|
|
||||||
)
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import importlib
|
|||||||
import os
|
import os
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
QT_WRAPPER = 'PyQt5'
|
||||||
|
|
||||||
base = os.path.dirname(os.path.abspath(__file__))
|
base = os.path.dirname(os.path.abspath(__file__))
|
||||||
module_lists = {
|
module_lists = {
|
||||||
'core': (
|
'core': (
|
||||||
@ -29,8 +31,8 @@ def scan(name):
|
|||||||
name_map = {}
|
name_map = {}
|
||||||
types = []
|
types = []
|
||||||
for mod_name in module_names:
|
for mod_name in module_names:
|
||||||
mod = importlib.import_module(f'PyQt5.{mod_name}')
|
mod = importlib.import_module(f'{QT_WRAPPER}.{mod_name}')
|
||||||
full_name = mod.__name__
|
full_name = name_map[mod_name] = mod.__name__
|
||||||
types.append(f'import {full_name}')
|
types.append(f'import {full_name}')
|
||||||
for obj_name in sorted(dir(mod)):
|
for obj_name in sorted(dir(mod)):
|
||||||
if not obj_name.startswith('_') and obj_name not in name_map:
|
if not obj_name.startswith('_') and obj_name not in name_map:
|
||||||
@ -38,11 +40,19 @@ def scan(name):
|
|||||||
types.append(f'{obj_name} = {full_name}.{obj_name}')
|
types.append(f'{obj_name} = {full_name}.{obj_name}')
|
||||||
with open(f'{base}/{name}.pyi', 'w') as f:
|
with open(f'{base}/{name}.pyi', 'w') as f:
|
||||||
print('# autogenerated by __main__.py do not edit', file=f)
|
print('# autogenerated by __main__.py do not edit', file=f)
|
||||||
f.write('\n'.join(sorted(types)))
|
f.write('\n'.join(types))
|
||||||
|
if name == 'core':
|
||||||
|
module_names += ('sip',)
|
||||||
|
mod = importlib.import_module(f'{QT_WRAPPER}.sip')
|
||||||
|
name_map['sip'] = mod.__name__
|
||||||
|
name_map['QtWin'] = f'{QT_WRAPPER}.QtWinExtras'
|
||||||
with open(f'{base}/{name}_name_map.py', 'w') as f:
|
with open(f'{base}/{name}_name_map.py', 'w') as f:
|
||||||
print('# autogenerated by __main__.py do not edit', file=f)
|
print('# autogenerated by __main__.py do not edit', file=f)
|
||||||
print('name_map =', end=' ', file=f)
|
print('name_map =', end=' ', file=f)
|
||||||
pprint(name_map, stream=f)
|
pprint(name_map, stream=f)
|
||||||
|
print('module_names = frozenset(', end='', file=f)
|
||||||
|
pprint(module_names, stream=f)
|
||||||
|
print(')', file=f)
|
||||||
|
|
||||||
|
|
||||||
for name in ('core', 'webengine'):
|
for name in ('core', 'webengine'):
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
|
|
||||||
from .loader import dynamic_load
|
from .loader import dynamic_load
|
||||||
from .core_name_map import name_map
|
from .core_name_map import name_map, module_names
|
||||||
|
|
||||||
already_imported = {}
|
already_imported = {}
|
||||||
qt_modules = {}
|
qt_modules = {}
|
||||||
|
|
||||||
|
|
||||||
def __getattr__(name):
|
def __getattr__(name):
|
||||||
return dynamic_load(name, name_map, already_imported, qt_modules)
|
return dynamic_load(name, name_map, already_imported, qt_modules, module_names)
|
||||||
|
926
src/qt/core.pyi
926
src/qt/core.pyi
File diff suppressed because it is too large
Load Diff
@ -605,13 +605,20 @@ name_map = {'PYQT_CONFIGURATION': 'PyQt5.QtCore',
|
|||||||
'Q_FLAGS': 'PyQt5.QtCore',
|
'Q_FLAGS': 'PyQt5.QtCore',
|
||||||
'Q_RETURN_ARG': 'PyQt5.QtCore',
|
'Q_RETURN_ARG': 'PyQt5.QtCore',
|
||||||
'Qt': 'PyQt5.QtCore',
|
'Qt': 'PyQt5.QtCore',
|
||||||
|
'QtCore': 'PyQt5.QtCore',
|
||||||
'QtCriticalMsg': 'PyQt5.QtCore',
|
'QtCriticalMsg': 'PyQt5.QtCore',
|
||||||
'QtDebugMsg': 'PyQt5.QtCore',
|
'QtDebugMsg': 'PyQt5.QtCore',
|
||||||
'QtFatalMsg': 'PyQt5.QtCore',
|
'QtFatalMsg': 'PyQt5.QtCore',
|
||||||
|
'QtGui': 'PyQt5.QtGui',
|
||||||
'QtInfoMsg': 'PyQt5.QtCore',
|
'QtInfoMsg': 'PyQt5.QtCore',
|
||||||
'QtMsgType': 'PyQt5.QtCore',
|
'QtMsgType': 'PyQt5.QtCore',
|
||||||
|
'QtNetwork': 'PyQt5.QtNetwork',
|
||||||
|
'QtPrintSupport': 'PyQt5.QtPrintSupport',
|
||||||
|
'QtSvg': 'PyQt5.QtSvg',
|
||||||
'QtSystemMsg': 'PyQt5.QtCore',
|
'QtSystemMsg': 'PyQt5.QtCore',
|
||||||
'QtWarningMsg': 'PyQt5.QtCore',
|
'QtWarningMsg': 'PyQt5.QtCore',
|
||||||
|
'QtWidgets': 'PyQt5.QtWidgets',
|
||||||
|
'QtWin': 'PyQt5.QtWinExtras',
|
||||||
'bin_': 'PyQt5.QtCore',
|
'bin_': 'PyQt5.QtCore',
|
||||||
'bom': 'PyQt5.QtCore',
|
'bom': 'PyQt5.QtCore',
|
||||||
'center': 'PyQt5.QtCore',
|
'center': 'PyQt5.QtCore',
|
||||||
@ -705,6 +712,9 @@ name_map = {'PYQT_CONFIGURATION': 'PyQt5.QtCore',
|
|||||||
'right': 'PyQt5.QtCore',
|
'right': 'PyQt5.QtCore',
|
||||||
'scientific': 'PyQt5.QtCore',
|
'scientific': 'PyQt5.QtCore',
|
||||||
'showbase': 'PyQt5.QtCore',
|
'showbase': 'PyQt5.QtCore',
|
||||||
|
'sip': 'PyQt5.sip',
|
||||||
'uppercasebase': 'PyQt5.QtCore',
|
'uppercasebase': 'PyQt5.QtCore',
|
||||||
'uppercasedigits': 'PyQt5.QtCore',
|
'uppercasedigits': 'PyQt5.QtCore',
|
||||||
'ws': 'PyQt5.QtCore'}
|
'ws': 'PyQt5.QtCore'}
|
||||||
|
module_names = frozenset(('QtCore', 'QtGui', 'QtWidgets', 'QtNetwork', 'QtSvg', 'QtPrintSupport', 'sip')
|
||||||
|
)
|
||||||
|
@ -6,7 +6,7 @@ from importlib import import_module
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def dynamic_load(name, name_map, already_imported, qt_modules):
|
def dynamic_load(name, name_map, already_imported, qt_modules, module_names=()):
|
||||||
ans = already_imported.get(name, already_imported)
|
ans = already_imported.get(name, already_imported)
|
||||||
if ans is not already_imported:
|
if ans is not already_imported:
|
||||||
return ans
|
return ans
|
||||||
@ -26,7 +26,10 @@ def dynamic_load(name, name_map, already_imported, qt_modules):
|
|||||||
file=sys.stderr
|
file=sys.stderr
|
||||||
)
|
)
|
||||||
if mod is not False:
|
if mod is not False:
|
||||||
q = getattr(mod, name, qt_modules)
|
if name in module_names:
|
||||||
|
q = mod
|
||||||
|
else:
|
||||||
|
q = getattr(mod, name, qt_modules)
|
||||||
if q is not qt_modules:
|
if q is not qt_modules:
|
||||||
already_imported[name] = q
|
already_imported[name] = q
|
||||||
return q
|
return q
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
|
|
||||||
from .loader import dynamic_load
|
from .loader import dynamic_load
|
||||||
from .webengine_name_map import name_map
|
from .webengine_name_map import name_map, module_names
|
||||||
|
|
||||||
already_imported = {}
|
already_imported = {}
|
||||||
qt_modules = {}
|
qt_modules = {}
|
||||||
|
|
||||||
|
|
||||||
def __getattr__(name):
|
def __getattr__(name):
|
||||||
return dynamic_load(name, name_map, already_imported, qt_modules)
|
return dynamic_load(name, name_map, already_imported, qt_modules, module_names)
|
||||||
|
@ -1,35 +1,33 @@
|
|||||||
# autogenerated by __main__.py do not edit
|
# autogenerated by __main__.py do not edit
|
||||||
|
import PyQt5.QtWebEngine
|
||||||
PYQT_WEBENGINE_VERSION = PyQt5.QtWebEngine.PYQT_WEBENGINE_VERSION
|
PYQT_WEBENGINE_VERSION = PyQt5.QtWebEngine.PYQT_WEBENGINE_VERSION
|
||||||
PYQT_WEBENGINE_VERSION_STR = PyQt5.QtWebEngine.PYQT_WEBENGINE_VERSION_STR
|
PYQT_WEBENGINE_VERSION_STR = PyQt5.QtWebEngine.PYQT_WEBENGINE_VERSION_STR
|
||||||
QQuickWebEngineProfile = PyQt5.QtWebEngine.QQuickWebEngineProfile
|
QQuickWebEngineProfile = PyQt5.QtWebEngine.QQuickWebEngineProfile
|
||||||
QQuickWebEngineScript = PyQt5.QtWebEngine.QQuickWebEngineScript
|
QQuickWebEngineScript = PyQt5.QtWebEngine.QQuickWebEngineScript
|
||||||
QWebEngineCertificateError = PyQt5.QtWebEngineWidgets.QWebEngineCertificateError
|
import PyQt5.QtWebEngineCore
|
||||||
QWebEngineClientCertificateSelection = PyQt5.QtWebEngineWidgets.QWebEngineClientCertificateSelection
|
|
||||||
QWebEngineClientCertificateStore = PyQt5.QtWebEngineCore.QWebEngineClientCertificateStore
|
QWebEngineClientCertificateStore = PyQt5.QtWebEngineCore.QWebEngineClientCertificateStore
|
||||||
QWebEngineContextMenuData = PyQt5.QtWebEngineWidgets.QWebEngineContextMenuData
|
|
||||||
QWebEngineCookieStore = PyQt5.QtWebEngineCore.QWebEngineCookieStore
|
QWebEngineCookieStore = PyQt5.QtWebEngineCore.QWebEngineCookieStore
|
||||||
QWebEngineDownloadItem = PyQt5.QtWebEngineWidgets.QWebEngineDownloadItem
|
|
||||||
QWebEngineFindTextResult = PyQt5.QtWebEngineCore.QWebEngineFindTextResult
|
QWebEngineFindTextResult = PyQt5.QtWebEngineCore.QWebEngineFindTextResult
|
||||||
QWebEngineFullScreenRequest = PyQt5.QtWebEngineWidgets.QWebEngineFullScreenRequest
|
|
||||||
QWebEngineHistory = PyQt5.QtWebEngineWidgets.QWebEngineHistory
|
|
||||||
QWebEngineHistoryItem = PyQt5.QtWebEngineWidgets.QWebEngineHistoryItem
|
|
||||||
QWebEngineHttpRequest = PyQt5.QtWebEngineCore.QWebEngineHttpRequest
|
QWebEngineHttpRequest = PyQt5.QtWebEngineCore.QWebEngineHttpRequest
|
||||||
QWebEngineNotification = PyQt5.QtWebEngineCore.QWebEngineNotification
|
QWebEngineNotification = PyQt5.QtWebEngineCore.QWebEngineNotification
|
||||||
QWebEnginePage = PyQt5.QtWebEngineWidgets.QWebEnginePage
|
|
||||||
QWebEngineProfile = PyQt5.QtWebEngineWidgets.QWebEngineProfile
|
|
||||||
QWebEngineQuotaRequest = PyQt5.QtWebEngineCore.QWebEngineQuotaRequest
|
QWebEngineQuotaRequest = PyQt5.QtWebEngineCore.QWebEngineQuotaRequest
|
||||||
QWebEngineRegisterProtocolHandlerRequest = PyQt5.QtWebEngineCore.QWebEngineRegisterProtocolHandlerRequest
|
QWebEngineRegisterProtocolHandlerRequest = PyQt5.QtWebEngineCore.QWebEngineRegisterProtocolHandlerRequest
|
||||||
QWebEngineScript = PyQt5.QtWebEngineWidgets.QWebEngineScript
|
|
||||||
QWebEngineScriptCollection = PyQt5.QtWebEngineWidgets.QWebEngineScriptCollection
|
|
||||||
QWebEngineSettings = PyQt5.QtWebEngineWidgets.QWebEngineSettings
|
|
||||||
QWebEngineUrlRequestInfo = PyQt5.QtWebEngineCore.QWebEngineUrlRequestInfo
|
QWebEngineUrlRequestInfo = PyQt5.QtWebEngineCore.QWebEngineUrlRequestInfo
|
||||||
QWebEngineUrlRequestInterceptor = PyQt5.QtWebEngineCore.QWebEngineUrlRequestInterceptor
|
QWebEngineUrlRequestInterceptor = PyQt5.QtWebEngineCore.QWebEngineUrlRequestInterceptor
|
||||||
QWebEngineUrlRequestJob = PyQt5.QtWebEngineCore.QWebEngineUrlRequestJob
|
QWebEngineUrlRequestJob = PyQt5.QtWebEngineCore.QWebEngineUrlRequestJob
|
||||||
QWebEngineUrlScheme = PyQt5.QtWebEngineCore.QWebEngineUrlScheme
|
QWebEngineUrlScheme = PyQt5.QtWebEngineCore.QWebEngineUrlScheme
|
||||||
QWebEngineUrlSchemeHandler = PyQt5.QtWebEngineCore.QWebEngineUrlSchemeHandler
|
QWebEngineUrlSchemeHandler = PyQt5.QtWebEngineCore.QWebEngineUrlSchemeHandler
|
||||||
QWebEngineView = PyQt5.QtWebEngineWidgets.QWebEngineView
|
|
||||||
QtWebEngine = PyQt5.QtWebEngine.QtWebEngine
|
|
||||||
QtWebEngineCore = PyQt5.QtWebEngineCore.QtWebEngineCore
|
|
||||||
import PyQt5.QtWebEngine
|
|
||||||
import PyQt5.QtWebEngineCore
|
|
||||||
import PyQt5.QtWebEngineWidgets
|
import PyQt5.QtWebEngineWidgets
|
||||||
|
QWebEngineCertificateError = PyQt5.QtWebEngineWidgets.QWebEngineCertificateError
|
||||||
|
QWebEngineClientCertificateSelection = PyQt5.QtWebEngineWidgets.QWebEngineClientCertificateSelection
|
||||||
|
QWebEngineContextMenuData = PyQt5.QtWebEngineWidgets.QWebEngineContextMenuData
|
||||||
|
QWebEngineDownloadItem = PyQt5.QtWebEngineWidgets.QWebEngineDownloadItem
|
||||||
|
QWebEngineFullScreenRequest = PyQt5.QtWebEngineWidgets.QWebEngineFullScreenRequest
|
||||||
|
QWebEngineHistory = PyQt5.QtWebEngineWidgets.QWebEngineHistory
|
||||||
|
QWebEngineHistoryItem = PyQt5.QtWebEngineWidgets.QWebEngineHistoryItem
|
||||||
|
QWebEnginePage = PyQt5.QtWebEngineWidgets.QWebEnginePage
|
||||||
|
QWebEngineProfile = PyQt5.QtWebEngineWidgets.QWebEngineProfile
|
||||||
|
QWebEngineScript = PyQt5.QtWebEngineWidgets.QWebEngineScript
|
||||||
|
QWebEngineScriptCollection = PyQt5.QtWebEngineWidgets.QWebEngineScriptCollection
|
||||||
|
QWebEngineSettings = PyQt5.QtWebEngineWidgets.QWebEngineSettings
|
||||||
|
QWebEngineView = PyQt5.QtWebEngineWidgets.QWebEngineView
|
@ -29,4 +29,7 @@ name_map = {'PYQT_WEBENGINE_VERSION': 'PyQt5.QtWebEngine',
|
|||||||
'QWebEngineUrlSchemeHandler': 'PyQt5.QtWebEngineCore',
|
'QWebEngineUrlSchemeHandler': 'PyQt5.QtWebEngineCore',
|
||||||
'QWebEngineView': 'PyQt5.QtWebEngineWidgets',
|
'QWebEngineView': 'PyQt5.QtWebEngineWidgets',
|
||||||
'QtWebEngine': 'PyQt5.QtWebEngine',
|
'QtWebEngine': 'PyQt5.QtWebEngine',
|
||||||
'QtWebEngineCore': 'PyQt5.QtWebEngineCore'}
|
'QtWebEngineCore': 'PyQt5.QtWebEngineCore',
|
||||||
|
'QtWebEngineWidgets': 'PyQt5.QtWebEngineWidgets'}
|
||||||
|
module_names = frozenset(('QtWebEngine', 'QtWebEngineCore', 'QtWebEngineWidgets')
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user