Skip to content

Commit

Permalink
Drop qtpy and use PyQt5 instead
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Feb 16, 2025
1 parent fb653e1 commit f2f9927
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 82 deletions.
4 changes: 2 additions & 2 deletions labelme/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import yaml
from loguru import logger
from qtpy import QtCore
from qtpy import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtWidgets

from labelme import __appname__
from labelme import __version__
Expand Down
8 changes: 4 additions & 4 deletions labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import natsort
import numpy as np
from loguru import logger
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from qtpy.QtCore import Qt
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt

from labelme import __appname__
from labelme import ai
Expand Down
4 changes: 2 additions & 2 deletions labelme/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import numpy as np
import skimage.measure
from loguru import logger
from qtpy import QtCore
from qtpy import QtGui
from PyQt5 import QtCore
from PyQt5 import QtGui

import labelme.utils

Expand Down
6 changes: 3 additions & 3 deletions labelme/utils/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from math import sqrt

import numpy as np
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets

here = osp.dirname(osp.abspath(__file__))

Expand Down
2 changes: 1 addition & 1 deletion labelme/widgets/ai_prompt_widget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy import QtWidgets
from PyQt5 import QtWidgets


class AiPromptWidget(QtWidgets.QWidget):
Expand Down
6 changes: 3 additions & 3 deletions labelme/widgets/brightness_contrast_dialog.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PIL.Image
import PIL.ImageEnhance
from qtpy import QtWidgets
from qtpy.QtCore import Qt
from qtpy.QtGui import QImage
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QImage


class BrightnessContrastDialog(QtWidgets.QDialog):
Expand Down
22 changes: 11 additions & 11 deletions labelme/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import imgviz
from loguru import logger
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets

import labelme.ai
import labelme.utils
Expand All @@ -24,14 +24,14 @@


class Canvas(QtWidgets.QWidget):
zoomRequest = QtCore.Signal(int, QtCore.QPoint)
scrollRequest = QtCore.Signal(int, int)
newShape = QtCore.Signal()
selectionChanged = QtCore.Signal(list)
shapeMoved = QtCore.Signal()
drawingPolygon = QtCore.Signal(bool)
vertexSelected = QtCore.Signal(bool)
mouseMoved = QtCore.Signal(QtCore.QPointF)
zoomRequest = QtCore.pyqtSignal(int, QtCore.QPoint)
scrollRequest = QtCore.pyqtSignal(int, int)
newShape = QtCore.pyqtSignal()
selectionChanged = QtCore.pyqtSignal(list)
shapeMoved = QtCore.pyqtSignal()
drawingPolygon = QtCore.pyqtSignal(bool)
vertexSelected = QtCore.pyqtSignal(bool)
mouseMoved = QtCore.pyqtSignal(QtCore.QPointF)

CREATE, EDIT = 0, 1

Expand Down
2 changes: 1 addition & 1 deletion labelme/widgets/color_dialog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy import QtWidgets
from PyQt5 import QtWidgets


class ColorDialog(QtWidgets.QColorDialog):
Expand Down
4 changes: 2 additions & 2 deletions labelme/widgets/escapable_qlist_widget.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from qtpy import QtWidgets
from qtpy.QtCore import Qt
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt


class EscapableQListWidget(QtWidgets.QListWidget):
Expand Down
6 changes: 3 additions & 3 deletions labelme/widgets/file_dialog_preview.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json

from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets


class ScrollAreaPreview(QtWidgets.QScrollArea):
Expand Down
6 changes: 3 additions & 3 deletions labelme/widgets/label_dialog.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import re

from loguru import logger
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets

import labelme.utils

Expand Down
18 changes: 9 additions & 9 deletions labelme/widgets/label_list_widget.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from qtpy.QtCore import Qt
from qtpy.QtGui import QPalette
from qtpy.QtWidgets import QStyle
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPalette
from PyQt5.QtWidgets import QStyle


# https://stackoverflow.com/a/2039745/4158863
Expand Down Expand Up @@ -93,7 +93,7 @@ def __repr__(self):


class StandardItemModel(QtGui.QStandardItemModel):
itemDropped = QtCore.Signal()
itemDropped = QtCore.pyqtSignal()

def removeRows(self, *args, **kwargs):
ret = super().removeRows(*args, **kwargs)
Expand All @@ -102,8 +102,8 @@ def removeRows(self, *args, **kwargs):


class LabelListWidget(QtWidgets.QListView):
itemDoubleClicked = QtCore.Signal(LabelListWidgetItem)
itemSelectionChanged = QtCore.Signal(list, list)
itemDoubleClicked = QtCore.pyqtSignal(LabelListWidgetItem)
itemSelectionChanged = QtCore.pyqtSignal(list, list)

def __init__(self):
super(LabelListWidget, self).__init__()
Expand Down
4 changes: 2 additions & 2 deletions labelme/widgets/tool_bar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from qtpy import QtCore
from qtpy import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtWidgets


class ToolBar(QtWidgets.QToolBar):
Expand Down
4 changes: 2 additions & 2 deletions labelme/widgets/unique_label_qlist_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import html

from qtpy import QtWidgets
from qtpy.QtCore import Qt
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt

from .escapable_qlist_widget import EscapableQListWidget

Expand Down
6 changes: 3 additions & 3 deletions labelme/widgets/zoom_widget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets


class ZoomWidget(QtWidgets.QSpinBox):
Expand Down
30 changes: 1 addition & 29 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,11 @@ def get_install_requires():
"osam>=0.2.2",
"Pillow>=2.8",
"PyYAML",
"qtpy!=1.11.2",
"scikit-image",
"termcolor",
"PyQt5>=5.14.0",
]

# Find python binding for qt with priority:
# PyQt5 -> PySide2
# and PyQt5 is automatically installed on Python3.
QT_BINDING = None

try:
import PyQt5 # NOQA

QT_BINDING = "pyqt5"
except ImportError:
pass

if QT_BINDING is None:
try:
import PySide2 # NOQA

QT_BINDING = "pyside2"
except ImportError:
pass

if QT_BINDING is None:
# PyQt5 can be installed via pip for Python3
# 5.15.3, 5.15.4 won't work with PyInstaller
install_requires.append("PyQt5!=5.15.3,!=5.15.4")
QT_BINDING = "pyqt5"

del QT_BINDING

if os.name == "nt": # Windows
install_requires.append("colorama")

Expand Down
4 changes: 2 additions & 2 deletions tests/labelme_tests/widgets_tests/test_label_dialog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from qtpy import QtCore
from qtpy import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtWidgets

from labelme.widgets import LabelDialog
from labelme.widgets import LabelQLineEdit
Expand Down

0 comments on commit f2f9927

Please sign in to comment.