Welcome to PyQtRibbon’s documentation!
Ribbon Bar for PyQt or PySide applications.
GitHub Repository: github.com/haiiliin/pyqtribbon.
PyPI: pypi.org/project/pyqtribbon.
Documentation: pyqribbon.readthedocs.io/en/stable.
Read the Docs: readthedocs.org/projects/pyqtribbon.
Getting Started
Installation
PyQtRibbon is distribued to PyPI, you can use pip to install it:
pip install pyqtribbon
You can also install the package from source:
pip install git+https://github.com/haiiliin/pyqtribbon.git@main
The Ribbon Bar
Introduction
The ribbon is first introduced by Microsoft in the 2000’s. It is a toolbar with a tabbed interface. According to Microsoft:
Note
A ribbon is a user interface (UI) element that organizes commands into logical groups. These groups appear on separate tabs in a strip across the top of the window. The ribbon replaces the menu bar and toolbars. A ribbon can significantly improve application usability. For more information, see Ribbons. The following illustration shows a ribbon. A ribbon can significantly improve application usability. For more information, see Ribbons. The following illustration shows a ribbon.

Definitions of Ribbon Elements

Application button: The button that appears on the upper-left corner of a ribbon. The Application button replaces the File menu and is visible even when the ribbon is minimized. When the button is clicked, a menu that has a list of commands is displayed.
Quick Access toolbar: A small, customizable toolbar that displays frequently used commands.
Category: The logical grouping that represents the contents of a ribbon tab.
Category Default button: The button that appears on the ribbon when the ribbon is minimized. When the button is clicked, the category reappears as a menu.
Panel: An area of the ribbon bar that displays a group of related controls. Every ribbon category contains one or more ribbon panels.
Ribbon elements: Controls in the panels, for example, buttons and combo boxes. To see the various controls that can be hosted on a ribbon, see RibbonGadgets Sample: Ribbon Gadgets Application.
Ribbon Elements in PyQtRibbon

User Manual
The RibbonScreenShotWindow Class
The RibbonScreenShotWindow
class is just for taking a screenshot of the window,
the window will be closed 0.1s after it is shown. It is just used for documenting the window.
- class pyqtribbon.screenshotwindow.RibbonScreenShotWindow(fileName: str = 'shot.jpg', *args, **kwargs)[source]
This class is just for taking a screenshot of the window, the window will be closed 0.1s after it is shown.
Initialize the class.
- Parameters:
fileName – The file name for the screenshot.
- setScreenShotFileName(fileName: str)[source]
Set the file name for the screenshot.
- Parameters:
fileName – The file name for the screenshot.
- takeScreenShot()[source]
Take a screenshot of the window.
Instantiate a Ribbon Bar
RibbonBar
is inherited from QMenuBar
,
you can use the setMenuBar method of QMainWindow
to set the ribbon bar as the main menu bar.
from pyqtribbon import RibbonBar
window = QtWidgets.QMainWindow()
ribbon = RibbonBar()
window.setMenuBar(ribbon)
Example
For example, using the following code,
import sys
from qtpy import QtGui, QtWidgets
from pyqtribbon import RibbonBar
from pyqtribbon.screenshotwindow import RibbonScreenShotWindow
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
app.setFont(QtGui.QFont("Times New Roman", 8))
window = RibbonScreenShotWindow("ribbonbar.png")
# Ribbon bar
ribbonbar = RibbonBar()
window.setMenuBar(ribbonbar)
# Show the window
window.resize(1000, 250)
window.show()
sys.exit(app.exec_())
You can get a window like this:

