pyqtribbon.category module

class pyqtribbon.category.RibbonCategory(title: str = '', style: RibbonCategoryStyle = RibbonCategoryStyle.Normal, color: QColor = None, parent=None)[source]
class pyqtribbon.category.RibbonCategory(parent=None)

Bases: RibbonCategoryLayoutWidget

The RibbonCategory is the logical grouping that represents the contents of a ribbon tab.

Create a new category.

Parameters:
  • title – The title of the category.

  • style – The button style of the category.

  • color – The color of the context category.

  • parent – The parent widget.

addPanel(title: str, showPanelOptionButton=True) RibbonPanel[source]

Add a new panel to the category.

Parameters:
  • title – The title of the panel.

  • showPanelOptionButton – Whether to show the panel option button.

Returns:

The newly created panel.

addPanelsBy(data: Dict[str, Dict]) Dict[str, RibbonPanel][source]

Add panels from a dictionary.

Parameters:

data

The dictionary. The keys are the titles of the panels. The value is a dictionary of arguments. the argument showPanelOptionButton is a boolean to decide whether to show the panel option button, the rest arguments are passed to the RibbonPanel.addWidgetsBy() method. The dict is of the form:

{
    "panel-title": {
        "showPanelOptionButton": True,
        "widgets": {
            "widget-name": {
                "type": "Button",
                "args": (),
                "kwargs": {  # or "arguments" for backward compatibility
                    "key1": "value1",
                    "key2": "value2"
                }
            },
        }
    },
}

Returns:

A dictionary of the newly created panels.

categoryStyle() RibbonCategoryStyle[source]

Return the button style of the category.

Returns:

The button style.

panel(title: str) RibbonPanel[source]

Return a panel from the category.

Parameters:

title – The title of the panel.

Returns:

The panel.

panels() Dict[str, RibbonPanel][source]

Return all panels in the category.

Returns:

The panels.

removePanel(title: str)[source]

Remove a panel from the category.

Parameters:

title – The title of the panel.

setCategoryStyle(style: RibbonCategoryStyle)[source]

Set the button style of the category.

Parameters:

style – The button style.

setMaximumRows(rows: int)[source]

Set the maximum number of rows.

Parameters:

rows – The maximum number of rows.

takePanel(title: str) RibbonPanel[source]

Remove and return a panel from the category.

Parameters:

title – The title of the panel.

Returns:

The removed panel.

title() str[source]

Return the title of the category.

class pyqtribbon.category.RibbonCategoryLayoutButton[source]

Bases: QToolButton

Previous/Next buttons in the category when the size is not enough for the widgets.

class pyqtribbon.category.RibbonCategoryLayoutWidget(parent=None)[source]

Bases: QFrame

The category layout widget’s category scroll area to arrange the widgets in the category.

Create a new category layout widget.

Parameters:

parent – The parent widget.

addWidget(widget: QWidget)[source]

Add a widget to the category layout.

Parameters:

widget – The widget to add.

autoSetScrollButtonsVisible()[source]

Set the visibility of the scroll buttons.

displayOptionsButtonClicked[source]

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

paintEvent(a0: QPaintEvent) None[source]

Override the paint event to draw the background.

removeWidget(widget: QWidget)[source]

Remove a widget from the category layout.

Parameters:

widget – The widget to remove.

resizeEvent(a0: QResizeEvent) None[source]

Override the resize event to resize the scroll area.

scrollNext()[source]

Scroll the category to the next widget.

scrollPrevious()[source]

Scroll the category to the previous widget.

takeWidget(widget: QWidget) QWidget[source]

Remove and return a widget from the category layout.

Parameters:

widget – The widget to remove.

Returns:

The widget that was removed.

class pyqtribbon.category.RibbonCategoryScrollArea[source]

Bases: QScrollArea

Scroll area for the gallery

class pyqtribbon.category.RibbonCategoryScrollAreaContents[source]

Bases: QFrame

Scroll area contents for the gallery

class pyqtribbon.category.RibbonContextCategories(name: str, color: QColor, categories: Dict[str, RibbonContextCategory], ribbon)[source]

Bases: Dict[str, RibbonContextCategory]

A list of context categories.

categoriesVisible() bool[source]

Return whether the categories are shown.

color() QColor[source]

Return the color of the context categories.

hideContextCategories()[source]

Hide the categories

name() str[source]

Return the name of the context categories.

setCategoriesVisible(visible: bool)[source]

Set the state of the categories.

setColor(color: QColor)[source]

Set the color of the context categories.

setName(name: str)[source]

Set the name of the context categories.

showContextCategories()[source]

Show the categories

class pyqtribbon.category.RibbonContextCategory(title: str, color: QColor, parent: QWidget)[source]

Bases: RibbonCategory

A context category.

Create a new context category.

Parameters:
  • title – The title of the category.

  • color – The color of the context category.

  • parent – The parent widget.

categoryVisible() bool[source]

Return whether the category is shown.

Returns:

Whether the category is shown.

color() QColor[source]

Return the color of the context category.

Returns:

The color of the context category.

hideContextCategory()[source]

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

setCategoryStyle(style: RibbonCategoryStyle)[source]

Set the button style of the category.

Parameters:

style – The button style.

setCategoryVisible(visible: bool)[source]

Set the state of the category.

Parameters:

visible – The state.

setColor(color: QColor)[source]

Set the color of the context category.

Parameters:

color – The color of the context category.

showContextCategory()[source]

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

class pyqtribbon.category.RibbonNormalCategory(title: str, parent: QWidget)[source]

Bases: RibbonCategory

A normal category.

Create a new normal category.

Parameters:
  • title – The title of the category.

  • parent – The parent widget.

setCategoryStyle(style: RibbonCategoryStyle)[source]

Set the button style of the category.

Parameters:

style – The button style.