User Manual

Instantiating 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 ribbon import RibbonBar

window = QtWidgets.QMainWindow()
ribbon = RibbonBar()
window.setMenuBar(ribbon)
...

Customize Ribbon Bar

General Setups

RibbonBar.setRibbonStyle(style)

Set the style of the ribbon.

RibbonBar.ribbonHeight()

Get the total height of the ribbon.

RibbonBar.setRibbonHeight(height)

Set the total height of the ribbon.

RibbonBar.showRibbon()

Show the ribbon.

RibbonBar.hideRibbon()

Hide the ribbon.

RibbonBar.ribbonVisible()

Get the visibility of the ribbon.

RibbonBar.setRibbonVisible(visible)

Set the visibility of the ribbon.

Setup Application Button

RibbonBar.applicationOptionButton()

Return the application button.

RibbonBar.setApplicationIcon(icon)

Set the application icon.

RibbonBar.addApplicationOptionAction(action)

Add a display option to the ribbon.

Setup Title

RibbonBar.title()

Return the title of the ribbon.

RibbonBar.setTitle(title)

Set the title of the ribbon.

Setup Category Tab Bar

RibbonBar.tabBar()

Return the tab bar of the ribbon.

RibbonBar.tabBarHeight()

Get the height of the tab bar.

RibbonBar.setTabBarHeight([height])

Set the height of the tab bar.

Setup Quick Access Bar

RibbonBar.quickAccessToolBar()

Return the quick access toolbar of the ribbon.

RibbonBar.addQuickAccessButton(button)

Add a button to the quick access bar.

RibbonBar.setQuickAccessButtonHeight([height])

Set the height of the quick access buttons.

Setup Right Tool Bar

RibbonBar.rightToolBar()

Return the right toolbar of the ribbon.

RibbonBar.addRightToolButton(button)

Add a widget to the right button bar.

RibbonBar.setRightToolBarHeight([height])

Set the height of the right buttons.

RibbonBar.setHelpButtonIcon(icon)

Set the icon of the help button.

RibbonBar.removeHelpButton()

Remove the help button from the ribbon.

RibbonBar.helpButtonClicked(bool)

Signal, the help button was clicked.

RibbonBar.collapseRibbonButton()

Return the collapse ribbon button.

RibbonBar.setCollapseButtonIcon(icon)

Set the icon of the min button.

RibbonBar.removeCollapseButton()

Remove the min button from the ribbon.

Manage Categories

RibbonBar.categories()

Return a list of categories of the ribbon.

RibbonBar.addCategory(title[, style, color])

Add a new category to the ribbon.

RibbonBar.addNormalCategory(title)

Add a new category to the ribbon.

RibbonBar.addContextCategory(title[, color])

Add a new context category to the ribbon.

RibbonBar.showContextCategory(category)

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

RibbonBar.hideContextCategory(category)

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

RibbonBar.removeCategory(category)

Remove a category from the ribbon.

RibbonBar.setCurrentCategory(category)

Set the current category.

Customize Categories

Setup Styles

RibbonCategory.categoryStyle()

Return the button style of the category.

RibbonCategory.setCategoryStyle(style)

Set the button style of the category.

Manage Panels

RibbonCategory.addPanel(title)

Add a new panel to the category.

RibbonCategory.removePanel(title)

Remove a panel from the category.

RibbonCategory.takePanel(title)

Remove and return a panel from the category.

RibbonCategory.panel(title)

Return a panel from the category.

RibbonCategory.panels()

Return all panels in the category.

Customize Panels

Setup Title Label

RibbonPanel.title()

Get the title of the panel.

RibbonPanel.setTitle(title)

Set the title of the panel.

Setup Panel Option Button

RibbonPanel.panelOptionButton()

Return the panel option button.

RibbonPanel.setPanelOptionToolTip(text)

Set the tooltip of the panel option button.

RibbonPanel.panelOptionClicked(bool)

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

Add Widgets to Panels

RibbonPanel.addWidget(widget[, rowSpan, ...])

Add a widget to the panel.

RibbonPanel.removeWidget(widget)

Remove a widget from the panel.

RibbonPanel.widget(index)

