pyqtribbon.ribbonbar

Module Contents

Classes

RibbonStyle

Enum where members are also (and must be) ints

RibbonStackedWidget

Stacked widget that is used to display the ribbon.

RibbonBar

The RibbonBar class is the top level widget that contains the ribbon.

class pyqtribbon.ribbonbar.RibbonStyle[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

class pyqtribbon.ribbonbar.RibbonStackedWidget(parent=None)[source]

Bases: qtpy.QtWidgets.QStackedWidget

Stacked widget that is used to display the ribbon.

class pyqtribbon.ribbonbar.RibbonBar(title: str = 'Ribbon Bar Title', maxRows=6, parent=None)           RibbonBar(parent=None)[source]

Bases: qtpy.QtWidgets.QMenuBar

The RibbonBar class is the top level widget that contains the ribbon.

setRibbonStyle(style: RibbonStyle)[source]

Set the style of the ribbon.

Parameters:

style – The style to set.

applicationOptionButton() pyqtribbon.titlewidget.RibbonApplicationButton[source]

Return the application button.

setApplicationIcon(icon: qtpy.QtGui.QIcon)[source]

Set the application icon.

Parameters:

icon – The icon to set.

addTitleWidget(widget: qtpy.QtWidgets.QWidget)[source]

Add a widget to the title widget.

Parameters:

widget – The widget to add.

removeTitleWidget(widget: qtpy.QtWidgets.QWidget)[source]

Remove a widget from the title widget.

Parameters:

widget – The widget to remove.

insertTitleWidget(index: int, widget: qtpy.QtWidgets.QWidget)[source]

Insert a widget to the title widget.

Parameters:
  • index – The index to insert the widget.

  • widget – The widget to insert.

addFileMenu() pyqtribbon.menu.RibbonMenu[source]

Add a file menu to the ribbon.

ribbonHeight() int[source]

Get the total height of the ribbon.

Returns:

The height of the ribbon.

setRibbonHeight(height: int)[source]

Set the total height of the ribbon.

Parameters:

height – The height to set.

tabBar() pyqtribbon.tabbar.RibbonTabBar[source]

Return the tab bar of the ribbon.

Returns:

The tab bar of the ribbon.

quickAccessToolBar() qtpy.QtWidgets.QToolBar[source]

Return the quick access toolbar of the ribbon.

Returns:

The quick access toolbar of the ribbon.

addQuickAccessButton(button: qtpy.QtWidgets.QToolButton)[source]

Add a button to the quick access bar.

Parameters:

button – The button to add.

setQuickAccessButtonHeight(height: int = 30)[source]

Set the height of the quick access buttons.

Parameters:

height – The height to set.

title() str[source]

Return the title of the ribbon.

Returns:

The title of the ribbon.

setTitle(title: str)[source]

Set the title of the ribbon.

Parameters:

title – The title to set.

rightToolBar() qtpy.QtWidgets.QToolBar[source]

Return the right toolbar of the ribbon.

Returns:

The right toolbar of the ribbon.

addRightToolButton(button: qtpy.QtWidgets.QToolButton)[source]

Add a widget to the right button bar.

Parameters:

button – The button to add.

setRightToolBarHeight(height: int = 24)[source]

Set the height of the right buttons.

Parameters:

height – The height to set.

helpRibbonButton() qtpy.QtWidgets.QToolButton[source]

Return the help button of the ribbon.

Returns:

The help button of the ribbon.

setHelpButtonIcon(icon: qtpy.QtGui.QIcon)[source]

Set the icon of the help button.

Parameters:

icon – The icon to set.

removeHelpButton()[source]

Remove the help button from the ribbon.

collapseRibbonButton() qtpy.QtWidgets.QToolButton[source]

Return the collapse ribbon button.

Returns:

The collapse ribbon button.

setCollapseButtonIcon(icon: qtpy.QtGui.QIcon)[source]

Set the icon of the min button.

Parameters:

icon – The icon to set.

removeCollapseButton()[source]

Remove the min button from the ribbon.

category(name: str) pyqtribbon.category.RibbonCategory[source]

Return the category with the given name.

Parameters:

name – The name of the category.

Returns:

The category with the given name.

categories() Dict[str, pyqtribbon.category.RibbonCategory][source]

Return a list of categories of the ribbon.

Returns:

A dict of categories of the ribbon.

addCategoriesBy(data: Dict[str, Dict]) Dict[str, pyqtribbon.category.RibbonCategory][source]

Add categories from a dict.

Parameters:

data

The dict of categories. The dict is of the form:

{
    "category-title": {
        "style": RibbonCategoryStyle.Normal,
        "color": QtCore.Qt.red,
        "panels": {
            "panel-title": {
                "showPanelOptionButton": True,
                "widgets": {
                    "widget-name": {
                        "type": "Button",
                        "arguments": {
                            "key1": "value1",
                            "key2": "value2"
                        }
                    },
                }
            },
        },
    }
}

Returns:

A dict of categories of the ribbon.

addCategory(title: str, style=RibbonCategoryStyle.Normal, color: qtpy.QtGui.QColor = None) pyqtribbon.category.RibbonNormalCategory | pyqtribbon.category.RibbonContextCategory[source]

Add a new category to the ribbon.

Parameters:
  • title – The title of the category.

  • style – The button style of the category.

  • color – The color of the context category, only used if style is Context, if None, the default color will be used.

Returns:

The newly created category.

addNormalCategory(title: str) pyqtribbon.category.RibbonNormalCategory[source]

Add a new category to the ribbon.

Parameters:

title – The title of the category.

Returns:

The newly created category.

addContextCategory(title: str, color: qtpy.QtGui.QColor | qtpy.QtCore.Qt.GlobalColor = QtCore.Qt.blue) pyqtribbon.category.RibbonContextCategory[source]

Add a new context category to the ribbon.

Parameters:
  • title – The title of the category.

  • color – The color of the context category, if None, the default color will be used.

Returns:

The newly created category.

addContextCategories(name: str, titles: List[str], color: qtpy.QtGui.QColor | qtpy.QtCore.Qt.GlobalColor = QtCore.Qt.blue) pyqtribbon.category.RibbonContextCategories[source]

Add a group of context categories with the same tab color to the ribbon.

Parameters:
  • name – The name of the context categories.

  • titles – The title of the category.

  • color – The color of the context category, if None, the default color will be used.

Returns:

The newly created category.

showCategoryByIndex(index: int)[source]

Show category by tab index

Parameters:

index – tab index

showContextCategory(category: pyqtribbon.category.RibbonContextCategory | pyqtribbon.category.RibbonContextCategories)[source]

Show the given category or categories, if it is not a context category, nothing happens.

Parameters:

category – The category to show.

hideContextCategory(category: pyqtribbon.category.RibbonContextCategory | pyqtribbon.category.RibbonContextCategories)[source]

Hide the given category or categories, if it is not a context category, nothing happens.

Parameters:

category – The category to hide.

categoryVisible(category: pyqtribbon.category.RibbonCategory) bool[source]

Return whether the category is shown.

Parameters:

category – The category to check.

Returns:

Whether the category is shown.

removeCategory(category: pyqtribbon.category.RibbonCategory)[source]

Remove a category from the ribbon.

Parameters:

category – The category to remove.

removeCategories(categories: pyqtribbon.category.RibbonContextCategories)[source]

Remove a list of categories from the ribbon.

Parameters:

categories – The categories to remove.

setCurrentCategory(category: pyqtribbon.category.RibbonCategory)[source]

Set the current category.

Parameters:

category – The category to set.

currentCategory() pyqtribbon.category.RibbonCategory[source]

Return the current category.

Returns:

The current category.

minimumSizeHint() qtpy.QtCore.QSize[source]

Return the minimum size hint of the widget.

Returns:

The minimum size hint.

showRibbon()[source]

Show the ribbon.

hideRibbon()[source]

Hide the ribbon.

ribbonVisible() bool[source]

Get the visibility of the ribbon.

Returns:

True if the ribbon is visible, False otherwise.

setRibbonVisible(visible: bool)[source]

Set the visibility of the ribbon.

Parameters:

visible – True to show the ribbon, False to hide it.