Skip to content

Commit

Permalink
Create Qt backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
KmolYuan committed Jul 1, 2021
1 parent fd373d3 commit b72c358
Show file tree
Hide file tree
Showing 80 changed files with 228 additions and 164 deletions.
6 changes: 3 additions & 3 deletions pyslvs_ui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pyslvs_ui/entities/edit_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/entities/edit_link_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions pyslvs_ui/entities/edit_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/entities/edit_point_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions pyslvs_ui/entities/relocate_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/entities/relocate_point_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions pyslvs_ui/entities/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
8 changes: 4 additions & 4 deletions pyslvs_ui/graphics/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions pyslvs_ui/graphics/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions pyslvs_ui/graphics/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions pyslvs_ui/graphics/nx_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pyslvs_ui/info/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/info/about_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/info/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/info/logging_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions pyslvs_ui/io/format_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions pyslvs_ui/io/output_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/io/output_option_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions pyslvs_ui/io/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/io/overview_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/io/preference_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions pyslvs_ui/io/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pyslvs_ui/io/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/io/project_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/io/project_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/io/project_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pyslvs_ui/io/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyslvs_ui/io/script_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions pyslvs_ui/main_window/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions pyslvs_ui/main_window/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pyslvs_ui/main_window/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit b72c358

Please sign in to comment.