Get the widget at the given index.

RibbonPanel.addSmallWidget(widget[, mode, ...])

Add a small widget to the panel.

RibbonPanel.addMediumWidget(widget[, mode, ...])

Add a medium widget to the panel.

RibbonPanel.addLargeWidget(widget[, mode, ...])

Add a large widget to the panel.

RibbonPanel.addButton([text, icon, style, ...])

Add a button to the panel.

RibbonPanel.addSmallButton([text, icon, ...])

Add a small button to the panel.

RibbonPanel.addMediumButton([text, icon, ...])

Add a medium button to the panel.

RibbonPanel.addLargeButton([text, icon, ...])

Add a large button to the panel.

RibbonPanel.addToggleButton([text, icon, ...])

Add a toggle button to the panel.

RibbonPanel.addSmallToggleButton([text, ...])

Add a small toggle button to the panel.

RibbonPanel.addMediumToggleButton([text, ...])

Add a medium toggle button to the panel.

RibbonPanel.addLargeToggleButton([text, ...])

Add a large toggle button to the panel.

RibbonPanel.addComboBox(items[, rowSpan, ...])

Add a combo box to the panel.

RibbonPanel.addFontComboBox([rowSpan, ...])

Add a font combo box to the panel.

RibbonPanel.addLineEdit([rowSpan, colSpan, ...])

Add a line edit to the panel.

RibbonPanel.addTextEdit([rowSpan, colSpan, ...])

Add a text edit to the panel.

RibbonPanel.addPlainTextEdit([rowSpan, ...])

Add a plain text edit to the panel.

RibbonPanel.addLabel(text[, rowSpan, ...])

Add a label to the panel.

RibbonPanel.addProgressBar([rowSpan, ...])

Add a progress bar to the panel.

RibbonPanel.addSlider([rowSpan, colSpan, ...])

Add a slider to the panel.

RibbonPanel.addSpinBox([rowSpan, colSpan, ...])

Add a spin box to the panel.

RibbonPanel.addDoubleSpinBox([rowSpan, ...])

Add a double spin box to the panel.

RibbonPanel.addDateEdit([rowSpan, colSpan, ...])

Add a date edit to the panel.

RibbonPanel.addTimeEdit([rowSpan, colSpan, ...])

Add a time edit to the panel.

RibbonPanel.addDateTimeEdit([rowSpan, ...])

Add a date time edit to the panel.

RibbonPanel.addTableWidget([rowSpan, ...])

Add a table widget to the panel.

RibbonPanel.addTreeWidget([rowSpan, ...])

Add a tree widget to the panel.

RibbonPanel.addListWidget([rowSpan, ...])

Add a list widget to the panel.

RibbonPanel.addCalendarWidget([rowSpan, ...])

Add a calendar widget to the panel.

RibbonPanel.addSeparator([orientation, ...])

Add a separator to the panel.

RibbonPanel.addHorizontalSeparator([width, ...])

Add a horizontal separator to the panel.

RibbonPanel.addVerticalSeparator([width, ...])

Add a vertical separator to the panel.

RibbonPanel.addGallery([minimumWidth, ...])

Add a gallery to the panel.

A Complete Example

The following code snippet is a complete example.

import sys

from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QWidget, QVBoxLayout
from PyQt5.QtGui import QIcon, QFont
from PyQt5.QtCore import Qt

from ribbon import RibbonBar
from ribbon.utils import data_file_path

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setFont(QFont("Times New Roman", 8))
    
    # Central widget
    window = QMainWindow()
    window.setWindowIcon(QIcon(data_file_path("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(data_file_path("icons/python.png")))
    panel.addMediumButton("A Medium Button", QIcon(data_file_path("icons/python.png")))
    panel.addMediumButton("A Medium Button", QIcon(data_file_path("icons/python.png")))
    panel.addSmallButton("A Small Button", QIcon(data_file_path("icons/python.png")))
    panel.addSmallButton("A Small Button", QIcon(data_file_path("icons/python.png")))
    panel.addSmallButton("A Small Button", QIcon(data_file_path("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)
    window.show()
    sys.exit(app.exec_())

It would be rendered as follows:

_images/example.png