Customize Ribbon Bar
General Setups
|
Set the style of the ribbon. |
Get the total height of the ribbon. |
|
|
Set the total height of the ribbon. |
Show the ribbon. |
|
Hide the ribbon. |
|
Get the visibility of the ribbon. |
|
|
Set the visibility of the ribbon. |
Setup Title
Return the title of the ribbon. |
|
|
Set the title of the ribbon. |
|
Add a widget to the title widget. |
|
Insert a widget to the title widget. |
|
Remove a widget from the title widget. |
Setup Category Tab Bar
Return the tab bar of the ribbon. |
Setup Quick Access Bar
Return the quick access toolbar of the ribbon. |
|
|
Add a button to the quick access bar. |
|
Set the height of the quick access buttons. |
Setup Right Tool Bar
Return the right toolbar of the ribbon. |
|
|
Add a widget to the right button bar. |
|
Set the height of the right buttons. |
Set the icon of the help button. |
|
Remove the help button from the ribbon. |
|
Signal, the help button was clicked. |
|
Return the collapse ribbon button. |
|
Set the icon of the min button. |
|
Remove the min button from the ribbon. |
Example
For example, using the following code,
import sys
from qtpy import QtGui
from qtpy.QtWidgets import QApplication, QToolButton
from pyqtribbon import RibbonBar
from pyqtribbon.screenshotwindow import RibbonScreenShotWindow
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setFont(QtGui.QFont("Times New Roman", 8))
window = RibbonScreenShotWindow("ribbonbar-customize.png")
# Ribbon bar
ribbonbar = RibbonBar()
window.setMenuBar(ribbonbar)
# Title of the ribbon
ribbonbar.setTitle("This is my custom title")
# Quick Access Bar
qbutton = QToolButton()
qbutton.setText("Quick Button")
ribbonbar.addQuickAccessButton(qbutton)
# Right toolbar
rbutton = QToolButton()
rbutton.setText("Right Button")
ribbonbar.addRightToolButton(rbutton)
# Show the window
window.resize(1000, 250)
window.show()
sys.exit(app.exec_())
You can get a window like this:

Manage Categories
Return a list of categories of the ribbon. |
|
|
Add a new category to the ribbon. |
Add categories from a dict. |
|
|
Add a new category to the ribbon. |
|
Add a new context category to the ribbon. |
|
Add a group of context categories with the same tab color to the ribbon. |
|
Show the given category or categories, if it is not a context category, nothing happens. |
|
Hide the given category or categories, if it is not a context category, nothing happens. |
|
Remove a category from the ribbon. |
|
Set the current category. |
Return the current category. |
|
Show category by tab index |
Customize Categories
Setup Styles
Return the button style of the category. |
|
Set the button style of the category. |
Manage Panels
|
Add a new panel to the category. |
Add panels from a dictionary. |
|
|
Remove a panel from the category. |
|
Remove and return a panel from the category. |
|
Return a panel from the category. |
Return all panels in the category. |
Example
For example, using the following code,
import sys
from qtpy import QtGui
from qtpy.QtGui import QIcon
from qtpy.QtWidgets import QApplication
from pyqtribbon import RibbonBar, RibbonCategoryStyle
from pyqtribbon.screenshotwindow import RibbonScreenShotWindow
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setFont(QtGui.QFont("Times New Roman", 8))
window = RibbonScreenShotWindow("category.png")
# Ribbon bar
ribbonbar = RibbonBar()
window.setMenuBar(ribbonbar)
# Categories
category1 = ribbonbar.addCategory("Category 1")
panel1 = category1.addPanel("Panel 1")
panel1.addLargeButton("Large Button 1", QIcon("python.png"))
category2 = ribbonbar.addContextCategory("Category 2")
panel12 = category2.addPanel("Panel 2")
panel12.addLargeButton("Large Button 2", QIcon("python.png"))
categories = ribbonbar.addCategoriesBy(
{
"Category 6": {
"style": RibbonCategoryStyle.Normal,
"panels": {
"Panel 1": {
"showPanelOptionButton": True,
"widgets": {
"Button 1": {
"type": "Button",
"arguments": {
"icon": QIcon("python.png"),
"text": "Button",
"tooltip": "This is a tooltip",
},
},
},
},
},
}
}
)
ribbonbar.setCurrentCategory(categories["Category 6"])
# Show the window
window.resize(1000, 250)
window.show()
sys.exit(app.exec_())
You can get a window like this:

