8.6.8.14. pymodaq_gui.utils.styling module

class pymodaq_gui.utils.styling.Font(font_name='Tahoma', font_size=14, isbold=True, isitalic=False, color=None)[source]

Bases: object

Attributes:
color

Methods

apply_to_widget

get_font

apply_to_widget(widget)[source]
get_font()[source]
Return type:

QFont

color: QColor | str | tuple[int, int, int] = None
font_name: str = 'Tahoma'
font_size: int = 14
isbold: bool = True
isitalic: bool = False
pymodaq_gui.utils.styling.alpha_color(level)[source]
pymodaq_gui.utils.styling.button_style(level)[source]
pymodaq_gui.utils.styling.color_from_depth(color, depth)[source]
Return type:

QColor

pymodaq_gui.utils.styling.color_to_rgba(color, alpha=None)[source]

Return a rgba string to use for color argument in stylesheets

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, rotate=0, fill=None)[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).

  • rotate (int) – Rotate the icon given the value in degrees

  • fill (bool) – Is Material Icon filled or edged. If None, left to the user configuration else force the choice on the icon

  • rotate – rotation of the icon in degrees. If 0 nothing is done

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.menu_style(level)[source]
pymodaq_gui.utils.styling.resource_path_exists(path)[source]
Return type:

bool

pymodaq_gui.utils.styling.text_color(level)[source]
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