diff --git a/pyslvs_ui/__main__.py b/pyslvs_ui/__main__.py index d73db7895..55bd161eb 100644 --- a/pyslvs_ui/__main__.py +++ b/pyslvs_ui/__main__.py @@ -22,9 +22,9 @@ def main() -> None: from platform import system from pyslvs_ui.info import ARGUMENTS, logger if ARGUMENTS.cmd in {'gui', None}: - from qtpy.QtCore import Qt, qInstallMessageHandler - from qtpy.QtWidgets import QApplication, QSplashScreen - from qtpy.QtGui import QPixmap + from pyslvs_ui.qt.QtCore import Qt, qInstallMessageHandler + from pyslvs_ui.qt.QtWidgets import QApplication, QSplashScreen + from pyslvs_ui.qt.QtGui import QPixmap _app = QApplication(argv) # Depress Qt warning qInstallMessageHandler(lambda _0, _1, _2: None) diff --git a/pyslvs_ui/entities/edit_link.py b/pyslvs_ui/entities/edit_link.py index 908bda615..270b787e4 100644 --- a/pyslvs_ui/entities/edit_link.py +++ b/pyslvs_ui/entities/edit_link.py @@ -9,11 +9,11 @@ from re import match from typing import List, Union -from qtpy.QtCore import Slot, Qt -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot, Qt +from pyslvs_ui.qt.QtWidgets import ( QDialog, QListWidgetItem, QDialogButtonBox, QColorDialog, QWidget, ) -from qtpy.QtGui import QIcon, QPixmap +from pyslvs_ui.qt.QtGui import QIcon, QPixmap from pyslvs import VPoint, VLink, color_names from pyslvs_ui.graphics import color_qt, color_icon from .utility import set_custom_color, add_custom_color diff --git a/pyslvs_ui/entities/edit_link_ui.py b/pyslvs_ui/entities/edit_link_ui.py index eacc610b9..62d289cdd 100644 --- a/pyslvs_ui/entities/edit_link_ui.py +++ b/pyslvs_ui/entities/edit_link_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/entities/edit_point.py b/pyslvs_ui/entities/edit_point.py index c78790bd8..87c387448 100644 --- a/pyslvs_ui/entities/edit_point.py +++ b/pyslvs_ui/entities/edit_point.py @@ -8,9 +8,9 @@ __email__ = "pyslvs@gmail.com" from typing import List, Union -from qtpy.QtCore import Slot, Qt -from qtpy.QtWidgets import QDialog, QListWidgetItem, QColorDialog, QWidget -from qtpy.QtGui import QIcon, QPixmap +from pyslvs_ui.qt.QtCore import Slot, Qt +from pyslvs_ui.qt.QtWidgets import QDialog, QListWidgetItem, QColorDialog, QWidget +from pyslvs_ui.qt.QtGui import QIcon, QPixmap from pyslvs import VPoint, VLink, color_names from pyslvs_ui.graphics import color_qt, color_icon from .utility import set_custom_color, add_custom_color diff --git a/pyslvs_ui/entities/edit_point_ui.py b/pyslvs_ui/entities/edit_point_ui.py index 146ef65c6..313185776 100644 --- a/pyslvs_ui/entities/edit_point_ui.py +++ b/pyslvs_ui/entities/edit_point_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/entities/relocate_point.py b/pyslvs_ui/entities/relocate_point.py index b9d1712b2..86e5dfe4b 100644 --- a/pyslvs_ui/entities/relocate_point.py +++ b/pyslvs_ui/entities/relocate_point.py @@ -11,8 +11,8 @@ from typing import TYPE_CHECKING from math import isnan, radians -from qtpy.QtCore import Slot -from qtpy.QtWidgets import QDialog, QDialogButtonBox +from pyslvs_ui.qt.QtCore import Slot +from pyslvs_ui.qt.QtWidgets import QDialog, QDialogButtonBox from pyslvs import plap, pllp, Coord from pyslvs_ui.widgets import QRotatableView from .relocate_point_ui import Ui_Dialog as SubUiDialog diff --git a/pyslvs_ui/entities/relocate_point_ui.py b/pyslvs_ui/entities/relocate_point_ui.py index 88d754276..82b79232a 100644 --- a/pyslvs_ui/entities/relocate_point_ui.py +++ b/pyslvs_ui/entities/relocate_point_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/entities/utility.py b/pyslvs_ui/entities/utility.py index 732fcd5b8..70233f723 100644 --- a/pyslvs_ui/entities/utility.py +++ b/pyslvs_ui/entities/utility.py @@ -7,8 +7,8 @@ __license__ = "AGPL" __email__ = "pyslvs@gmail.com" -from qtpy.QtWidgets import QComboBox -from qtpy.QtGui import QColor +from pyslvs_ui.qt.QtWidgets import QComboBox +from pyslvs_ui.qt.QtGui import QColor from pyslvs_ui.graphics import color_icon diff --git a/pyslvs_ui/graphics/canvas.py b/pyslvs_ui/graphics/canvas.py index 2da91f709..372203e49 100644 --- a/pyslvs_ui/graphics/canvas.py +++ b/pyslvs_ui/graphics/canvas.py @@ -16,15 +16,15 @@ from enum import auto, unique, IntEnum from math import radians, sin, cos, atan2, hypot, isnan from functools import reduce -from qtpy.QtCore import Slot, Qt, QPointF, QRectF, QSizeF, Signal -from qtpy.QtWidgets import QWidget, QSizePolicy -from qtpy.QtGui import ( +from pyslvs_ui.qt.QtCore import Slot, Qt, QPointF, QRectF, QSizeF, Signal +from pyslvs_ui.qt.QtWidgets import QWidget, QSizePolicy +from pyslvs_ui.qt.QtGui import ( QPolygonF, QPainter, QBrush, QPen, QColor, QFont, QPainterPath, QImage, QPaintEvent, QMouseEvent, ) from pyslvs import VPoint, edges_view, parse_pos from pyslvs.graph import Graph -from pyslvs_ui.qt_patch import QABCMeta +from pyslvs_ui.qt import QABCMeta from .color import color_num, color_qt, target_path_style _T = TypeVar('_T') diff --git a/pyslvs_ui/graphics/chart.py b/pyslvs_ui/graphics/chart.py index 20f6c06ef..a39bf8db2 100644 --- a/pyslvs_ui/graphics/chart.py +++ b/pyslvs_ui/graphics/chart.py @@ -11,8 +11,8 @@ __email__ = "pyslvs@gmail.com" from typing import Sequence, List -from qtpy.QtCore import Qt -from qtpy.QtWidgets import QWidget, QVBoxLayout, QDialog +from pyslvs_ui.qt.QtCore import Qt +from pyslvs_ui.qt.QtWidgets import QWidget, QVBoxLayout, QDialog from matplotlib.axes import Axes from matplotlib.figure import Figure from matplotlib.backends.backend_qt5agg import ( diff --git a/pyslvs_ui/graphics/color.py b/pyslvs_ui/graphics/color.py index d98fb5f57..5764df39b 100644 --- a/pyslvs_ui/graphics/color.py +++ b/pyslvs_ui/graphics/color.py @@ -8,8 +8,8 @@ __email__ = "pyslvs@gmail.com" from typing import Tuple, Union -from qtpy.QtCore import QSize -from qtpy.QtGui import QColor, QIcon, QPixmap +from pyslvs_ui.qt.QtCore import QSize +from pyslvs_ui.qt.QtGui import QColor, QIcon, QPixmap from pyslvs import color_names, color_rgb _Color = Union[str, Tuple[int, int, int], None] diff --git a/pyslvs_ui/graphics/nx_layout.py b/pyslvs_ui/graphics/nx_layout.py index 139e28090..f36f35069 100644 --- a/pyslvs_ui/graphics/nx_layout.py +++ b/pyslvs_ui/graphics/nx_layout.py @@ -8,8 +8,8 @@ __email__ = "pyslvs@gmail.com" from typing import Mapping, Tuple, Optional -from qtpy.QtCore import Qt, QSize, QPointF -from qtpy.QtGui import QImage, QPainter, QBrush, QPen, QIcon, QPixmap, QFont +from pyslvs_ui.qt.QtCore import Qt, QSize, QPointF +from pyslvs_ui.qt.QtGui import QImage, QPainter, QBrush, QPen, QIcon, QPixmap, QFont from pyslvs import edges_view from pyslvs.graph import Graph, external_loop_layout from pyslvs_ui.info import logger diff --git a/pyslvs_ui/info/about.py b/pyslvs_ui/info/about.py index f8dc0843f..8d1a02922 100644 --- a/pyslvs_ui/info/about.py +++ b/pyslvs_ui/info/about.py @@ -8,8 +8,8 @@ __email__ = "pyslvs@gmail.com" from requests import get as get_url -from qtpy.QtCore import Qt, QCoreApplication -from qtpy.QtWidgets import QDialog, QWidget, QProgressDialog +from pyslvs_ui.qt.QtCore import Qt, QCoreApplication +from pyslvs_ui.qt.QtWidgets import QDialog, QWidget, QProgressDialog from pyslvs_ui import __version__ from .info import SYS_INFO, ARGUMENTS from .logging_handler import logger diff --git a/pyslvs_ui/info/about_ui.py b/pyslvs_ui/info/about_ui.py index 36a3daeea..4412315ee 100644 --- a/pyslvs_ui/info/about_ui.py +++ b/pyslvs_ui/info/about_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/info/info.py b/pyslvs_ui/info/info.py index 89938278c..fce1f1182 100644 --- a/pyslvs_ui/info/info.py +++ b/pyslvs_ui/info/info.py @@ -20,7 +20,7 @@ from argparse import ArgumentParser from dataclasses import dataclass from pyslvs_ui import __version__ -from pyslvs_ui.qt_patch import API +from pyslvs_ui.qt import API def has_module(name: str) -> bool: diff --git a/pyslvs_ui/info/logging_handler.py b/pyslvs_ui/info/logging_handler.py index 864bbbd84..db8b07b2f 100644 --- a/pyslvs_ui/info/logging_handler.py +++ b/pyslvs_ui/info/logging_handler.py @@ -16,7 +16,7 @@ from platform import system from logging import (DEBUG, INFO, ERROR, basicConfig, getLogger, Handler, StreamHandler, LogRecord) -from qtpy.QtCore import QObject, Signal +from pyslvs_ui.qt.QtCore import QObject, Signal from .info import ARGUMENTS, SYS_INFO logger = getLogger('matplotlib') diff --git a/pyslvs_ui/io/format_editor.py b/pyslvs_ui/io/format_editor.py index 096d87cea..3532999e0 100644 --- a/pyslvs_ui/io/format_editor.py +++ b/pyslvs_ui/io/format_editor.py @@ -9,10 +9,10 @@ from typing import ( TYPE_CHECKING, Tuple, List, Sequence, Dict, Mapping, Union, Any, ) -from qtpy.QtCore import QObject, QFileInfo -from qtpy.QtWidgets import QProgressDialog, QMessageBox +from pyslvs_ui.qt.QtCore import QObject, QFileInfo +from pyslvs_ui.qt.QtWidgets import QProgressDialog, QMessageBox from pyslvs_ui import __version__ -from pyslvs_ui.qt_patch import QABCMeta +from pyslvs_ui.qt import QABCMeta from pyslvs_ui.info import logger from .overview import OverviewDialog diff --git a/pyslvs_ui/io/output_option.py b/pyslvs_ui/io/output_option.py index b3c4c6346..8209743d6 100644 --- a/pyslvs_ui/io/output_option.py +++ b/pyslvs_ui/io/output_option.py @@ -12,8 +12,8 @@ from os.path import isdir, isfile from shutil import which from subprocess import Popen, DEVNULL -from qtpy.QtCore import Slot, Qt, QDir -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot, Qt, QDir +from pyslvs_ui.qt.QtWidgets import ( QDialog, QMessageBox, QFileDialog, @@ -27,9 +27,9 @@ QSizePolicy, QSpacerItem, ) -from qtpy.QtGui import QIcon, QPixmap +from pyslvs_ui.qt.QtGui import QIcon, QPixmap from pyslvs import VPoint, VLink -from pyslvs_ui.qt_patch import QABCMeta +from pyslvs_ui.qt import QABCMeta from .slvs import slvs2_frame, slvs2_part from .dxf import DXF_VERSIONS, DXF_VERSIONS_MAP, dxf_frame, dxf_boundary from .output_option_ui import Ui_Dialog diff --git a/pyslvs_ui/io/output_option_ui.py b/pyslvs_ui/io/output_option_ui.py index b0a42b08c..3aac05fb4 100644 --- a/pyslvs_ui/io/output_option_ui.py +++ b/pyslvs_ui/io/output_option_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/io/overview.py b/pyslvs_ui/io/overview.py index 3147adf9d..195a3b3fa 100644 --- a/pyslvs_ui/io/overview.py +++ b/pyslvs_ui/io/overview.py @@ -8,9 +8,9 @@ __email__ = "pyslvs@gmail.com" from typing import Tuple, Sequence, Mapping, Any -from qtpy.QtCore import Qt -from qtpy.QtWidgets import QWidget, QDialog, QListWidgetItem -from qtpy.QtGui import QPixmap +from pyslvs_ui.qt.QtCore import Qt +from pyslvs_ui.qt.QtWidgets import QWidget, QDialog, QListWidgetItem +from pyslvs_ui.qt.QtGui import QPixmap from .overview_ui import Ui_Dialog _Paths = Sequence[Sequence[Tuple[float, float]]] diff --git a/pyslvs_ui/io/overview_ui.py b/pyslvs_ui/io/overview_ui.py index 7e613621a..856fe3031 100644 --- a/pyslvs_ui/io/overview_ui.py +++ b/pyslvs_ui/io/overview_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/io/preference_ui.py b/pyslvs_ui/io/preference_ui.py index 6b4e845d7..55c372c7c 100644 --- a/pyslvs_ui/io/preference_ui.py +++ b/pyslvs_ui/io/preference_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/io/preferences.py b/pyslvs_ui/io/preferences.py index f44b5ce45..f8732ae1a 100644 --- a/pyslvs_ui/io/preferences.py +++ b/pyslvs_ui/io/preferences.py @@ -9,8 +9,8 @@ from typing import Optional from dataclasses import fields, Field -from qtpy.QtCore import Slot -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot +from pyslvs_ui.qt.QtWidgets import ( QDialog, QLineEdit, QSpinBox, @@ -20,7 +20,7 @@ QDialogButtonBox, QMessageBox, ) -from qtpy.QtGui import QCloseEvent +from pyslvs_ui.qt.QtGui import QCloseEvent from pyslvs_ui.info import KERNELS, Kernel from pyslvs_ui.widgets import Preferences, MainWindowBase from .format_editor import ProjectFormat diff --git a/pyslvs_ui/io/project.py b/pyslvs_ui/io/project.py index 64774ce41..cec1f4e9a 100644 --- a/pyslvs_ui/io/project.py +++ b/pyslvs_ui/io/project.py @@ -12,18 +12,18 @@ from typing import TYPE_CHECKING, Mapping, Union from os.path import join -from qtpy.QtCore import Slot, QFileInfo, QDateTime -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot, QFileInfo, QDateTime +from pyslvs_ui.qt.QtWidgets import ( QUndoView, QVBoxLayout, QWidget, QInputDialog, QMessageBox, ) -from qtpy.QtGui import QPixmap, QIcon +from pyslvs_ui.qt.QtGui import QPixmap, QIcon from pyslvs import example_list, all_examples from pyslvs_ui.info import logger, size_format -from pyslvs_ui.qt_patch import qt_image_format +from pyslvs_ui.qt import qt_image_format from .project_yaml import YamlEditor from .project_pickle import PickleEditor from .project_ui import Ui_Form diff --git a/pyslvs_ui/io/project_pickle.py b/pyslvs_ui/io/project_pickle.py index e52566f57..24c2dcfad 100644 --- a/pyslvs_ui/io/project_pickle.py +++ b/pyslvs_ui/io/project_pickle.py @@ -8,7 +8,7 @@ __email__ = "pyslvs@gmail.com" from pickle import load, dump, UnpicklingError, HIGHEST_PROTOCOL -from qtpy.QtWidgets import QMessageBox +from pyslvs_ui.qt.QtWidgets import QMessageBox from .format_editor import FormatEditor diff --git a/pyslvs_ui/io/project_ui.py b/pyslvs_ui/io/project_ui.py index 21387f028..24bd6f712 100644 --- a/pyslvs_ui/io/project_ui.py +++ b/pyslvs_ui/io/project_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/pyslvs_ui/io/project_yaml.py b/pyslvs_ui/io/project_yaml.py index 3a6c851d1..7879631ad 100644 --- a/pyslvs_ui/io/project_yaml.py +++ b/pyslvs_ui/io/project_yaml.py @@ -13,7 +13,7 @@ from yaml import safe_load, safe_dump from yaml.error import YAMLError from yaml.representer import SafeRepresenter -from qtpy.QtWidgets import QMessageBox +from pyslvs_ui.qt.QtWidgets import QMessageBox from .format_editor import FormatEditor, ProjectFormat # Add a patch for numpy numbers diff --git a/pyslvs_ui/io/script.py b/pyslvs_ui/io/script.py index 771cad4a3..ec8acd8f5 100644 --- a/pyslvs_ui/io/script.py +++ b/pyslvs_ui/io/script.py @@ -13,8 +13,8 @@ from qrcode import make from qrcode.image.base import BaseImage from numpy import full, ndarray, uint8 -from qtpy.QtCore import Slot, Qt -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot, Qt +from pyslvs_ui.qt.QtWidgets import ( QApplication, QDialog, QDialogButtonBox, @@ -25,7 +25,7 @@ QLineEdit, QSizePolicy, ) -from qtpy.QtGui import QIcon, QPixmap, QImage, QWheelEvent, QFont +from pyslvs_ui.qt.QtGui import QIcon, QPixmap, QImage, QWheelEvent, QFont from .script_ui import Ui_Dialog if TYPE_CHECKING: diff --git a/pyslvs_ui/io/script_ui.py b/pyslvs_ui/io/script_ui.py index b474f91fc..950690c56 100644 --- a/pyslvs_ui/io/script_ui.py +++ b/pyslvs_ui/io/script_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/main_window/__init__.py b/pyslvs_ui/main_window/__init__.py index da54c2935..787ed1373 100644 --- a/pyslvs_ui/main_window/__init__.py +++ b/pyslvs_ui/main_window/__init__.py @@ -20,9 +20,9 @@ __email__ = "pyslvs@gmail.com" from typing import Tuple, Sequence -from qtpy.QtCore import Slot -from qtpy.QtWidgets import QMessageBox, QInputDialog -from qtpy.QtGui import QTextCursor, QCloseEvent +from pyslvs_ui.qt.QtCore import Slot +from pyslvs_ui.qt.QtWidgets import QMessageBox, QInputDialog +from pyslvs_ui.qt.QtGui import QTextCursor, QCloseEvent from pyslvs_ui.info import XStream, logger from .io import IOMethodInterface diff --git a/pyslvs_ui/main_window/actions.py b/pyslvs_ui/main_window/actions.py index b0215713f..5f8cefc98 100644 --- a/pyslvs_ui/main_window/actions.py +++ b/pyslvs_ui/main_window/actions.py @@ -9,8 +9,8 @@ from typing import cast, Sequence, Callable, Union from abc import ABC -from qtpy.QtCore import Slot, QPoint -from qtpy.QtWidgets import QAction, QApplication, QTableWidget +from pyslvs_ui.qt.QtCore import Slot, QPoint +from pyslvs_ui.qt.QtWidgets import QAction, QApplication, QTableWidget from pyslvs import VLink from pyslvs_ui.graphics import BaseCanvas from pyslvs_ui.widgets import EditPointTable, EditLinkTable, Preferences diff --git a/pyslvs_ui/main_window/entities.py b/pyslvs_ui/main_window/entities.py index dcccf90b0..edd2b96d2 100644 --- a/pyslvs_ui/main_window/entities.py +++ b/pyslvs_ui/main_window/entities.py @@ -15,8 +15,8 @@ from collections import Counter from math import sin, cos, radians, isnan from numpy import array -from qtpy.QtCore import Slot -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot +from pyslvs_ui.qt.QtWidgets import ( QDialogButtonBox, QDialog, QDoubleSpinBox, diff --git a/pyslvs_ui/main_window/io.py b/pyslvs_ui/main_window/io.py index 745105463..30f95886c 100644 --- a/pyslvs_ui/main_window/io.py +++ b/pyslvs_ui/main_window/io.py @@ -13,15 +13,15 @@ from abc import ABC from dataclasses import Field, fields from lark.exceptions import LarkError -from qtpy.QtCore import Slot, QUrl, QFile, QFileInfo, QMimeData -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot, QUrl, QFile, QFileInfo, QMimeData +from pyslvs_ui.qt.QtWidgets import ( QApplication, QMessageBox, QInputDialog, QFileDialog, QProgressDialog, ) -from qtpy.QtGui import ( +from pyslvs_ui.qt.QtGui import ( QDesktopServices, QPixmap, QIcon, @@ -30,7 +30,7 @@ ) from pyslvs import parse_params, VLink from pyslvs_ui import __version__ -from pyslvs_ui.qt_patch import qt_image_format, qt_image_suffix +from pyslvs_ui.qt import qt_image_format, qt_image_suffix from pyslvs_ui.info import ( ARGUMENTS, logger, diff --git a/pyslvs_ui/main_window/solver.py b/pyslvs_ui/main_window/solver.py index f101a879d..d33b58d63 100644 --- a/pyslvs_ui/main_window/solver.py +++ b/pyslvs_ui/main_window/solver.py @@ -11,7 +11,7 @@ from math import radians, cos, sin from abc import ABC, abstractmethod from traceback import format_exc -from qtpy.QtCore import Slot +from pyslvs_ui.qt.QtCore import Slot from pyslvs import ( edges_view, graph2vpoints, diff --git a/pyslvs_ui/main_window/storage.py b/pyslvs_ui/main_window/storage.py index 34b90d3d0..2a53a919b 100644 --- a/pyslvs_ui/main_window/storage.py +++ b/pyslvs_ui/main_window/storage.py @@ -9,8 +9,8 @@ from typing import Sequence, Dict, Mapping, Optional from abc import ABC -from qtpy.QtCore import Slot -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot +from pyslvs_ui.qt.QtWidgets import ( QApplication, QListWidgetItem, QInputDialog, diff --git a/pyslvs_ui/qt/QtCore.py b/pyslvs_ui/qt/QtCore.py new file mode 100644 index 000000000..d73976fa2 --- /dev/null +++ b/pyslvs_ui/qt/QtCore.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +"""This module mounted Qt.QtCore.""" + +__author__ = "Yuan Chang" +__copyright__ = "Copyright (C) 2016-2021" +__license__ = "AGPL" +__email__ = "pyslvs@gmail.com" + +from .backend import BACKEND + +if BACKEND == "PyQt5": + from PyQt5.QtCore import * +else: + raise ImportError +Signal = pyqtSignal +Slot = pyqtSlot diff --git a/pyslvs_ui/qt/QtGui.py b/pyslvs_ui/qt/QtGui.py new file mode 100644 index 000000000..b9a71293e --- /dev/null +++ b/pyslvs_ui/qt/QtGui.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +"""This module mounted Qt.QtGui.""" + +__author__ = "Yuan Chang" +__copyright__ = "Copyright (C) 2016-2021" +__license__ = "AGPL" +__email__ = "pyslvs@gmail.com" + +from .backend import BACKEND + +if BACKEND == "PyQt5": + from PyQt5.QtGui import * +else: + raise ImportError diff --git a/pyslvs_ui/qt/QtWidgets.py b/pyslvs_ui/qt/QtWidgets.py new file mode 100644 index 000000000..1fa95dd3d --- /dev/null +++ b/pyslvs_ui/qt/QtWidgets.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +"""This module mounted Qt.QtWidgets.""" + +__author__ = "Yuan Chang" +__copyright__ = "Copyright (C) 2016-2021" +__license__ = "AGPL" +__email__ = "pyslvs@gmail.com" + +from .backend import BACKEND + +if BACKEND == "PyQt5": + from PyQt5.QtWidgets import * +else: + raise ImportError diff --git a/pyslvs_ui/qt_patch.py b/pyslvs_ui/qt/__init__.py similarity index 88% rename from pyslvs_ui/qt_patch.py rename to pyslvs_ui/qt/__init__.py index 1fc73513a..5b2afa390 100644 --- a/pyslvs_ui/qt_patch.py +++ b/pyslvs_ui/qt/__init__.py @@ -14,10 +14,10 @@ from abc import ABCMeta from os.path import join, dirname, abspath from importlib.metadata import version -from qtpy import API_NAME -from qtpy.QtCore import QObject, QDir +from .backend import BACKEND +from .QtCore import QObject, QDir -API = f"{API_NAME} {version(API_NAME)}" +API = f"{BACKEND} {version(BACKEND)}" qt_image_suffix = [] qt_image_format = [] for suffix, name in ( @@ -36,7 +36,7 @@ qt_image_suffix = tuple(qt_image_suffix) qt_image_format = tuple(qt_image_format) del suffix, name -QDir.addSearchPath("icons", join(abspath(dirname(__file__)), "icons")) +QDir.addSearchPath("icons", abspath(join(dirname(__file__), "..", "icons"))) class QABCMeta(type(QObject), ABCMeta): # type: ignore diff --git a/pyslvs_ui/qt/backend.py b/pyslvs_ui/qt/backend.py new file mode 100644 index 000000000..b27885a17 --- /dev/null +++ b/pyslvs_ui/qt/backend.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +"""This module will try to found the backend of Qt.""" + +__all__ = ['BACKEND'] +__author__ = "Yuan Chang" +__copyright__ = "Copyright (C) 2016-2021" +__license__ = "AGPL" +__email__ = "pyslvs@gmail.com" + +try: + import PyQt5.QtCore +except ImportError: + raise ImportError("no Qt backend found (support PyQt5 only)") +else: + BACKEND = "PyQt5" diff --git a/pyslvs_ui/synthesis/collections/__init__.py b/pyslvs_ui/synthesis/collections/__init__.py index 53b35896a..6ef3643d4 100644 --- a/pyslvs_ui/synthesis/collections/__init__.py +++ b/pyslvs_ui/synthesis/collections/__init__.py @@ -18,8 +18,8 @@ __email__ = "pyslvs@gmail.com" from typing import TYPE_CHECKING, List, Tuple, Sequence, Dict, Any -from qtpy.QtWidgets import QWidget, QVBoxLayout, QTabWidget -from qtpy.QtGui import QIcon, QPixmap +from pyslvs_ui.qt.QtWidgets import QWidget, QVBoxLayout, QTabWidget +from pyslvs_ui.qt.QtGui import QIcon, QPixmap from .structure_widget import StructureWidget from .configure_widget import ConfigureWidget from .dialogs import CollectionsDialog diff --git a/pyslvs_ui/synthesis/collections/configure_widget.py b/pyslvs_ui/synthesis/collections/configure_widget.py index c82b14425..96e642db6 100644 --- a/pyslvs_ui/synthesis/collections/configure_widget.py +++ b/pyslvs_ui/synthesis/collections/configure_widget.py @@ -15,8 +15,8 @@ ) from math import hypot import pprint -from qtpy.QtCore import Signal, Slot -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Signal, Slot +from pyslvs_ui.qt.QtWidgets import ( QWidget, QMessageBox, QInputDialog, @@ -24,7 +24,7 @@ QLabel, QApplication, ) -from qtpy.QtGui import QMouseEvent +from pyslvs_ui.qt.QtGui import QMouseEvent from pyslvs import edges_view, graph2vpoints, parse_pos from pyslvs.graph import Graph from pyslvs_ui.graphics import PreviewCanvas diff --git a/pyslvs_ui/synthesis/collections/configure_widget_ui.py b/pyslvs_ui/synthesis/collections/configure_widget_ui.py index a5371502a..35044b651 100644 --- a/pyslvs_ui/synthesis/collections/configure_widget_ui.py +++ b/pyslvs_ui/synthesis/collections/configure_widget_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/pyslvs_ui/synthesis/collections/dialogs/collections.py b/pyslvs_ui/synthesis/collections/dialogs/collections.py index 0877886c7..1d51ab388 100644 --- a/pyslvs_ui/synthesis/collections/dialogs/collections.py +++ b/pyslvs_ui/synthesis/collections/dialogs/collections.py @@ -9,8 +9,8 @@ from copy import deepcopy from typing import Dict, Mapping, Callable, Any -from qtpy.QtCore import Qt, Slot -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Qt, Slot +from pyslvs_ui.qt.QtWidgets import ( QDialog, QDialogButtonBox, QInputDialog, diff --git a/pyslvs_ui/synthesis/collections/dialogs/collections_ui.py b/pyslvs_ui/synthesis/collections/dialogs/collections_ui.py index a81258167..a883b249c 100644 --- a/pyslvs_ui/synthesis/collections/dialogs/collections_ui.py +++ b/pyslvs_ui/synthesis/collections/dialogs/collections_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/synthesis/collections/dialogs/customs.py b/pyslvs_ui/synthesis/collections/dialogs/customs.py index ccee429ce..7ef560ee3 100644 --- a/pyslvs_ui/synthesis/collections/dialogs/customs.py +++ b/pyslvs_ui/synthesis/collections/dialogs/customs.py @@ -10,8 +10,8 @@ __email__ = "pyslvs@gmail.com" from typing import TYPE_CHECKING -from qtpy.QtCore import Slot, Qt -from qtpy.QtWidgets import QDialog +from pyslvs_ui.qt.QtCore import Slot, Qt +from pyslvs_ui.qt.QtWidgets import QDialog from .customs_ui import Ui_Dialog if TYPE_CHECKING: diff --git a/pyslvs_ui/synthesis/collections/dialogs/customs_ui.py b/pyslvs_ui/synthesis/collections/dialogs/customs_ui.py index a157dce20..2e5a20752 100644 --- a/pyslvs_ui/synthesis/collections/dialogs/customs_ui.py +++ b/pyslvs_ui/synthesis/collections/dialogs/customs_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/synthesis/collections/dialogs/targets.py b/pyslvs_ui/synthesis/collections/dialogs/targets.py index 2379d693d..4d7e3ffcb 100644 --- a/pyslvs_ui/synthesis/collections/dialogs/targets.py +++ b/pyslvs_ui/synthesis/collections/dialogs/targets.py @@ -10,8 +10,8 @@ __email__ = "pyslvs@gmail.com" from typing import List, Iterable, Iterator -from qtpy.QtCore import Slot, Qt -from qtpy.QtWidgets import QWidget, QDialog, QListWidget, QListWidgetItem +from pyslvs_ui.qt.QtCore import Slot, Qt +from pyslvs_ui.qt.QtWidgets import QWidget, QDialog, QListWidget, QListWidgetItem from .targets_ui import Ui_Dialog diff --git a/pyslvs_ui/synthesis/collections/dialogs/targets_ui.py b/pyslvs_ui/synthesis/collections/dialogs/targets_ui.py index fab91d071..6b6caa7e2 100644 --- a/pyslvs_ui/synthesis/collections/dialogs/targets_ui.py +++ b/pyslvs_ui/synthesis/collections/dialogs/targets_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/synthesis/collections/structure_widget.py b/pyslvs_ui/synthesis/collections/structure_widget.py index 070042ee8..0eacd7dd4 100644 --- a/pyslvs_ui/synthesis/collections/structure_widget.py +++ b/pyslvs_ui/synthesis/collections/structure_widget.py @@ -10,8 +10,8 @@ __email__ = "pyslvs@gmail.com" from typing import TYPE_CHECKING, List, Tuple, Sequence, Dict, Iterable -from qtpy.QtCore import Signal, Slot, Qt, QSize, QPointF, QCoreApplication -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Signal, Slot, Qt, QSize, QPointF, QCoreApplication +from pyslvs_ui.qt.QtWidgets import ( QMessageBox, QProgressDialog, QListWidgetItem, @@ -19,7 +19,7 @@ QWidget, QApplication, ) -from qtpy.QtGui import QImage, QPainter, QPixmap +from pyslvs_ui.qt.QtGui import QImage, QPainter, QPixmap from pyslvs.graph import ( Graph, link_assortment, @@ -28,7 +28,7 @@ is_planar, external_loop_layout, ) -from pyslvs_ui.qt_patch import qt_image_format +from pyslvs_ui.qt import qt_image_format from pyslvs_ui.graphics import graph2icon, engine_picker, engines from .dialogs.targets import TargetsDialog from .structure_widget_ui import Ui_Form diff --git a/pyslvs_ui/synthesis/collections/structure_widget_ui.py b/pyslvs_ui/synthesis/collections/structure_widget_ui.py index 8eb020dbd..a464c5745 100644 --- a/pyslvs_ui/synthesis/collections/structure_widget_ui.py +++ b/pyslvs_ui/synthesis/collections/structure_widget_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/__init__.py b/pyslvs_ui/synthesis/dimensional_synthesis/__init__.py index 40861e89a..5853892f1 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/__init__.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/__init__.py @@ -24,9 +24,9 @@ from pyslvs import expr_solving, parse_pos, parse_vpoints, t_config from pyslvs.optimization import norm_path from pyslvs.metaheuristics import AlgorithmType, default -from qtpy.QtCore import QModelIndex, Slot -from qtpy.QtGui import QIcon, QPixmap -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import QModelIndex, Slot +from pyslvs_ui.qt.QtGui import QIcon, QPixmap +from pyslvs_ui.qt.QtWidgets import ( QApplication, QDoubleSpinBox, QHeaderView, diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/chart.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/chart.py index df9782d5d..fd608dc4c 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/chart.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/chart.py @@ -9,8 +9,8 @@ from typing import Sequence, Mapping, Any from numpy import array -from qtpy.QtCore import Qt, QSize -from qtpy.QtWidgets import QDialog, QVBoxLayout, QTabWidget, QWidget +from pyslvs_ui.qt.QtCore import Qt, QSize +from pyslvs_ui.qt.QtWidgets import QDialog, QVBoxLayout, QTabWidget, QWidget from pyslvs_ui.graphics import DataChart diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/edit_path.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/edit_path.py index 8cb2044a3..1bf2b8933 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/edit_path.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/edit_path.py @@ -12,8 +12,8 @@ from typing import TYPE_CHECKING from math import cos, sin, atan2, radians, hypot from numpy import ndarray, array, linspace, concatenate, full_like -from qtpy.QtCore import Slot, Qt -from qtpy.QtWidgets import QDialog +from pyslvs_ui.qt.QtCore import Slot, Qt +from pyslvs_ui.qt.QtWidgets import QDialog from pyslvs import efd_fitting from pyslvs_ui.graphics import DataChartDialog from pyslvs_ui.info import HAS_SCIPY diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/edit_path_ui.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/edit_path_ui.py index eaf23fb38..f0448d37c 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/edit_path_ui.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/edit_path_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/options.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/options.py index 8d19035d4..4433a5aae 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/options.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/options.py @@ -8,8 +8,8 @@ __email__ = "pyslvs@gmail.com" from typing import cast, Mapping, Union -from qtpy.QtCore import Slot, Qt -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot, Qt +from pyslvs_ui.qt.QtWidgets import ( QDialog, QTableWidgetItem, QDoubleSpinBox, diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/options_ui.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/options_ui.py index 5776ba15f..aca86fa89 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/options_ui.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/options_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/preview.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/preview.py index 9a8d0d716..48a1259de 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/preview.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/preview.py @@ -11,9 +11,9 @@ from itertools import chain from typing import Tuple, List, Dict, Sequence, Any from numpy import linspace, concatenate -from qtpy.QtCore import Slot, Qt, QTimer, QPointF, QRectF, QSizeF -from qtpy.QtWidgets import QDialog, QWidget -from qtpy.QtGui import QPen, QFont, QPaintEvent +from pyslvs_ui.qt.QtCore import Slot, Qt, QTimer, QPointF, QRectF, QSizeF +from pyslvs_ui.qt.QtWidgets import QDialog, QWidget +from pyslvs_ui.qt.QtGui import QPen, QFont, QPaintEvent from pyslvs import ( color_rgb, get_vlinks, VPoint, VLink, parse_vpoints, efd_fitting, ) diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/preview_ui.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/preview_ui.py index a06094d2c..35e6a3eb6 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/preview_ui.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/preview_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/progress.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/progress.py index 51ab53986..3e6821828 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/progress.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/progress.py @@ -8,8 +8,8 @@ __email__ = "pyslvs@gmail.com" from typing import List, Dict, Any -from qtpy.QtCore import Qt, QTimer, Signal, Slot -from qtpy.QtWidgets import QDialog +from pyslvs_ui.qt.QtCore import Qt, QTimer, Signal, Slot +from pyslvs_ui.qt.QtWidgets import QDialog from pyslvs.metaheuristics import AlgorithmType from pyslvs_ui.info import logger from .progress_ui import Ui_Dialog diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/progress_ui.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/progress_ui.py index 9748ce1d0..9a8b3148f 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/progress_ui.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/progress_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Dialog(object): diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/thread.py b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/thread.py index fb988980e..4f5ddd80e 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/thread.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dialogs/thread.py @@ -10,8 +10,8 @@ from typing import cast, Dict, Any from time import process_time from platform import system, release, machine, processor -from qtpy.QtCore import Signal -from qtpy.QtWidgets import QWidget +from pyslvs_ui.qt.QtCore import Signal +from pyslvs_ui.qt.QtWidgets import QWidget from pyslvs.optimization import FPlanar, FConfig from pyslvs.metaheuristics import algorithm, AlgorithmType, Setting from pyslvs_ui.info import logger diff --git a/pyslvs_ui/synthesis/dimensional_synthesis/dimension_widget_ui.py b/pyslvs_ui/synthesis/dimensional_synthesis/dimension_widget_ui.py index 6deeca32a..2f8e2c20c 100644 --- a/pyslvs_ui/synthesis/dimensional_synthesis/dimension_widget_ui.py +++ b/pyslvs_ui/synthesis/dimensional_synthesis/dimension_widget_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/pyslvs_ui/synthesis/structure_synthesis/__init__.py b/pyslvs_ui/synthesis/structure_synthesis/__init__.py index 0c2df3c59..90b585445 100644 --- a/pyslvs_ui/synthesis/structure_synthesis/__init__.py +++ b/pyslvs_ui/synthesis/structure_synthesis/__init__.py @@ -14,7 +14,7 @@ from typing import TYPE_CHECKING, List, Sequence, Dict, Optional from time import process_time -from qtpy.QtCore import ( +from pyslvs_ui.qt.QtCore import ( Slot, Qt, QSize, @@ -22,7 +22,7 @@ QPoint, QPointF, ) -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtWidgets import ( QWidget, QMenu, QAction, @@ -35,9 +35,9 @@ QTreeWidgetItem, QHeaderView, ) -from qtpy.QtGui import QIcon, QPixmap, QImage, QPainter +from pyslvs_ui.qt.QtGui import QIcon, QPixmap, QImage, QPainter from pyslvs.graph import Graph, link_assortment, contracted_link_assortment -from pyslvs_ui.qt_patch import qt_image_format +from pyslvs_ui.qt import qt_image_format from pyslvs_ui.graphics import graph2icon, engines from .thread import assortment_eval, LinkThread, GraphThread from .structure_widget_ui import Ui_Form diff --git a/pyslvs_ui/synthesis/structure_synthesis/structure_widget_ui.py b/pyslvs_ui/synthesis/structure_synthesis/structure_widget_ui.py index 86ac8140d..d185e9296 100644 --- a/pyslvs_ui/synthesis/structure_synthesis/structure_widget_ui.py +++ b/pyslvs_ui/synthesis/structure_synthesis/structure_widget_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/pyslvs_ui/synthesis/structure_synthesis/thread.py b/pyslvs_ui/synthesis/structure_synthesis/thread.py index e31070748..3f0a7d59d 100644 --- a/pyslvs_ui/synthesis/structure_synthesis/thread.py +++ b/pyslvs_ui/synthesis/structure_synthesis/thread.py @@ -8,8 +8,8 @@ __email__ = "pyslvs@gmail.com" from typing import Sequence, Dict, List -from qtpy.QtCore import Signal -from qtpy.QtWidgets import QWidget, QTreeWidgetItem +from pyslvs_ui.qt.QtCore import Signal +from pyslvs_ui.qt.QtWidgets import QWidget, QTreeWidgetItem from pyslvs.graph import ( link_synthesis, contracted_link_synthesis, diff --git a/pyslvs_ui/synthesis/thread.py b/pyslvs_ui/synthesis/thread.py index 202b4eb83..5d5ae08df 100644 --- a/pyslvs_ui/synthesis/thread.py +++ b/pyslvs_ui/synthesis/thread.py @@ -8,9 +8,9 @@ __email__ = "pyslvs@gmail.com" from abc import abstractmethod -from qtpy.QtCore import Slot, QThread -from qtpy.QtWidgets import QWidget -from pyslvs_ui.qt_patch import QABCMeta +from pyslvs_ui.qt.QtCore import Slot, QThread +from pyslvs_ui.qt.QtWidgets import QWidget +from pyslvs_ui.qt import QABCMeta class BaseThread(QThread, metaclass=QABCMeta): diff --git a/pyslvs_ui/widgets/canvas.py b/pyslvs_ui/widgets/canvas.py index 59a0874ab..945e44cc1 100644 --- a/pyslvs_ui/widgets/canvas.py +++ b/pyslvs_ui/widgets/canvas.py @@ -13,9 +13,9 @@ from typing import ( cast, TYPE_CHECKING, List, Tuple, Sequence, Union, Mapping, ) -from qtpy.QtCore import Slot, Qt, QRectF, QPoint, QPointF, QSizeF -from qtpy.QtWidgets import QApplication, QToolTip, QWidget -from qtpy.QtGui import QRegion, QCursor, QWheelEvent, QPixmap, QImage +from pyslvs_ui.qt.QtCore import Slot, Qt, QRectF, QPoint, QPointF, QSizeF +from pyslvs_ui.qt.QtWidgets import QApplication, QToolTip, QWidget +from pyslvs_ui.qt.QtGui import QRegion, QCursor, QWheelEvent, QPixmap, QImage from pyslvs import VJoint from .canvas_base import MainCanvasBase, FreeMode, SelectMode, ZoomBy diff --git a/pyslvs_ui/widgets/canvas_base.py b/pyslvs_ui/widgets/canvas_base.py index d0f520270..844dac670 100644 --- a/pyslvs_ui/widgets/canvas_base.py +++ b/pyslvs_ui/widgets/canvas_base.py @@ -14,9 +14,9 @@ from enum import IntEnum, auto, unique from dataclasses import dataclass, field from math import degrees, sin, cos, atan2, hypot -from qtpy.QtCore import Signal, Slot, Qt, QRectF, QPoint, QPointF, QLineF -from qtpy.QtWidgets import QApplication -from qtpy.QtGui import QPolygonF, QFont, QPen, QColor, QPaintEvent, QMouseEvent +from pyslvs_ui.qt.QtCore import Signal, Slot, Qt, QRectF, QPoint, QPointF, QLineF +from pyslvs_ui.qt.QtWidgets import QApplication +from pyslvs_ui.qt.QtGui import QPolygonF, QFont, QPen, QColor, QPaintEvent, QMouseEvent from pyslvs import VJoint, VPoint, VLink from pyslvs_ui.graphics import ( convex_hull, BaseCanvas, color_qt, LINK_COLOR, RangeDetector, diff --git a/pyslvs_ui/widgets/inputs/__init__.py b/pyslvs_ui/widgets/inputs/__init__.py index 6be9181a3..2e3d4d4fb 100644 --- a/pyslvs_ui/widgets/inputs/__init__.py +++ b/pyslvs_ui/widgets/inputs/__init__.py @@ -18,12 +18,12 @@ from copy import copy from numpy import array, ndarray, hypot, arctan2, vstack, hstack from numpy.fft import fft -from qtpy.QtCore import Signal, Slot, QTimer -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Signal, Slot, QTimer +from pyslvs_ui.qt.QtWidgets import ( QWidget, QMessageBox, QInputDialog, QListWidgetItem, QApplication, QCheckBox, ) -from qtpy.QtGui import QIcon, QPixmap +from pyslvs_ui.qt.QtGui import QIcon, QPixmap from pyslvs import VJoint from pyslvs.optimization import ( curvature, derivative, path_signature, norm_path, norm_pca, diff --git a/pyslvs_ui/widgets/inputs/animation.py b/pyslvs_ui/widgets/inputs/animation.py index c8679220b..3474ea9bf 100644 --- a/pyslvs_ui/widgets/inputs/animation.py +++ b/pyslvs_ui/widgets/inputs/animation.py @@ -4,12 +4,12 @@ from typing import Sequence, Tuple, Mapping from math import cos, sin, atan2, hypot, degrees -from qtpy.QtCore import Qt, Slot, QTimer -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Qt, Slot, QTimer +from pyslvs_ui.qt.QtWidgets import ( QWidget, QDialog, QVBoxLayout, QHBoxLayout, QSlider, QPushButton, QLabel, QSpacerItem, QSizePolicy, QDoubleSpinBox, QComboBox, ) -from qtpy.QtGui import QPaintEvent, QPen, QPixmap, QIcon +from pyslvs_ui.qt.QtGui import QPaintEvent, QPen, QPixmap, QIcon from numpy import array, ndarray, isclose, isnan from pyslvs import VPoint, VLink, VJoint from pyslvs.optimization import derivative diff --git a/pyslvs_ui/widgets/inputs/inputs_ui.py b/pyslvs_ui/widgets/inputs/inputs_ui.py index c6231f2dd..90790da5e 100644 --- a/pyslvs_ui/widgets/inputs/inputs_ui.py +++ b/pyslvs_ui/widgets/inputs/inputs_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_Form(object): diff --git a/pyslvs_ui/widgets/inputs/rotatable.py b/pyslvs_ui/widgets/inputs/rotatable.py index c794e7cd0..ac1574191 100644 --- a/pyslvs_ui/widgets/inputs/rotatable.py +++ b/pyslvs_ui/widgets/inputs/rotatable.py @@ -7,8 +7,8 @@ __license__ = "AGPL" __email__ = "pyslvs@gmail.com" -from qtpy.QtCore import Qt, Signal, Slot, QSize -from qtpy.QtWidgets import QWidget, QDial, QGraphicsView, QGraphicsScene +from pyslvs_ui.qt.QtCore import Qt, Signal, Slot, QSize +from pyslvs_ui.qt.QtWidgets import QWidget, QDial, QGraphicsView, QGraphicsScene class QRotatableView(QGraphicsView): diff --git a/pyslvs_ui/widgets/main_abc.py b/pyslvs_ui/widgets/main_abc.py index d2f1b7465..31a1df2e4 100644 --- a/pyslvs_ui/widgets/main_abc.py +++ b/pyslvs_ui/widgets/main_abc.py @@ -11,11 +11,11 @@ from typing import Tuple, List, Sequence, Dict, Mapping, Optional, Any from abc import abstractmethod -from qtpy.QtCore import Qt, QPoint -from qtpy.QtWidgets import QMainWindow +from pyslvs_ui.qt.QtCore import Qt, QPoint +from pyslvs_ui.qt.QtWidgets import QMainWindow from pyslvs import VPoint from pyslvs.graph import Graph -from pyslvs_ui.qt_patch import QABCMeta +from pyslvs_ui.qt import QABCMeta from .main_ui import Ui_MainWindow _Coord = Tuple[float, float] diff --git a/pyslvs_ui/widgets/main_base.py b/pyslvs_ui/widgets/main_base.py index effbb3308..629adae5f 100644 --- a/pyslvs_ui/widgets/main_base.py +++ b/pyslvs_ui/widgets/main_base.py @@ -20,8 +20,8 @@ from abc import abstractmethod, ABC from enum import Flag, auto, unique from dataclasses import dataclass, field, fields, Field, astuple -from qtpy.QtCore import Slot, Qt, QPoint, QDir, QSettings -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Slot, Qt, QPoint, QDir, QSettings +from pyslvs_ui.qt.QtWidgets import ( QAction, QWidget, QMenu, @@ -29,7 +29,7 @@ QPushButton, QUndoStack, ) -from qtpy.QtGui import QIcon, QPixmap +from pyslvs_ui.qt.QtGui import QIcon, QPixmap from pyslvs import VPoint, VLink, color_rgb from pyslvs_ui.info import ARGUMENTS, logger, Kernel from pyslvs_ui.io import ProjectWidget, ProjectFormat diff --git a/pyslvs_ui/widgets/main_ui.py b/pyslvs_ui/widgets/main_ui.py index 91b989b5b..3aedfe406 100644 --- a/pyslvs_ui/widgets/main_ui.py +++ b/pyslvs_ui/widgets/main_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from qtpy import QtCore, QtGui, QtWidgets +from pyslvs_ui.qt import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): diff --git a/pyslvs_ui/widgets/tables.py b/pyslvs_ui/widgets/tables.py index 836325c23..b9dd7178a 100644 --- a/pyslvs_ui/widgets/tables.py +++ b/pyslvs_ui/widgets/tables.py @@ -18,8 +18,8 @@ TYPE_CHECKING, Tuple, List, Iterator, Sequence, Union, Optional, TypeVar, Generic, ) -from qtpy.QtCore import Signal, Qt, QTimer, Slot -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Signal, Qt, QTimer, Slot +from pyslvs_ui.qt.QtWidgets import ( QTableWidget, QSizePolicy, QAbstractItemView, @@ -30,9 +30,9 @@ QLabel, QWidget, ) -from qtpy.QtGui import QKeyEvent +from pyslvs_ui.qt.QtGui import QKeyEvent from pyslvs import EStack, VPoint, VLink, PointArgs, LinkArgs -from pyslvs_ui.qt_patch import QABCMeta +from pyslvs_ui.qt import QABCMeta from pyslvs_ui.graphics import color_icon if TYPE_CHECKING: diff --git a/pyslvs_ui/widgets/undo_redo.py b/pyslvs_ui/widgets/undo_redo.py index 0e162db26..7506577eb 100644 --- a/pyslvs_ui/widgets/undo_redo.py +++ b/pyslvs_ui/widgets/undo_redo.py @@ -24,8 +24,8 @@ Generic, Optional, TypeVar, ) from abc import abstractmethod -from qtpy.QtCore import Qt -from qtpy.QtWidgets import ( +from pyslvs_ui.qt.QtCore import Qt +from pyslvs_ui.qt.QtWidgets import ( QUndoCommand, QTableWidgetItem, QListWidget, @@ -33,9 +33,9 @@ QLineEdit, QWidget, ) -from qtpy.QtGui import QIcon, QPixmap +from pyslvs_ui.qt.QtGui import QIcon, QPixmap from pyslvs import VJoint, VPoint, VLink, color_rgb, PointArgs, LinkArgs -from pyslvs_ui.qt_patch import QABCMeta +from pyslvs_ui.qt import QABCMeta from .tables import BaseTableWidget, PointTableWidget, LinkTableWidget _Coord = Tuple[float, float] diff --git a/scripts/uic.py b/scripts/uic.py index abe6ab0cd..883a92b50 100644 --- a/scripts/uic.py +++ b/scripts/uic.py @@ -10,12 +10,14 @@ from os import walk from os.path import join from re import sub -from qtpy import PYQT5 -if PYQT5: +try: from PyQt5.uic import compileUi -else: - raise ModuleNotFoundError("no compiler found") +except ImportError: + try: + from PyQt6.uic import compileUi + except ImportError: + raise ModuleNotFoundError("no compiler found") def gen_ui(): @@ -36,8 +38,8 @@ def gen_ui(): f.seek(0) script_new = sub(r"from [\w.]+ import [\w]+_rc\n", "", f.read() - .replace("from PyQt5", "from qtpy") - .replace("from PySide2", "from qtpy") + .replace("from PyQt5", "from pyslvs_ui.qt") + .replace("from PyQt6", "from pyslvs_ui.qt") .replace(root + "/", "")) f.seek(0) f.truncate() diff --git a/setup.cfg b/setup.cfg index d15bf96e3..9f6ae137c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,6 @@ packages = find: python_requires = >=3.8 install_requires = requests - qtpy pyqt5 ezdxf numpy