8.5.8.11. pymodaq_gui.utils.styling module

pymodaq_gui.utils.styling.create_color(icon_color)[source]
Return type:

Optional[QColor]

pymodaq_gui.utils.styling.create_font(font_name=None, font_size=None, isbold=False, isitalic=False)[source]
Return type:

QFont

pymodaq_gui.utils.styling.create_icon(icon_name, icon_color=None, icon_checked_color=None, flip_h=False, flip_v=False)[source]

Create an icon from various sources by order of preference:

  1. icon_name is a MaterialIcon

  2. icon_name is a regular QIcon

  3. icon_name is a registered MaterialIcon

  4. icon_name is a real path to a png

  5. icon_name is a registered png in icon_library

  6. icon_name is a registered ThemeIcon

  7. icon_name is a registered StandardPixmap

Parameters:
  • icon_name (Union[QIcon, str, Path]) – Icon source — see priority list above.

  • icon_color (Union[QColor, bytes, str]) – Colour applied to the unchecked/off-state icon (MaterialIcon only).

  • icon_checked_color (Union[QColor, bytes, str]) – Colour applied to the checked/on-state icon (MaterialIcon only).

  • flip_h (bool) – Mirror the icon horizontally (left ↔ right).

  • flip_v (bool) – Mirror the icon vertically (top ↔ bottom).

pymodaq_gui.utils.styling.make_shape_icon(shape='circle', filled=True, size=12, width=None, height=None, pen=None, brush=None, **kwargs)[source]

Return a small solid or outlined shape as a QIcon, using pyqtgraph’s mkPen/mkBrush.

Parameters:
  • shape (str) – Shape of the icon: ‘circle’, ‘triangle’, ‘square’, ‘rectangle’, or ‘diamond’.

  • filled (bool) – If True, the shape is filled; if False, only the outline is drawn.

  • size (int) – Diameter of the circle, side length of the square/diamond, or default side for triangle/rectangle in pixels (default 12).

  • width (int) – Width of the rectangle (if shape is ‘rectangle’). If None, defaults to size.

  • height (int) – Height of the rectangle (if shape is ‘rectangle’). If None, defaults to size.

  • pen (QPen) – QPen for the outline (e.g., pg.mkPen(‘blue’, width=2)).

  • brush (QBrush) – QBrush for filling the shape (e.g., pg.mkBrush(‘red’)).

  • **kwargs – Optional arguments for creating pen/brush if not provided: - color: str (default: ‘black’) - pen_width: int (default: 1) - pen_style: str (e.g., ‘solid’, ‘dashed’, ‘dotted’, ‘dashdot’, ‘dashdotdot’) - brush_color: str (default: same as color)

Return type:

QIcon

pymodaq_gui.utils.styling.resource_path_exists(path)[source]
Return type:

bool

pymodaq_gui.utils.styling.transform_icon(icon, transform)[source]

Return a new QIcon with all pixmaps transformed by transform.

Parameters:
  • icon (QIcon) – The icon to transform.

  • transform (QTransform) – The transform to apply to the icon.

Return type:

QIcon