pyqtribbon.ribbonbar module
- class pyqtribbon.ribbonbar.RibbonBar(title: str = 'Ribbon Bar Title', maxRows=6, parent=None)[source]
- class pyqtribbon.ribbonbar.RibbonBar(parent=None)
Bases:
QMenuBarThe RibbonBar class is the top level widget that contains the ribbon.
Create a new ribbon.
- Parameters:
title – The title of the ribbon.
maxRows – The maximum number of rows.
parent – The parent widget of the ribbon.
- addAction(self, action: QAction | None)[source]
- addAction(self, text: str | None) QAction | None
- addAction(self, text: str | None, slot: PYQT_SLOT) QAction | None
- addCategoriesBy(data: Dict[str, Dict]) Dict[str, 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", "args": (), "kwargs": { # or "arguments" for backward compatibility "key1": "value1", "key2": "value2" } }, } }, }, } }
- Returns:
A dict of categories of the ribbon.
- addCategory(title: str, style=RibbonCategoryStyle.Normal, color: QColor | None = None) RibbonNormalCategory | 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.
- addContextCategories(name: str, titles: List[str], color: QColor | GlobalColor = 9) 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.
- addContextCategory(title: str, color: QColor | GlobalColor = 9) 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.
- addFileMenu() RibbonMenu[source]
Add a file menu to the ribbon.
- addMenu(self, menu: QMenu | None) QAction | None[source]
- addMenu(self, title: str | None) QMenu | None
- addMenu(self, icon: QIcon, title: str | None) QMenu | None
- addNormalCategory(title: str) RibbonNormalCategory[source]
Add a new category to the ribbon.
- Parameters:
title – The title of the category.
- Returns:
The newly created category.
- addQuickAccessButton(button: QToolButton)[source]
Add a button to the quick access bar.
- Parameters:
button – The button to add.
- addRightToolButton(button: QToolButton)[source]
Add a widget to the right button bar.
- Parameters:
button – The button to add.
- addTitleWidget(widget: QWidget)[source]
Add a widget to the title widget.
- Parameters:
widget – The widget to add.
- applicationOptionButton() RibbonApplicationButton[source]
Return the application button.
- autoHideRibbon() bool[source]
Return whether the ribbon bar is automatically hidden when the mouse is pressed outside the ribbon bar.
- Returns:
Whether the ribbon bar is automatically hidden.
- categories() Dict[str, RibbonCategory][source]
Return a list of categories of the ribbon.
- Returns:
A dict of categories of the ribbon.
- category(name: str) RibbonCategory[source]
Return the category with the given name.
- Parameters:
name – The name of the category.
- Returns:
The category with the given name.
- categoryVisible(category: RibbonCategory) bool[source]
Return whether the category is shown.
- Parameters:
category – The category to check.
- Returns:
Whether the category is shown.
- collapseRibbonButton() QToolButton[source]
Return the collapse ribbon button.
- Returns:
The collapse ribbon button.
- currentCategory() RibbonCategory[source]
Return the current category.
- Returns:
The current category.
- helpRibbonButton() QToolButton[source]
Return the help button of the ribbon.
- Returns:
The help button of the ribbon.
- hideContextCategory(category: RibbonContextCategory | RibbonContextCategories)[source]
Hide the given category or categories, if it is not a context category, nothing happens.
- Parameters:
category – The category to hide.
- insertTitleWidget(index: int, widget: QWidget)[source]
Insert a widget to the title widget.
- Parameters:
index – The index to insert the widget.
widget – The widget to insert.
- minimumSizeHint() QSize[source]
Return the minimum size hint of the widget.
- Returns:
The minimum size hint.
- quickAccessToolBar() QToolBar[source]
Return the quick access toolbar of the ribbon.
- Returns:
The quick access toolbar of the ribbon.
- removeCategories(categories: RibbonContextCategories)[source]
Remove a list of categories from the ribbon.
- Parameters:
categories – The categories to remove.
- removeCategory(category: RibbonCategory)[source]
Remove a category from the ribbon.
- Parameters:
category – The category to remove.
- removeTitleWidget(widget: QWidget)[source]
Remove a widget from the title widget.
- Parameters:
widget – The widget to remove.
- ribbonVisible() bool[source]
Get the visibility of the ribbon.
- Returns:
True if the ribbon is visible, False otherwise.
- rightToolBar() QToolBar[source]
Return the right toolbar of the ribbon.
- Returns:
The right toolbar of the ribbon.
- setApplicationIcon(icon: QIcon)[source]
Set the application icon.
- Parameters:
icon – The icon to set.
- setAutoHideRibbon(autoHide: bool)[source]
Set whether the ribbon bar is automatically hidden when the mouse is pressed outside the ribbon bar.
- Parameters:
autoHide – Whether the ribbon bar is automatically hidden.
- setCollapseButtonIcon(icon: QIcon)[source]
Set the icon of the min button.
- Parameters:
icon – The icon to set.
- setCurrentCategory(category: RibbonCategory)[source]
Set the current category.
- Parameters:
category – The category to set.
- setHelpButtonIcon(icon: QIcon)[source]
Set the icon of the help button.
- Parameters:
icon – The icon to set.
- setQuickAccessButtonHeight(height: int)[source]
Set the height of the quick access buttons.
- Parameters:
height – The height to set.
- setRibbonHeight(height: int)[source]
Set the total height of the ribbon.
- Parameters:
height – The height to set.
- setRibbonStyle(style: RibbonStyle)[source]
Set the style of the ribbon.
- Parameters:
style – The style to set.
- setRibbonVisible(visible: bool)[source]
Set the visibility of the ribbon.
- Parameters:
visible – True to show the ribbon, False to hide it.
- setRightToolBarHeight(height: int)[source]
Set the height of the right buttons.
- Parameters:
height – The height to set.
- setTitleWidgetHeight(height: int)[source]
Set the height of the title widget.
- Parameters:
height – The height to set.
- showContextCategory(category: RibbonContextCategory | RibbonContextCategories)[source]
Show the given category or categories, if it is not a context category, nothing happens.
- Parameters:
category – The category to show.
- tabBar() RibbonTabBar[source]
Return the tab bar of the ribbon.
- Returns:
The tab bar of the ribbon.
- class pyqtribbon.ribbonbar.RibbonStackedWidget(parent=None)[source]
Bases:
QStackedWidgetStacked widget that is used to display the ribbon.
Create a new ribbon stacked widget.
- Parameters:
parent – The parent widget.