Drawing

Summary

DrawingCanvas

Abstract base class for drawing.

Drawing

A widget that displays the result of drawing commands.

DrawLine

Draws a line.

DrawRectangle

Draws a rectangle.

DrawCircle

Draws a circle.

DrawText

Draws text.

DrawArrow

Draw a line with an arrowhead.

DrawPolyLine

Draws connected lines.

DrawTriangle

Draws a triangle.

DrawQuad

Draws a quadrilateral.

DrawPolygon

Draws a polygon.

DrawBezierCurve

Draws a bezier curve.

Drawing Canvas

class dearpygui_obj.drawing.DrawingCanvas[source]

Bases: abc.ABC

Abstract base class for drawing.

abstract property id: str
clear() None[source]

Clears the drawing.

Warning

Any DrawCommand objects created using this canvas must not be used after this method is called.

This includes reading or writing to any properties of DrawCommand objects.

draw_line(p1: Tuple[float, float], p2: Tuple[float, float], color: ColorRGBA, thickness: int) DrawLine[source]

See DrawLine

draw_rectangle(pmin: Tuple[float, float], pmax: Tuple[float, float], color: ColorRGBA, **kwargs: Any) DrawRectangle[source]

See DrawRectangle for keyword arguments.

draw_circle(center: Tuple[float, float], radius: float, color: ColorRGBA, **kwargs: Any) DrawCircle[source]

See DrawCircle for keyword arguments.

draw_text(pos: Tuple[float, float], text: str, **kwargs) DrawText[source]

See DrawText for keyword arguments.

draw_arrow(p1: Tuple[float, float], p2: Tuple[float, float], color: ColorRGBA, thickness: int, arrow_size: int) DrawArrow[source]

See DrawArrow for keyword arguments.

draw_polyline(points: Sequence[Tuple[float, float]], color: ColorRGBA, **kwargs: Any) DrawPolyLine[source]

See DrawPolyLine for keyword arguments.

draw_triangle(p1: Tuple[float, float], p2: Tuple[float, float], p3: Tuple[float, float], color: ColorRGBA, **kwargs: Any) DrawTriangle[source]

See DrawTriangle for keyword arguments.

draw_quad(p1: Tuple[float, float], p2: Tuple[float, float], p3: Tuple[float, float], p4: Tuple[float, float], color: ColorRGBA, **kwargs: Any) DrawQuad[source]

See DrawQuod for keyword arguments.

draw_polygon(points: Sequence[Tuple[float, float]], color: ColorRGBA, **kwargs) DrawPolygon[source]

See DrawPolygon for keyword arguments.

draw_bezier_curve(p1: Tuple[float, float], p2: Tuple[float, float], p3: Tuple[float, float], p4: Tuple[float, float], color: ColorRGBA, **kwargs: Any) DrawBezierCurve[source]

See DrawBezierCurve for keyword arguments.

class dearpygui_obj.drawing.WindowCanvas(window: Window)[source]

Bases: dearpygui_obj.drawing.DrawingCanvas

A DrawingCanvas that can be used to draw onto a window.

Can also be obtained from Window.get_canvas().

To draw on the foreground or background of the main viewport, see MainWindow.foreground and MainWindow.background.

property id: str

Drawing Widget

class dearpygui_obj.drawing.Drawing(size: Tuple[int, int] = (300, 300), **config)[source]

Bases: dearpygui_obj.wrapper.widget.Widget, dearpygui_obj.wrapper.widget.ItemWidgetMx, dearpygui_obj.drawing.DrawingCanvas

A widget that displays the result of drawing commands.

get_mouse_pos() Optional[Tuple[int, int]][source]

Get the mouse position within the drawing, or None if the drawing is not hovered.

Draw Commands

