pyqtribbon.panel

Module Contents

Classes

RibbonPanelTitle

Widget to display the title of a panel.

RibbonSpaceFindMode

Mode to find available space in a grid layout, ColumnWise or RowWise.

RibbonGridLayoutManager

Grid Layout Manager.

RibbonPanelItemWidget

Widget to display a panel item.

RibbonPanelOptionButton

Button to display the options of a panel.

RibbonPanel

Panel in the ribbon category.

class pyqtribbon.panel.RibbonPanelTitle[source]

Bases: qtpy.QtWidgets.QLabel

Widget to display the title of a panel.

class pyqtribbon.panel.RibbonSpaceFindMode[source]

Bases: enum.IntEnum

Mode to find available space in a grid layout, ColumnWise or RowWise.

class pyqtribbon.panel.RibbonGridLayoutManager(rows: int)[source]

Bases: object

Grid Layout Manager.

request_cells(rowSpan: int = 1, colSpan: int = 1, mode=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.RibbonPanelItemWidget(parent=None)[source]

Bases: qtpy.QtWidgets.QFrame

Widget to display a panel item.

addWidget(widget)[source]

Add a widget to the panel item.

Parameters:

widget – The widget to add.

class pyqtribbon.panel.RibbonPanelOptionButton[source]

Bases: qtpy.QtWidgets.QToolButton

Button to display the options of a panel.

class pyqtribbon.panel.RibbonPanel(title: str = '', maxRows: int = 6, showPanelOptionButton=True, parent=None)           RibbonPanel(parent=None)[source]

Bases: qtpy.QtWidgets.QFrame

Panel in the ribbon category.

maximumRows() int[source]

Return the maximal number of rows in the panel.

Returns:

The maximal number of rows in the panel.

largeRows() int[source]

Return the number of span rows for large widgets.

Returns:

The number of span rows for large widgets.

mediumRows() int[source]

Return the number of span rows for medium widgets.

Returns:

The number of span rows for medium widgets.

smallRows() int[source]

Return the number of span rows for small widgets.

Returns:

The number of span rows for small widgets.

setMaximumRows(maxRows: int)[source]

Set the maximal number of rows in the panel.

Parameters:

maxRows – The maximal number of rows in the panel.

setLargeRows(rows: int)[source]

Set the number of span rows for large widgets.

Parameters:

rows – The number of span rows for large widgets.

setMediumRows(rows: int)[source]

Set the number of span rows for medium widgets.

Parameters:

rows – The number of span rows for medium widgets.

setSmallRows(rows: int)[source]

Set the number of span rows for small widgets.

Parameters:

rows – The number of span rows for small widgets.

defaultRowSpan(rowSpan: int | pyqtribbon.toolbutton.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.

panelOptionButton() RibbonPanelOptionButton[source]

Return the panel option button.

Returns:

The panel option button.

setPanelOptionToolTip(text: str)[source]

Set the tooltip of the panel option button.

Parameters:

text – The tooltip text.

rowHeight() int[source]

Return the height of a row.

addWidgetsBy(data: Dict[str, Dict]) Dict[str, qtpy.QtWidgets.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.

addWidget(widget: qtpy.QtWidgets.QWidget, *, rowSpan: int | pyqtribbon.toolbutton.RibbonButtonStyle = Small, colSpan: int = 1, mode=ColumnWise, alignment=QtCore.Qt.AlignCenter, 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.

removeWidget(widget: qtpy.QtWidgets.QWidget)[source]

Remove a widget from the panel.

widget(index: int) qtpy.QtWidgets.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[qtpy.QtWidgets.QWidget][source]

Get all the widgets in the panel.

Returns:

A list of all the widgets in the panel.

addButton(text: str = None, icon: qtpy.QtGui.QIcon = None, showText: bool = True, slot: Callable = None, shortcut: qtpy.QtGui.QKeySequence = None, tooltip: str = None, statusTip: str = None, checkable: bool = False, *, rowSpan: pyqtribbon.toolbutton.RibbonButtonStyle = Large, **kwargs) pyqtribbon.toolbutton.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.

addAnyWidget(*args, cls, initializer: Callable = None, **kwargs) qtpy.QtWidgets.QWidget[source]

Add any widget to the panel.

Parameters:
  • args – The arguments to pass to the initializer.

  • cls – The class of the widget to add.

  • initializer – The initializer of the widget to add, the first argument must be the widget.

  • kwargs – The keyword arguments to pass to the initializer and to control the properties of the widget on the ribbon bar.

__getattr__(method: str) Callable[source]

Get the dynamic method add[Small|Medium|Large][Widget].

Parameters:

method – The name of the method to get.

Returns:

The method of the widget to add.

addSeparator(orientation=QtCore.Qt.Vertical, width=6, **kwargs) pyqtribbon.separator.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.

addGallery(minimumWidth=800, popupHideOnClick=False, **kwargs) pyqtribbon.gallery.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.

setTitle(title: str)[source]

Set the title of the panel.

Parameters:

title – The title to set.

title()[source]

Get the title of the panel.

Returns:

The title.