Customize Panels
Setup Title Label
Get the title of the panel. |
|
|
Set the title of the panel. |
Add Widgets to Panels
Example
For example, using the following code,
import sys
from qtpy import QtGui
from qtpy.QtCore import Qt
from qtpy.QtGui import QIcon
from qtpy.QtWidgets import QApplication, QLabel, QLineEdit, QMenu, QToolButton
from pyqtribbon import RibbonBar
from pyqtribbon.screenshotwindow import RibbonScreenShotWindow
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setFont(QtGui.QFont("Times New Roman", 8))
window = RibbonScreenShotWindow("panel.png")
# Ribbon bar
ribbonbar = RibbonBar()
window.setMenuBar(ribbonbar)
category1 = ribbonbar.addCategory("Category 1")
panel = category1.addPanel("Panel 1", showPanelOptionButton=False)
panel.addSmallButton("Button 1", icon=QIcon("python.png"))
panel.addSmallButton("Button 2", icon=QIcon("python.png"))
panel.addSmallButton("Button 3", icon=QIcon("python.png"))
panel.addMediumToggleButton("Show/Hide Category 2", icon=QIcon("python.png"))
panel.addVerticalSeparator()
panel.addMediumToggleButton("Show/Hide Category 3", icon=QIcon("python.png"))
panel.addMediumToggleButton("Show/Hide Category 4/5", icon=QIcon("python.png"), colSpan=2, alignment=Qt.AlignLeft)
panel.addLargeButton("Button 4", icon=QIcon("python.png"))
panel.addVerticalSeparator()
panel.addMediumButton("Button 5", icon=QIcon("python.png"))
panel.addMediumButton("Button 6", icon=QIcon("python.png"))
button = panel.addLargeButton("Button 7", icon=QIcon("python.png"))
menu = QMenu()
menu.addAction(QIcon("python.png"), "Action 1")
menu.addAction(QIcon("python.png"), "Action 2")
menu.addAction(QIcon("python.png"), "Action 3")
button.setMenu(menu)
button.setPopupMode(QToolButton.InstantPopup)
panel.addWidget(button, rowSpan=6)
gallery = panel.addGallery(minimumWidth=500, popupHideOnClick=True)
for i in range(100):
gallery.addToggleButton(f"item {i+1}", QIcon("python.png"))
popupMenu = gallery.popupMenu()
submenu = popupMenu.addMenu(QIcon("python.png"), "Submenu")
submenu.addAction(QIcon("python.png"), "Action 4")
popupMenu.addAction(QIcon("python.png"), "Action 1")
popupMenu.addAction(QIcon("python.png"), "Action 2")
popupMenu.addSeparator()
popupMenu.addWidget(QLabel("This is a custom widget"))
formLayout = popupMenu.addFormLayoutWidget()
formLayout.addRow(QLabel("Row 1"), QLineEdit())
# Show the window
window.resize(1300, 250)
window.show()
sys.exit(app.exec_())
You can get a window like this:

A Complete Example
The following code snippet is a complete example.
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont, QIcon
from PyQt5.QtWidgets import QApplication, QLabel, QVBoxLayout, QWidget
from pyqtribbon import RibbonBar
from pyqtribbon.screenshotwindow import RibbonScreenShotWindow
from pyqtribbon.utils import DataFile
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setFont(QFont("Times New Roman", 8))
# Central widget
window = RibbonScreenShotWindow("tutorial-ribbonbar.png")
window.setWindowIcon(QIcon(DataFile("icons/python.png")))
centralWidget = QWidget()
window.setCentralWidget(centralWidget)
layout = QVBoxLayout(centralWidget)
# Ribbon bar
ribbonbar = RibbonBar()
window.setMenuBar(ribbonbar)
category = ribbonbar.addCategory("Category 1")
panel = category.addPanel("Panel 1")
panel.addLargeButton("A Large Button", QIcon(DataFile("icons/python.png")))
panel.addMediumButton("A Medium Button", QIcon(DataFile("icons/python.png")))
panel.addMediumButton("A Medium Button", QIcon(DataFile("icons/python.png")))
panel.addSmallButton("A Small Button", QIcon(DataFile("icons/python.png")))
panel.addSmallButton("A Small Button", QIcon(DataFile("icons/python.png")))
panel.addSmallButton("A Small Button", QIcon(DataFile("icons/python.png")))
# Display a label in the main window
label = QLabel("Ribbon Test Window")
label.setFont(QFont("Arial", 20))
label.setAlignment(Qt.AlignCenter)
# Add the ribbon bar and label to the layout
layout.addWidget(label, 1)
# Show the window
window.resize(1800, 350) # type: ignore
window.show()
sys.exit(app.exec_())
You can get a window like this:

