8.6.8.2.7. pymodaq_gui.utils.widgets.painter_utils module

pymodaq_gui.utils.widgets.painter_utils.desaturate(color)[source]

Return a greyscale version of color with the same HSL lightness.

Return type:

QColor

pymodaq_gui.utils.widgets.painter_utils.draw_shape(painter, shape, rect)[source]

Draw a named shape inside rect using the painter’s current pen and brush.

Parameters:
  • painter (QPainter) – Active painter (must already be begun on a device).

  • shape (str) – One of 'circle', 'square', 'triangle', 'diamond', 'rectangle'.

  • rect (QRectF) – Bounding box (margins already applied by the caller).

Raises:

ValueError – If shape is not one of the supported values.

Return type:

None

pymodaq_gui.utils.widgets.painter_utils.make_brush(color, rect, gradient='flat', lighter=160, darker=130, angle=90.0)[source]

Return a QBrush suitable for filling a shape inside rect.

Parameters:
  • color (QColor) – Base fill colour.

  • rect (QRectF) – Bounding box of the shape to be filled (used to size the gradient).

  • gradient (str) –

    Fill style — one of:

    'flat'

    Solid fill with color.

    'radial'

    Off-centre radial gradient that mimics a sphere lit from the top-left: bright highlight fading to a darker edge. Classic LED look. Controlled by lighter / darker.

    'linear'

    Linear gradient along angle degrees (0 = left → right, 90 = top → bottom). Runs from color.lighter(lighter) to color.darker(darker).

    'glow'

    Centred radial gradient: full color at the centre fading to transparent at the edge. Useful for an “active” pulse effect.

  • lighter (int) – QColor.lighter() factor applied to the bright end of the gradient (default 160). Ignored for 'flat' and 'glow'.

  • darker (int) – QColor.darker() factor applied to the dark end of the gradient (default 130). Ignored for 'flat' and 'glow'.

  • angle (float) – Angle in degrees for 'linear' (default 90, top → bottom). 0 = left → right, 180 = right → left, 270 = bottom → top.

Raises:

ValueError – If gradient is not one of the supported styles.

Return type:

QBrush