PyDMDrawing Widgets

class pydm.widgets.drawing.PyDMDrawing(parent=None, init_channel=None)[source]

Base class to be used for all PyDM Drawing Widgets. This class inherits from QWidget and PyDMWidget.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

alarm_severity_changed(new_alarm_severity)[source]

Callback invoked when the Channel alarm severity is changed. This callback is not processed if the widget has no channel associated with it. This callback handles the composition of the stylesheet to be applied and the call to update to redraw the widget with the needed changes for the new state.

Parameters

new_alarm_severity (int) – The new severity where 0 = NO_ALARM, 1 = MINOR, 2 = MAJOR and 3 = INVALID

brush

PyQT Property for the brush object to be used when coloring the drawing

Returns

Return type

QBrush

draw_item(painter)[source]

The classes inheriting from PyDMDrawing must overwrite this method. This method translate the painter to the center point given by `get_center` and rotate the canvas by the given amount of degrees.

get_bounds(maxsize=False, force_no_pen=False)[source]

Returns a tuple containing the useful area for the drawing.

Parameters
  • maxsize (bool, default is False) – If True, width and height information are based on the maximum inner rectangle dimensions given by `get_inner_max`, otherwise width and height will receive the widget size.

  • force_no_pen (bool, default is False) – If True the pen width will not be considered when calculating the bounds.

Returns

x, y, w, h – Tuple with X and Y coordinates followed by the maximum width and height.

Return type

tuple

get_center()[source]

Simple calculation of the canvas’ center point.

Returns

x, y – Tuple with X and Y coordinates of the center.

Return type

float

get_inner_max()[source]

Calculates the largest inner rectangle in a rotated rectangle. This implementation was based on https://stackoverflow.com/a/18402507

Returns

w, h – The width and height of the largest rectangle.

Return type

tuple

has_border()[source]

Check whether or not the drawing have a border based on the Pen Style and Pen width.

Returns

True if the drawing has a border, False otherwise.

Return type

bool

is_square()[source]

Check if the widget has the same width and height values.

Returns

True in case the widget has a square shape, False otherwise.

Return type

bool

paintEvent(_)[source]

Paint events are sent to widgets that need to update themselves, for instance when part of a widget is exposed because a covering widget was moved.

At PyDMDrawing this method handles the alarm painting with parameters from the stylesheet, configures the brush, pen and calls `draw_item` so the specifics can be performed for each of the drawing classes.

Parameters

event (QPaintEvent) –

penCapStyle

PyQT Property for the pen cap to be used when drawing the border

Returns

Index at Qt.PenCapStyle enum

Return type

int

penColor

PyQT Property for the pen color to be used when drawing the border

Returns

Return type

QColor

penJoinStyle

PyQT Property for the pen join style to be used when drawing the border

Returns

Index at Qt.PenJoinStyle enum

Return type

int

penStyle

PyQT Property for the pen style to be used when drawing the border

Returns

Index at Qt.PenStyle enum

Return type

int

penWidth

PyQT Property for the pen width to be used when drawing the border

Returns

Return type

float

rotation

PyQT Property for the counter-clockwise rotation in degrees to be applied to the drawing.

Returns

Return type

float

sizeHint(self) → QSize[source]
class pydm.widgets.drawing.PyDMDrawingLine(parent=None, init_channel=None)[source]

A widget with a line drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the line after setting up the canvas with a call to `PyDMDrawing.draw_item`.

class pydm.widgets.drawing.PyDMDrawingImage(parent=None, init_channel=None, filename='')[source]

Renders an image given by the filename property. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

null_color

QColor to fill the image if the filename is not found.

Type

Qt.Color

aspectRatioMode

PyQT Property for aspect ratio mode to be used when rendering the image

Returns

Index at Qt.AspectRatioMode enum

Return type

int

draw_item(painter)[source]

Draws the image after setting up the canvas with a call to `PyDMDrawing.draw_item`.

filename

The filename of the image to be displayed. This can be an absolute or relative path to the display file.

Returns

The filename configured.

Return type

str

movie_finished()[source]

Callback executed when the movie is finished.

Returns

Return type

None

movie_frame_changed(frame_no)[source]

Callback executed when a new frame is available at the QMovie.

Parameters

frame_no (int) – The new frame index

Returns

Return type

None

sizeHint(self) → QSize[source]
class pydm.widgets.drawing.PyDMDrawingRectangle(parent=None, init_channel=None)[source]

A widget with a rectangle drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the rectangle after setting up the canvas with a call to `PyDMDrawing.draw_item`.

class pydm.widgets.drawing.PyDMDrawingTriangle(parent=None, init_channel=None)[source]

A widget with a triangle drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the triangle after setting up the canvas with a call to `PyDMDrawing.draw_item`.

class pydm.widgets.drawing.PyDMDrawingEllipse(parent=None, init_channel=None)[source]

A widget with an ellipse drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the ellipse after setting up the canvas with a call to `PyDMDrawing.draw_item`.

class pydm.widgets.drawing.PyDMDrawingCircle(parent=None, init_channel=None)[source]

A widget with a circle drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the circle after setting up the canvas with a call to `PyDMDrawing.draw_item`.

class pydm.widgets.drawing.PyDMDrawingArc(parent=None, init_channel=None)[source]

A widget with an arc drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the arc after setting up the canvas with a call to `PyDMDrawing.draw_item`.

spanAngle

PyQT Property for the span angle in degrees

Returns

Angle in degrees

Return type

float

startAngle

PyQT Property for the start angle in degrees

Returns

Angle in degrees

Return type

float

class pydm.widgets.drawing.PyDMDrawingPie(parent=None, init_channel=None)[source]

A widget with a pie drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the pie after setting up the canvas with a call to `PyDMDrawing.draw_item`.

class pydm.widgets.drawing.PyDMDrawingChord(parent=None, init_channel=None)[source]

A widget with a chord drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the chord after setting up the canvas with a call to `PyDMDrawing.draw_item`.

class pydm.widgets.drawing.PyDMDrawingPolygon(parent=None, init_channel=None)[source]

A widget with a polygon drawn in it. This class inherits from PyDMDrawing.

Parameters
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

draw_item(painter)[source]

Draws the Polygon after setting up the canvas with a call to `PyDMDrawing.draw_item`.

numberOfPoints

PyQT Property for the number of points

Returns

Number of Points

Return type

int