API References
pyqtribbon package
Submodules
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", "arguments": { "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.
- 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.
- 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.
- 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.
- 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.
- 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.
pyqtribbon.constants module
- class pyqtribbon.constants.RibbonButtonStyle(value)[source]
Bases:
IntEnum
Button style, Small, Medium, or Large.
- class pyqtribbon.constants.RibbonCategoryStyle(value)[source]
Bases:
IntEnum
The button style of a category.
- class pyqtribbon.constants.RibbonSpaceFindMode(value)[source]
Bases:
IntEnum
Mode to find available space in a grid layout, ColumnWise or RowWise.
pyqtribbon.gallery module
- class pyqtribbon.gallery.RibbonGallery(minimumWidth=800, popupHideOnClick=False, parent=None)[source]
- class pyqtribbon.gallery.RibbonGallery(parent=None)
Bases:
QFrame
A widget that displays a gallery of buttons.
Create a gallery.
- Parameters:
minimumWidth – minimum width of the gallery
popupHideOnClick – hide on click flag
parent – parent widget
- addButton(text: str | None = None, icon: QIcon | None = None, slot=None, shortcut=None, tooltip=None, statusTip=None, checkable=False) RibbonToolButton [source]
Add a button to the gallery
- Parameters:
text – text of the button
icon – icon of the button
slot – slot to call when the button is clicked
shortcut – shortcut of the button
tooltip – tooltip of the button
statusTip – status tip of the button
checkable – checkable flag of the button.
- Returns:
the button added
- addToggleButton(text: str | None = None, icon: QIcon | None = None, slot=None, shortcut=None, tooltip=None, statusTip=None) RibbonToolButton [source]
Add a toggle button to the gallery
- Parameters:
text – text of the button
icon – icon of the button
slot – slot to call when the button is clicked
shortcut – shortcut of the button
tooltip – tooltip of the button
statusTip – status tip of the button.
- Returns:
the button added
- popupMenu() RibbonPermanentMenu [source]
Return the popup menu.
- resizeEvent(a0: QResizeEvent) None [source]
Resize the gallery.
- setPopupHideOnClick(popupHideOnClick: bool)[source]
Set the hide on click flag
- Parameters:
popupHideOnClick – hide on click flag
- class pyqtribbon.gallery.RibbonGalleryButton[source]
Bases:
QToolButton
Gallery button.
- class pyqtribbon.gallery.RibbonGalleryListWidget(parent=None)[source]
Bases:
QListWidget
Gallery list widget.
- resizeEvent(e: QResizeEvent) None [source]
Resize the list widget.
- class pyqtribbon.gallery.RibbonGalleryPopupListWidget(parent=None)[source]
Bases:
RibbonGalleryListWidget
Gallery popup list widget.
pyqtribbon.logger module
https://timlehr.com/python-exception-hooks-with-qt-message-box/
pyqtribbon.panel module
- class pyqtribbon.panel.RibbonGridLayoutManager(rows: int)[source]
Bases:
object
Grid Layout Manager.
Create a new grid layout manager.
- Parameters:
rows – The number of rows in the grid layout.
- request_cells(rowSpan: int = 1, colSpan: int = 1, mode=RibbonSpaceFindMode.ColumnWise)[source]
Request a number of available cells from the grid.
- Parameters:
rowSpan – The number of rows the cell should span.
colSpan – The number of columns the cell should span.
mode – The mode of the grid.
- Returns:
row, col, the row and column of the requested cell.
- class pyqtribbon.panel.RibbonPanel(title: str = '', maxRows: int = 6, showPanelOptionButton=True, parent=None)[source]
- class pyqtribbon.panel.RibbonPanel(parent=None)
Bases:
QFrame
Panel in the ribbon category.
Create a new panel.
- Parameters:
title – The title of the panel.
maxRows – The maximal number of rows in the panel.
showPanelOptionButton – Whether to show the panel option button.
parent – The parent widget.
- addButton(text: str | None = None, icon: QIcon | None = None, showText: bool = True, slot: Callable | None = None, shortcut: QKeySequence | None = None, tooltip: str | None = None, statusTip: str | None = None, checkable: bool = False, *, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Large, **kwargs) RibbonToolButton [source]
Add a button to the panel.
- Parameters:
text – The text of the button.
icon – The icon of the button.
showText – Whether to show the text of the button.
slot – The slot to call when the button is clicked.
shortcut – The shortcut of the button.
tooltip – The tooltip of the button.
statusTip – The status tip of the button.
checkable – Whether the button is checkable.
rowSpan – The type of the button corresponding to the number of rows it should span.
kwargs – keyword arguments to control the properties of the widget on the ribbon bar.
- Returns:
The button that was added.
- addGallery(minimumWidth=800, popupHideOnClick=False, **kwargs) RibbonGallery [source]
Add a gallery to the panel.
- Parameters:
minimumWidth – The minimum width of the gallery.
popupHideOnClick – Whether the gallery popup should be hidden when a user clicks on it.
kwargs – keyword arguments to control the properties of the widget on the ribbon bar.
- Returns:
The gallery.
- addHorizontalSeparator(*, orientation=1, width=6, **kwargs) RibbonSeparator [source]
- addLargeButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: QKeySequence = None, tooltip: str = None, statusTip: str = None, checkable: bool = False, *, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Large, **kwargs) RibbonToolButton [source]
- addLargeToggleButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: QKeySequence = None, tooltip: str = None, statusTip: str = None, *, checkable: bool = True, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Large, **kwargs) RibbonToolButton [source]
- addLargeWidget(widget: QWidget, *, rowSpan: int | RibbonButtonStyle = RibbonButtonStyle.Large, colSpan: int = 1, mode=RibbonSpaceFindMode.ColumnWise, alignment=132, fixedHeight: bool | float = False) QWidget | Any [source]
- addMediumButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: QKeySequence = None, tooltip: str = None, statusTip: str = None, checkable: bool = False, *, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Medium, **kwargs) RibbonToolButton [source]
- addMediumToggleButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: QKeySequence = None, tooltip: str = None, statusTip: str = None, *, checkable: bool = True, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Medium, **kwargs) RibbonToolButton [source]
- addMediumWidget(widget: QWidget, *, rowSpan: int | RibbonButtonStyle = RibbonButtonStyle.Medium, colSpan: int = 1, mode=RibbonSpaceFindMode.ColumnWise, alignment=132, fixedHeight: bool | float = False) QWidget | Any [source]
- addSeparator(orientation=2, width=6, **kwargs) RibbonSeparator [source]
Add a separator to the panel.
- Parameters:
orientation – The orientation of the separator.
width – The width of the separator.
kwargs – keyword arguments to control the properties of the widget on the ribbon bar.
- Returns:
The separator.
- addSmallButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: QKeySequence = None, tooltip: str = None, statusTip: str = None, checkable: bool = False, *, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Small, **kwargs) RibbonToolButton [source]
- addSmallToggleButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: QKeySequence = None, tooltip: str = None, statusTip: str = None, *, checkable: bool = True, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Small, **kwargs) RibbonToolButton [source]
- addSmallWidget(widget: QWidget, *, rowSpan: int | RibbonButtonStyle = RibbonButtonStyle.Small, colSpan: int = 1, mode=RibbonSpaceFindMode.ColumnWise, alignment=132, fixedHeight: bool | float = False) QWidget | Any [source]
- addToggleButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: QKeySequence = None, tooltip: str = None, statusTip: str = None, *, checkable: bool = True, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Large, **kwargs) RibbonToolButton [source]
- addVerticalSeparator(*, orientation=2, width=6, **kwargs) RibbonSeparator [source]
- addWidget(widget: QWidget, *, rowSpan: int | RibbonButtonStyle = RibbonButtonStyle.Small, colSpan: int = 1, mode=RibbonSpaceFindMode.ColumnWise, alignment=132, fixedHeight: bool | float = False) QWidget | Any [source]
Add a widget to the panel.
- Parameters:
widget – The widget to add.
rowSpan – The number of rows the widget should span, 2: small, 3: medium, 6: large.
colSpan – The number of columns the widget should span.
mode – The mode to find spaces.
alignment – The alignment of the widget.
fixedHeight – Whether to fix the height of the widget, it can be a boolean, a percentage or a fixed height, when a boolean is given, the height is fixed to the maximum height allowed if the value is True, when a percentage is given (0 < percentage < 1) the height is calculated from the height of the maximum height allowed, depends on the number of rows to span. The minimum height is 40% of the maximum height allowed.
- Returns:
The added widget.
- addWidgetsBy(data: Dict[str, Dict]) Dict[str, QWidget] [source]
Add widgets to the panel.
- Parameters:
data –
The data to add. The dict is of the form:
{ "widget-name": { "type": "Button", "arguments": { "key1": "value1", "key2": "value2" } }, }
Possible types are: Button, SmallButton, MediumButton, LargeButton, ToggleButton, SmallToggleButton, MediumToggleButton, LargeToggleButton, ComboBox, FontComboBox, LineEdit, TextEdit, PlainTextEdit, Label, ProgressBar, SpinBox, DoubleSpinBox, DataEdit, TimeEdit, DateTimeEdit, TableWidget, TreeWidget, ListWidget, CalendarWidget, Separator, HorizontalSeparator, VerticalSeparator, Gallery.
- Returns:
A dictionary of the added widgets.
- defaultRowSpan(rowSpan: int | RibbonButtonStyle) int [source]
Return the number of span rows for the given widget type.
- Parameters:
rowSpan – row span or type.
- Returns:
The number of span rows for the given widget type.
- largeRows() int [source]
Return the number of span rows for large widgets.
- Returns:
The number of span rows for large widgets.
- maximumRows() int [source]
Return the maximal number of rows in the panel.
- Returns:
The maximal number of rows in the panel.
- mediumRows() int [source]
Return the number of span rows for medium widgets.
- Returns:
The number of span rows for medium widgets.
- panelOptionButton() RibbonPanelOptionButton [source]
Return the panel option button.
- Returns:
The panel option button.
- panelOptionClicked(bool)[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
- setLargeRows(rows: int)[source]
Set the number of span rows for large widgets.
- Parameters:
rows – The number of span rows for large widgets.
- setMaximumRows(maxRows: int)[source]
Set the maximal number of rows in the panel.
- Parameters:
maxRows – The maximal number of rows in the panel.
- setMediumRows(rows: int)[source]
Set the number of span rows for medium widgets.
- Parameters:
rows – The number of span rows for medium widgets.
- setPanelOptionToolTip(text: str)[source]
Set the tooltip of the panel option button.
- Parameters:
text – The tooltip text.
- setSmallRows(rows: int)[source]
Set the number of span rows for small widgets.
- Parameters:
rows – The number of span rows for small widgets.
- smallRows() int [source]
Return the number of span rows for small widgets.
- Returns:
The number of span rows for small widgets.
- class pyqtribbon.panel.RibbonPanelItemWidget(parent=None)[source]
Bases:
QFrame
Widget to display a panel item.
Create a new panel item.
- Parameters:
parent – The parent widget.
- class pyqtribbon.panel.RibbonPanelOptionButton[source]
Bases:
QToolButton
Button to display the options of a panel.
pyqtribbon.ribbonbar module
- class pyqtribbon.ribbonbar.RibbonBar(title: str = 'Ribbon Bar Title', maxRows=6, parent=None)[source]
- class pyqtribbon.ribbonbar.RibbonBar(parent=None)
Bases:
QMenuBar
The 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", "arguments": { "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.
- 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 = 30)[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 = 24)[source]
Set the height of the right buttons.
- 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:
QStackedWidget
Stacked widget that is used to display the ribbon.
Create a new ribbon stacked widget.
- Parameters:
parent – The parent widget.
pyqtribbon.screenshotwindow module
- class pyqtribbon.screenshotwindow.RibbonScreenShotWindow(fileName: str = 'shot.jpg', *args, **kwargs)[source]
Bases:
QMainWindow
This class is just for taking a screenshot of the window, the window will be closed 0.1s after it is shown.
Initialize the class.
- Parameters:
fileName – The file name for the screenshot.
pyqtribbon.separator module
- class pyqtribbon.separator.RibbonHorizontalSeparator(width: int = 6, parent=None)[source]
Bases:
RibbonSeparator
Horizontal separator.
Create a new horizontal separator.
- Parameters:
width – The width of the separator.
parent – The parent widget.
- class pyqtribbon.separator.RibbonSeparator(orientation=QtCore.Qt.Vertical, width=6, parent=None)[source]
- class pyqtribbon.separator.RibbonSeparator(parent=None)
Bases:
QFrame
The RibbonSeparator is a separator that can be used to separate widgets in a ribbon.
Create a new separator.
- Parameters:
orientation – The orientation of the separator.
width – The width of the separator.
parent – The parent widget.
- paintEvent(event: QPaintEvent) None [source]
Paint the separator.
- class pyqtribbon.separator.RibbonVerticalSeparator(width: int = 6, parent=None)[source]
Bases:
RibbonSeparator
Vertical separator.
Create a new vertical separator.
- Parameters:
width – The width of the separator.
parent – The parent widget.
pyqtribbon.tabbar module
- class pyqtribbon.tabbar.RibbonTabBar(parent=None)[source]
Bases:
QTabBar
The TabBar for the title widget.
Create a new tab bar.
- Parameters:
parent – The parent widget.
- addAssociatedTabs(name: str, texts: List[str], color: QColor) List[int] [source]
Add associated multiple tabs which have the same color to the tab bar.
- Parameters:
name – The name of the context category.
texts – The texts of the tabs.
color – The color of the tabs.
- Returns:
The indices of the tabs.
- addTab(text: str, color: QColor | None = None, *args, **kwargs) int [source]
Add a new tab to the tab bar.
- Parameters:
text – The text of the tab.
color – The color of the tab.
- Returns:
The index of the tab.
- indexOf(tabName: str) int [source]
Return the index of the tab with the given name.
- Parameters:
tabName – The name of the tab.
- Returns:
The index of the tab.
pyqtribbon.titlewidget module
- class pyqtribbon.titlewidget.RibbonApplicationButton[source]
Bases:
QToolButton
Application button in the ribbon bar.
- addFileMenu() RibbonMenu [source]
Add a new ribbon menu to the application button.
- Returns:
The new ribbon menu.
- class pyqtribbon.titlewidget.RibbonTitleWidget(title='PyQtRibbon', parent=None)[source]
- class pyqtribbon.titlewidget.RibbonTitleWidget(parent=None)
Bases:
QFrame
The title widget of the ribbon.
Initialize the ribbon title widget.
- Parameters:
title – The title of the ribbon.
parent – The parent widget.
- addQuickAccessButton(button: QToolButton)[source]
Add a widget 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 layout.
- Parameters:
widget – The widget to add.
- applicationButton() RibbonApplicationButton [source]
Return the application button.
- collapseRibbonButton() QToolButton [source]
Return the collapse ribbon button.
- Returns:
The collapse ribbon button.
- helpRibbonButton() QToolButton [source]
Return the help ribbon button.
- Returns:
The help ribbon button.
- insertTitleWidget(index: int, widget: QWidget)[source]
Insert a widget to the title layout.
- Parameters:
index – The index to insert the widget.
widget – The widget to insert.
- mouseDoubleClickEvent(self, a0: QMouseEvent | None)[source]
- mouseMoveEvent(self, a0: QMouseEvent | None)[source]
- mousePressEvent(self, a0: QMouseEvent | None)[source]
- quickAccessButtons() List[QToolButton] [source]
Return the quick access buttons of the ribbon.
- Returns:
The quick access buttons of the ribbon.
- quickAccessToolBar() QToolBar [source]
Return the quick access toolbar of the ribbon.
- Returns:
The quick access toolbar of the ribbon.
- removeTitleWidget(widget: QWidget)[source]
Remove a widget from the title layout.
- Parameters:
widget – The widget to remove.
- 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.
- setCollapseButtonIcon(icon: QIcon)[source]
Set the icon of the min button.
- Parameters:
icon – The icon to set.
- setHelpButtonIcon(icon: QIcon)[source]
Set the icon of the help button.
- Parameters:
icon – The icon to set.
- setQuickAccessButtonHeight(height: int = 30)[source]
Set the height of the quick access buttons.
- Parameters:
height – The height to set.
- setRightToolBarHeight(height: int = 24)[source]
Set the height of the right buttons.
- Parameters:
height – The height to set.
- tabBar() RibbonTabBar [source]
Return the tab bar of the ribbon.
- Returns:
The tab bar of the ribbon.