pyqtribbon

Submodules

Package Contents

Classes

RibbonCategoryStyle

The button style of a category.

RibbonMenu

RibbonPermanentMenu

A permanent menu.

RibbonSpaceFindMode

Mode to find available space in a grid layout, ColumnWise or RowWise.

RibbonBar

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

RibbonStyle

Enum where members are also (and must be) ints

RibbonButtonStyle

Button style, Small, Medium, or Large.

Attributes

Normal

Context

ColumnWise

RowWise

Default

Debug

Small

Medium

Large

class pyqtribbon.RibbonCategoryStyle[source]

Bases: enum.IntEnum

The button style of a category.

Normal = 0[source]
Context = 1[source]
pyqtribbon.Normal[source]
pyqtribbon.Context[source]
class pyqtribbon.RibbonMenu(title: str = '', parent=None)           RibbonMenu(parent=None)[source]

Bases: qtpy.QtWidgets.QMenu

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

Add a widget to the menu.

Parameters:

widget – The widget to add.

addHorizontalLayoutWidget() qtpy.QtWidgets.QHBoxLayout[source]

Add a horizontal layout widget to the menu.

Returns:

The horizontal layout.

addVerticalLayoutWidget() qtpy.QtWidgets.QVBoxLayout[source]

Add a vertical layout widget to the menu.

Returns:

The vertical layout.

addGridLayoutWidget() qtpy.QtWidgets.QGridLayout[source]

Add a grid layout widget to the menu.

Returns:

The grid layout.

addFormLayoutWidget() qtpy.QtWidgets.QFormLayout[source]

Add a form layout widget to the menu.

Returns:

The form layout.

addSpacing(spacing: int = 5)[source]

Add spacing to the menu.

Parameters:

spacing – The spacing.

addLabel(text: str = '', alignment: qtpy.QtCore.Qt.Alignment = QtCore.Qt.AlignLeft)[source]

Add a label to the menu.

Parameters:
  • text – The text of the label.

  • alignment – The alignment of the label.

class pyqtribbon.RibbonPermanentMenu(title: str = '', parent=None)           RibbonPermanentMenu(parent=None)[source]

Bases: RibbonMenu

A permanent menu.

actionAdded[source]
hideEvent(a0: QHideEvent) None[source]
actionEvent(a0: QActionEvent) None[source]
class pyqtribbon.RibbonSpaceFindMode[source]

Bases: enum.IntEnum

Mode to find available space in a grid layout, ColumnWise or RowWise.

ColumnWise = 0[source]
RowWise = 1[source]
pyqtribbon.ColumnWise[source]
pyqtribbon.RowWise[source]
class pyqtribbon.RibbonBar(title: str = '', maxRows=6, parent=None)           RibbonBar(parent=None)[source]

Bases: qtpy.QtWidgets.QMenuBar

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

helpButtonClicked[source]
fileButtonClicked[source]
_categories: Dict[str, pyqtribbon.category.RibbonCategory][source]
_contextCategoryCount = 0[source]
_maxRows = 6[source]
_ribbonVisible = True[source]
_ribbonHeight = 200[source]
_currentTabIndex = 0[source]
abstract actionAt(QPoint)[source]
abstract actionGeometry(QAction)[source]
abstract activeAction()[source]
abstract addMenu(*__args)[source]
abstract addAction(*__args)[source]
abstract addSeparator()[source]
abstract clear()[source]
abstract cornerWidget(corner=None)[source]
abstract insertMenu(QAction, QMenu)[source]
abstract insertSeparator(QAction)[source]
abstract isDefaultUp()[source]
abstract isNativeMenuBar()[source]
abstract setActiveAction(QAction)[source]
abstract setCornerWidget(QWidget, corner=None)[source]
abstract setDefaultUp(up)[source]
abstract setNativeMenuBar(bar)[source]
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.

_collapseButtonClicked()[source]
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.

class pyqtribbon.RibbonStyle[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

Default = 0[source]
Debug = 1[source]
pyqtribbon.Default[source]
pyqtribbon.Debug[source]
class pyqtribbon.RibbonButtonStyle[source]

Bases: enum.IntEnum

Button style, Small, Medium, or Large.

Small = 0[source]
Medium = 1[source]
Large = 2[source]
pyqtribbon.Small[source]
pyqtribbon.Medium[source]
pyqtribbon.Large[source]