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 = 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, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: Key | QKeySequence | QtCore.QKeyCombination | StandardKey | str | int = None, tooltip: str = None, statusTip: str = 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.

addCalendarWidget(*args, cls=<class 'PyQt5.QtWidgets.QCalendarWidget'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Large, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addCheckBox(*args, cls=<class 'PyQt5.QtWidgets.QCheckBox'>, initializer: Callable = <built-in function setText>, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addComboBox(*args, cls=<class 'PyQt5.QtWidgets.QComboBox'>, initializer: Callable = <built-in function addItems>, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addDateEdit(*args, cls=<class 'PyQt5.QtWidgets.QDateEdit'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addDateTimeEdit(*args, cls=<class 'PyQt5.QtWidgets.QDateTimeEdit'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addDoubleSpinBox(*args, cls=<class 'PyQt5.QtWidgets.QDoubleSpinBox'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addFontComboBox(*args, cls=<class 'PyQt5.QtWidgets.QFontComboBox'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
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]
addLabel(*args, cls=<class 'PyQt5.QtWidgets.QLabel'>, initializer: Callable = <built-in function setText>, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addLargeButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: Key | QKeySequence | QtCore.QKeyCombination | StandardKey | str | int = 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: Key | QKeySequence | QtCore.QKeyCombination | StandardKey | str | int = 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 = RibbonSpaceFindMode.ColumnWise, alignment: AlignmentFlag = 132, fixedHeight: bool | float = False) QWidget | Any[source]
addLineEdit(*args, cls=<class 'PyQt5.QtWidgets.QLineEdit'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addListWidget(*args, cls=<class 'PyQt5.QtWidgets.QListWidget'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Large, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addMediumButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: Key | QKeySequence | QtCore.QKeyCombination | StandardKey | str | int = 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: Key | QKeySequence | QtCore.QKeyCombination | StandardKey | str | int = 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 = RibbonSpaceFindMode.ColumnWise, alignment: AlignmentFlag = 132, fixedHeight: bool | float = False) QWidget | Any[source]
addPlainTextEdit(*args, cls=<class 'PyQt5.QtWidgets.QPlainTextEdit'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addProgressBar(*args, cls=<class 'PyQt5.QtWidgets.QProgressBar'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[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.

addSlider(*args, cls=<class 'PyQt5.QtWidgets.QSlider'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addSmallButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: Key | QKeySequence | QtCore.QKeyCombination | StandardKey | str | int = 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: Key | QKeySequence | QtCore.QKeyCombination | StandardKey | str | int = 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 = RibbonSpaceFindMode.ColumnWise, alignment: AlignmentFlag = 132, fixedHeight: bool | float = False) QWidget | Any[source]
addSpinBox(*args, cls=<class 'PyQt5.QtWidgets.QSpinBox'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addTableWidget(*args, cls=<class 'PyQt5.QtWidgets.QTableWidget'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Large, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addTextEdit(*args, cls=<class 'PyQt5.QtWidgets.QTextEdit'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addTimeEdit(*args, cls=<class 'PyQt5.QtWidgets.QTimeEdit'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addToggleButton(text: str = None, icon: QIcon = None, showText: bool = True, slot: Callable = None, shortcut: Key | QKeySequence | QtCore.QKeyCombination | StandardKey | str | int = None, tooltip: str = None, statusTip: str = None, *, checkable: bool = True, rowSpan: RibbonButtonStyle = RibbonButtonStyle.Large, **kwargs) RibbonToolButton[source]
addTreeWidget(*args, cls=<class 'PyQt5.QtWidgets.QTreeWidget'>, initializer: Callable = None, rowSpan: Union[int, RibbonButtonStyle] = RibbonButtonStyle.Large, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: QtCore.Qt.AlignmentFlag = 132, fixedHeight: Union[bool, float] = False, **kwargs) QWidget[source]
addVerticalSeparator(*, orientation=2, width=6, **kwargs) RibbonSeparator[source]
addWidget(widget: QWidget, *, rowSpan: int | RibbonButtonStyle = RibbonButtonStyle.Small, colSpan: int = 1, mode: RibbonSpaceFindMode = RibbonSpaceFindMode.ColumnWise, alignment: AlignmentFlag = 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",
        "args": (),
        "kwargs": {  # or "arguments" for backward compatibility
            "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

removeWidget(widget: QWidget)[source]

Remove a widget from the panel.

rowHeight() int[source]

Return the height of a row.

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.

setTitle(title: str)[source]

Set the title of the panel.

Parameters:

title – The title to set.

setTitleHeight(height: int)[source]

Set the height of the title widget.

Parameters:

height – The height to set.

smallRows() int[source]

Return the number of span rows for small widgets.

Returns:

The number of span rows for small widgets.

title()[source]

Get the title of the panel.

Returns:

The title.

titleHeight() int[source]

Get the height of the title widget.

Returns:

The height of the title widget.

widget(index: int) QWidget[source]

Get the widget at the given index.

Parameters:

index – The index of the widget, starting from 0.

Returns:

The widget at the given index.

widgets() List[QWidget][source]

Get all the widgets in the panel.

Returns:

A list of all the widgets in the panel.

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.

addWidget(widget)[source]

Add a widget to the panel item.

Parameters:

widget – The widget to add.

class pyqtribbon.panel.RibbonPanelOptionButton[source]

Bases: QToolButton

Button to display the options of a panel.

class pyqtribbon.panel.RibbonPanelTitle[source]

Bases: QLabel

Widget to display the title of a panel.