From 6fa5510331216d5c24fc90e9dce3f28f69aa24fc Mon Sep 17 00:00:00 2001 From: Michael Rariden Date: Fri, 28 Jul 2023 11:51:08 -0400 Subject: [PATCH 1/3] switch PyQt5 to qtpy --- cellpose/gui/gui.py | 5 ++--- cellpose/gui/guiparts.py | 9 ++++----- cellpose/gui/io.py | 4 ++-- cellpose/io.py | 4 ++-- environment.yml | 4 ++-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/cellpose/gui/gui.py b/cellpose/gui/gui.py index 5a136de7..b9756351 100644 --- a/cellpose/gui/gui.py +++ b/cellpose/gui/gui.py @@ -7,11 +7,10 @@ from natsort import natsorted from tqdm import tqdm, trange -import PyQt5 -from PyQt5 import QtGui, QtCore, Qt, QtWidgets +from qtpy import QtGui, QtCore, QtWidgets from superqt import QRangeSlider from qtpy.QtCore import Qt as Qtp -from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QScrollBar, QSlider, QComboBox, QGridLayout, QPushButton, QFrame, QCheckBox, QLabel, QProgressBar, QLineEdit, QMessageBox, QGroupBox +from qtpy.QtWidgets import QMainWindow, QApplication, QWidget, QScrollBar, QSlider, QComboBox, QGridLayout, QPushButton, QFrame, QCheckBox, QLabel, QProgressBar, QLineEdit, QMessageBox, QGroupBox import pyqtgraph as pg from pyqtgraph import GraphicsScene diff --git a/cellpose/gui/guiparts.py b/cellpose/gui/guiparts.py index 8f2c3918..661eefc8 100644 --- a/cellpose/gui/guiparts.py +++ b/cellpose/gui/guiparts.py @@ -2,10 +2,9 @@ Copright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu. """ -import PyQt5 -from PyQt5 import QtGui, QtCore, QtWidgets -from PyQt5.QtGui import QPainter, QPixmap -from PyQt5.QtWidgets import QApplication, QRadioButton, QWidget, QDialog, QButtonGroup, QSlider, QStyle, QStyleOptionSlider, QGridLayout, QPushButton, QLabel, QLineEdit, QDialogButtonBox, QComboBox, QCheckBox +from qtpy import QtGui, QtCore, QtWidgets +from qtpy.QtGui import QPainter, QPixmap +from qtpy.QtWidgets import QApplication, QRadioButton, QWidget, QDialog, QButtonGroup, QSlider, QStyle, QStyleOptionSlider, QGridLayout, QPushButton, QLabel, QLineEdit, QDialogButtonBox, QComboBox, QCheckBox import pyqtgraph as pg from pyqtgraph import functions as fn from pyqtgraph import Point @@ -509,7 +508,7 @@ class ImageDraw(pg.ImageItem): for controlling the levels and lookup table used to display the image. """ - sigImageChanged = QtCore.pyqtSignal() + sigImageChanged = QtCore.Signal() def __init__(self, image=None, viewbox=None, parent=None, **kargs): super(ImageDraw, self).__init__() diff --git a/cellpose/gui/io.py b/cellpose/gui/io.py index 6703b1a9..7c949a56 100644 --- a/cellpose/gui/io.py +++ b/cellpose/gui/io.py @@ -15,8 +15,8 @@ from ..transforms import normalize99 try: - import PyQt5 - from PyQt5.QtWidgets import QFileDialog + import qtpy + from qtpy.QtWidgets import QFileDialog GUI = True except: GUI = False diff --git a/cellpose/io.py b/cellpose/io.py index f0d0b6ac..073877ef 100644 --- a/cellpose/io.py +++ b/cellpose/io.py @@ -15,8 +15,8 @@ try: - from PyQt5 import QtGui, QtCore, Qt, QtWidgets - from PyQt5.QtWidgets import QMessageBox + from qtpy import QtGui, QtCore, Qt, QtWidgets + from qtpy.QtWidgets import QMessageBox GUI = True except: GUI = False diff --git a/environment.yml b/environment.yml index 11a23a09..5413f04a 100644 --- a/environment.yml +++ b/environment.yml @@ -3,8 +3,8 @@ dependencies: - python==3.8.5 - pip - pip: - - PyQt5 - - PyQt5.sip + - qtpy +# - PyQt5.sip - numpy>=1.20.0 - numba>=0.43.1 - scipy From c46ca1237791e1e3a1dd434bb14a4615c7f060c7 Mon Sep 17 00:00:00 2001 From: Michael Rariden Date: Fri, 28 Jul 2023 11:51:40 -0400 Subject: [PATCH 2/3] switch PyQt5 to qtpy --- cellpose/gui/menus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cellpose/gui/menus.py b/cellpose/gui/menus.py index d0793d32..3d708bbb 100644 --- a/cellpose/gui/menus.py +++ b/cellpose/gui/menus.py @@ -2,8 +2,8 @@ Copright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu. """ -import PyQt5 -from PyQt5.QtWidgets import QAction +import qtpy +from qtpy.QtWidgets import QAction from . import io from .. import models from ..io import save_server From 17a57fc737cc1f8031277b1851ed831b95c0d168 Mon Sep 17 00:00:00 2001 From: Michael Rariden Date: Fri, 4 Aug 2023 16:05:58 -0400 Subject: [PATCH 3/3] update setup.py to check for existing available pyqt version --- setup.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 694c901c..131b6d26 100644 --- a/setup.py +++ b/setup.py @@ -14,8 +14,9 @@ gui_deps = [ 'pyqtgraph>=0.11.0rc0', - 'pyqt5', - 'pyqt5.sip', + "pyqt6", + "pyqt6.sip", + 'qtpy', 'superqt', 'google-cloud-storage' ] @@ -42,6 +43,29 @@ except: pass +try: + import PyQt5 + gui_deps.remove("pyqt6") + gui_deps.remove("pyqt6.sip") + gui_deps.append("pyqt5") + gui_deps.append("pyqt5.sip") +except: + pass + +try: + import PySide2 + gui_deps.remove("pyqt6") + gui_deps.remove("pyqt6.sip") +except: + pass + +try: + import PySide6 + gui_deps.remove("pyqt6") + gui_deps.remove("pyqt6.sip") +except: + pass + with open("README.md", "r") as fh: long_description = fh.read()