class dearpygui_obj.drawing.DrawLine(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws a line.

p1: Tuple[float, float]

Read or modify the ‘p1’ config field.

p2: Tuple[float, float]

Read or modify the ‘p2’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

thickness: int

Read or modify the ‘thickness’ config field.

class dearpygui_obj.drawing.DrawRectangle(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws a rectangle.

pmin: Tuple[float, float]

Read or modify the ‘pmin’ config field.

pmax: Tuple[float, float]

Read or modify the ‘pmax’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

fill: ColorRGBA

Read or modify the ‘fill’ config field.

rounding: float

Read or modify the ‘rounding’ config field.

thickness: float

Read or modify the ‘thickness’ config field.

class dearpygui_obj.drawing.DrawCircle(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws a circle.

center: Tuple[float, float]

Read or modify the ‘center’ config field.

radius: float

Read or modify the ‘radius’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

segments: int

Read or modify the ‘segments’ config field.

thickness: float

Read or modify the ‘thickness’ config field.

fill: ColorRGBA

Read or modify the ‘fill’ config field.

class dearpygui_obj.drawing.DrawText(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws text.

pos: Tuple[float, float]

Read or modify the ‘pos’ config field.

text: str

Read or modify the ‘text’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

font_size: int

Read or modify the ‘size’ config field.

class dearpygui_obj.drawing.DrawArrow(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draw a line with an arrowhead.

p1: Tuple[float, float]

Read or modify the ‘p1’ config field.

p2: Tuple[float, float]

Read or modify the ‘p2’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

thickness: int

Read or modify the ‘thickness’ config field.

arrow_size: int

Read or modify the ‘size’ config field.

class dearpygui_obj.drawing.DrawPolyLine(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws connected lines.

points

Read or modify the ‘points’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

closed: bool

Read or modify the ‘closed’ config field.

thickness: float

Read or modify the ‘thickness’ config field.

class dearpygui_obj.drawing.DrawTriangle(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws a triangle.

p1: Tuple[float, float]

Read or modify the ‘p1’ config field.

p2: Tuple[float, float]

Read or modify the ‘p2’ config field.

p3: Tuple[float, float]

Read or modify the ‘p3’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

fill: ColorRGBA

Read or modify the ‘fill’ config field.

thickness: float

Read or modify the ‘thickness’ config field.

class dearpygui_obj.drawing.DrawQuad(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws a quadrilateral.

p1: Tuple[float, float]

Read or modify the ‘p1’ config field.

p2: Tuple[float, float]

Read or modify the ‘p2’ config field.

p3: Tuple[float, float]

Read or modify the ‘p3’ config field.

p4: Tuple[float, float]

Read or modify the ‘p4’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

fill: ColorRGBA

Read or modify the ‘fill’ config field.

thickness: float

Read or modify the ‘thickness’ config field.

class dearpygui_obj.drawing.DrawPolygon(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws a polygon.

points

Read or modify the ‘points’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

fill: ColorRGBA

Read or modify the ‘fill’ config field.

thickness: float

Read or modify the ‘thickness’ config field.

class dearpygui_obj.drawing.DrawBezierCurve(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: dearpygui_obj.wrapper.drawing.DrawCommand

Draws a bezier curve.

p1: Tuple[float, float]

Read or modify the ‘p1’ config field.

p2: Tuple[float, float]

Read or modify the ‘p2’ config field.

p3: Tuple[float, float]

Read or modify the ‘p3’ config field.

p4: Tuple[float, float]

Read or modify the ‘p4’ config field.

color: ColorRGBA

Read or modify the ‘color’ config field.

thickness: float

Read or modify the ‘thickness’ config field.

segments: int

Read or modify the ‘segments’ config field.

Pos2D

class dearpygui_obj.drawing.Pos2D(x: float, y: float)[source]

Bases: tuple

2D position data used for drawing.

x: float

x coordinate

y: float

y coordinate

Draw Wrapper

Summary

DrawCommand

Base class for drawing commands.

DrawProperty

Descriptor used to get or set a draw command’s configuration.

class dearpygui_obj.wrapper.drawing.DrawCommand(canvas: DrawingCanvas, *args, tag_id: str = None, **kwargs: Any)[source]

Bases: abc.ABC

Base class for drawing commands.

property id: str
property is_valid: bool
property canvas: DrawingCanvas
delete() None[source]
get_config() DrawConfigData[source]
set_config(**config: Any) None[source]
bring_to_front() None[source]
send_to_back() None[source]
move_forward() None[source]
move_back() None[source]
class dearpygui_obj.wrapper.drawing.DrawProperty(key: Optional[str] = None, *, doc: str = '')[source]

Bases: object

Descriptor used to get or set a draw command’s configuration.

getvalue(fvalue: GetDrawValueFunc)[source]
getconfig(fconfig: GetDrawConfigFunc)[source]
fvalue(instance: DrawCommand) Any[source]
fconfig(instance: DrawCommand, value: Any) DrawConfigData[source]