Skip to content

Commit

Permalink
Use qtpy to be compatiable with different Qt versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hailin-Wang committed Jul 24, 2022
1 parent 3cb0efb commit 0d45931
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
numpy
numpydoc
PyQt5
qtpy
sphinx-rtd-theme
sphinx-toolbox
sphinx-qt-documentation
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

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

from ribbon import RibbonMainWindow

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
numpy
PyQt5
qtpy
2 changes: 1 addition & 1 deletion ribbon/category.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import enum
import typing

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

from .categorylayoutwidget import RibbonCategoryLayoutWidget
from .panel import RibbonPanel
Expand Down
4 changes: 2 additions & 2 deletions ribbon/categorylayoutwidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5 import QtWidgets, QtCore, QtGui
from qtpy import QtWidgets, QtCore, QtGui

from ribbon.utils import data_file_path

Expand All @@ -22,7 +22,7 @@ class RibbonCategoryScrollAreaContents(QtWidgets.QFrame):

class RibbonCategoryLayoutWidget(QtWidgets.QFrame):
"""The category layout widget's category scroll area to arrange the widgets in the category."""
displayOptionsButtonClicked = QtCore.pyqtSignal()
displayOptionsButtonClicked = QtCore.Signal()

def __init__(self, parent=None):
"""Create a new category layout widget.
Expand Down
2 changes: 1 addition & 1 deletion ribbon/gallery.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typing

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

from .toolbutton import RibbonToolButton
from .utils import data_file_path
Expand Down
2 changes: 1 addition & 1 deletion ribbon/mainwindow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5 import QtWidgets
from qtpy import QtWidgets

from .ribbonbar import RibbonBar

Expand Down
4 changes: 2 additions & 2 deletions ribbon/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from enum import IntEnum

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

from .gallery import RibbonGallery
from .separator import RibbonHorizontalSeparator, RibbonVerticalSeparator
Expand Down Expand Up @@ -113,7 +113,7 @@ class RibbonPanel(QtWidgets.QFrame):
_titleHeight: int = 20

# Panel options signal
panelOptionClicked = QtCore.pyqtSignal(bool)
panelOptionClicked = QtCore.Signal(bool)

@typing.overload
def __init__(self, title: str = '', maxRows: int = 6, parent=None):
Expand Down
6 changes: 3 additions & 3 deletions ribbon/ribbonbar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import typing
from enum import IntEnum

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

from .category import RibbonCategory, RibbonContextCategory, RibbonNormalCategory, RibbonCategoryStyle, contextColors
from .separator import RibbonHorizontalSeparator
Expand All @@ -17,8 +17,8 @@ class RibbonStyle(IntEnum):
class RibbonBar(QtWidgets.QFrame):
"""The RibbonBar class is the top level widget that contains the ribbon.
"""
#: Signal, The help button was clicked.
helpButtonClicked = QtCore.pyqtSignal(bool)
#: Signal, the help button was clicked.
helpButtonClicked = QtCore.Signal(bool)

#: The categories of the ribbon.
_categories: typing.List[RibbonCategory] = []
Expand Down
2 changes: 1 addition & 1 deletion ribbon/separator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typing

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


class RibbonSeparator(QtWidgets.QFrame):
Expand Down
2 changes: 1 addition & 1 deletion ribbon/tabbar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5 import QtWidgets, QtGui, QtCore
from qtpy import QtWidgets, QtGui, QtCore


class RibbonTabBar(QtWidgets.QTabBar):
Expand Down
9 changes: 5 additions & 4 deletions ribbon/titlewidget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typing

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

from .tabbar import RibbonTabBar
from .utils import data_file_path
Expand All @@ -18,9 +18,10 @@ class RibbonTitleLabel(QtWidgets.QLabel):

class RibbonTitleWidget(QtWidgets.QFrame):
"""The title widget of the ribbon."""
#: Signal: The help button was clicked.
helpButtonClicked = QtCore.pyqtSignal(bool)
collapseRibbonButtonClicked = QtCore.pyqtSignal(bool)
#: Signal, the help button was clicked.
helpButtonClicked = QtCore.Signal(bool)
#: Signal, the collapse button wa clicked.
collapseRibbonButtonClicked = QtCore.Signal(bool)

#: Buttons
_quickAccessButtons = []
Expand Down
2 changes: 1 addition & 1 deletion ribbon/toolbutton.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import typing
from enum import IntEnum

from PyQt5 import QtWidgets, QtCore
from qtpy import QtWidgets, QtCore


class RibbonButtonStyle(IntEnum):
Expand Down
2 changes: 1 addition & 1 deletion ribbon/typehints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typing

from PyQt5 import QtCore, QtWidgets
from qtpy import QtCore, QtWidgets


class PyQtSignalType:
Expand Down

0 comments on commit 0d45931

Please sign in to comment.