From c243f508311271c6309b5c0c4d0f899668e36b6d Mon Sep 17 00:00:00 2001 From: Hailin Wang <2011133@tongji.edu.cn> Date: Sat, 23 Jul 2022 14:02:55 +0800 Subject: [PATCH] Rename CategoryStyle to RibbonCategoryStyle --- ribbon/__init__.py | 2 +- ribbon/category.py | 16 ++++++++-------- ribbon/ribbonbar.py | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ribbon/__init__.py b/ribbon/__init__.py index b9049353..6b06a9ae 100644 --- a/ribbon/__init__.py +++ b/ribbon/__init__.py @@ -1,4 +1,4 @@ -from .category import RibbonCategory, CategoryStyle, RibbonNormalCategory, RibbonContextCategory +from .category import RibbonCategory, RibbonCategoryStyle, RibbonNormalCategory, RibbonContextCategory from .categorylayoutwidget import (RibbonCategoryLayoutWidget, RibbonCategoryLayoutButton, RibbonCategoryScrollArea, RibbonCategoryScrollAreaContents) from .gallery import RibbonGallery, RibbonGalleryListWidget, RibbonGalleryButton, RibbonGalleryPopupListWidget diff --git a/ribbon/category.py b/ribbon/category.py index 904e2946..db0d8ef2 100644 --- a/ribbon/category.py +++ b/ribbon/category.py @@ -9,7 +9,7 @@ from .typehints import RibbonType -class CategoryStyle(enum.IntEnum): +class RibbonCategoryStyle(enum.IntEnum): """The button style of a category.""" Normal = 0 Context = 1 @@ -33,7 +33,7 @@ class RibbonCategory(QtWidgets.QFrame): #: The ribbon parent of this category _ribbon: typing.Optional[RibbonType] #: The button style of the category. - _style: CategoryStyle + _style: RibbonCategoryStyle #: Panels _panels: typing.Dict[str, RibbonPanel] #: color of the context category @@ -42,7 +42,7 @@ class RibbonCategory(QtWidgets.QFrame): #: The signal that is emitted when the display options button is clicked. displayOptionsButtonClicked = QtCore.pyqtSignal(bool) - def __init__(self, title: str, style: CategoryStyle = CategoryStyle.Normal, color: QtGui.QColor = None, + def __init__(self, title: str, style: RibbonCategoryStyle = RibbonCategoryStyle.Normal, color: QtGui.QColor = None, parent=None): """Create a new category. @@ -68,7 +68,7 @@ def title(self) -> str: """Return the title of the category.""" return self._title - def setCategoryStyle(self, style: CategoryStyle): + def setCategoryStyle(self, style: RibbonCategoryStyle): """Set the button style of the category. :param style: The button style. @@ -136,9 +136,9 @@ def __init__(self, title: str, parent: QtWidgets.QWidget): :param title: The title of the category. :param parent: The parent widget. """ - super().__init__(title, CategoryStyle.Normal, parent=parent) + super().__init__(title, RibbonCategoryStyle.Normal, parent=parent) - def setCategoryStyle(self, style: CategoryStyle): + def setCategoryStyle(self, style: RibbonCategoryStyle): """Set the button style of the category. :param style: The button style. @@ -156,9 +156,9 @@ def __init__(self, title: str, color: QtGui.QColor, parent: QtWidgets.QWidget): :param color: The color of the context category. :param parent: The parent widget. """ - super().__init__(title, CategoryStyle.Context, color=color, parent=parent) + super().__init__(title, RibbonCategoryStyle.Context, color=color, parent=parent) - def setCategoryStyle(self, style: CategoryStyle): + def setCategoryStyle(self, style: RibbonCategoryStyle): """Set the button style of the category. :param style: The button style. diff --git a/ribbon/ribbonbar.py b/ribbon/ribbonbar.py index 8a85106d..a46bac45 100644 --- a/ribbon/ribbonbar.py +++ b/ribbon/ribbonbar.py @@ -3,7 +3,7 @@ from PyQt5 import QtWidgets, QtCore, QtGui -from .category import RibbonCategory, RibbonContextCategory, RibbonNormalCategory, CategoryStyle, contextColors +from .category import RibbonCategory, RibbonContextCategory, RibbonNormalCategory, RibbonCategoryStyle, contextColors from .separator import RibbonHorizontalSeparator from .titlewidget import RibbonTitleWidget from .utils import data_file_path @@ -210,7 +210,7 @@ def categories(self) -> typing.List[RibbonCategory]: def addCategory( self, title: str, - style=CategoryStyle.Normal, + style=RibbonCategoryStyle.Normal, color: QtGui.QColor = None, ) -> typing.Union[RibbonNormalCategory, RibbonContextCategory]: """Add a new category to the ribbon. @@ -221,11 +221,11 @@ def addCategory( will be used. :return: The newly created category. """ - if style == CategoryStyle.Context: + if style == RibbonCategoryStyle.Context: if color is None: color = contextColors[self._contextCategoryCount % len(contextColors)] self._contextCategoryCount += 1 - category = (RibbonContextCategory(title, color, self) if style == CategoryStyle.Context else + category = (RibbonContextCategory(title, color, self) if style == RibbonCategoryStyle.Context else RibbonNormalCategory(title, self)) category.setFixedHeight(self._ribbonHeight - self._mainLayout.spacing() * 2 - @@ -233,11 +233,11 @@ def addCategory( self._mainLayout.contentsMargins().bottom() - self._titleWidget.height() - self._separator.height() - 4) # 4: extra space for drawing lines when debugging - if style == CategoryStyle.Normal: + if style == RibbonCategoryStyle.Normal: self._categories.append(category) self._titleWidget.tabBar().addTab(title, color) self._stackedWidget.addWidget(category) - elif style == CategoryStyle.Context: + elif style == RibbonCategoryStyle.Context: category.hide() return category @@ -247,7 +247,7 @@ def addNormalCategory(self, title: str) -> RibbonNormalCategory: :param title: The title of the category. :return: The newly created category. """ - return self.addCategory(title, CategoryStyle.Normal) + return self.addCategory(title, RibbonCategoryStyle.Normal) def addContextCategory(self, title: str, color: QtGui.QColor = None) -> RibbonContextCategory: """Add a new context category to the ribbon. @@ -256,7 +256,7 @@ def addContextCategory(self, title: str, color: QtGui.QColor = None) -> RibbonCo :param color: The color of the context category, if None, the default color will be used. :return: The newly created category. """ - return self.addCategory(title, CategoryStyle.Context, color) + return self.addCategory(title, RibbonCategoryStyle.Context, color) def showContextCategory(self, category: RibbonContextCategory): """Show the given category, if it is not a context category, nothing happens.