DearPyGui is a modern, fast and powerful GUI framework for Python that provides an easy-to-use, dynamic, GPU-accelerated, cross-platform graphical user interface toolkit.
—
Low-level drawing capabilities for custom graphics including shapes, lines, text rendering, and image display with transformation support. DearPyGui's drawing system provides immediate-mode graphics with GPU acceleration.
def add_drawlist(*, width: int = '', height: int = '', tag: Union[int, str] = '', parent: Union[int, str] = '', **kwargs) -> Union[int, str]:
"""Creates a drawing canvas for custom graphics."""
def add_viewport_drawlist(*, front: bool = '', tag: Union[int, str] = '', **kwargs) -> Union[int, str]:
"""Creates a viewport-level drawing overlay."""def draw_line(p1: Union[List[float], Tuple[float, ...]], p2: Union[List[float], Tuple[float, ...]], *, color: Union[List[int], Tuple[int, ...]] = '', thickness: float = '') -> None:
"""Draws a line between two points."""
def draw_rectangle(pmin: Union[List[float], Tuple[float, ...]], pmax: Union[List[float], Tuple[float, ...]], *, color: Union[List[int], Tuple[int, ...]] = '', fill: Union[List[int], Tuple[int, ...]] = '', thickness: float = '', rounding: float = '') -> None:
"""Draws a rectangle with optional fill and rounding."""
def draw_circle(center: Union[List[float], Tuple[float, ...]], radius: float, *, color: Union[List[int], Tuple[int, ...]] = '', fill: Union[List[int], Tuple[int, ...]] = '', thickness: float = '', segments: int = '') -> None:
"""Draws a circle with optional fill."""
def draw_ellipse(pmin: Union[List[float], Tuple[float, ...]], pmax: Union[List[float], Tuple[float, ...]], *, label: str = '', user_data: Any = '', use_internal_label: bool = '', tag: Union[int, str] = '', parent: Union[int, str] = '', before: Union[int, str] = '', show: bool = '', color: Union[List[int], Tuple[int, ...]] = '', fill: Union[List[int], Tuple[int, ...]] = '', thickness: float = '', segments: int = '') -> Union[int, str]:
"""
Draws an ellipse defined by bounding box.
Parameters:
- pmin, pmax (tuple): Bounding box corners
- color (tuple): Outline color
- fill (tuple): Fill color
- thickness (float): Outline thickness
- segments (int): Number of segments for smoothness
Returns:
Union[int, str]: Drawing item ID
"""
def draw_triangle(p1: Union[List[float], Tuple[float, ...]], p2: Union[List[float], Tuple[float, ...]], p3: Union[List[float], Tuple[float, ...]], *, label: str = '', user_data: Any = '', use_internal_label: bool = '', tag: Union[int, str] = '', parent: Union[int, str] = '', before: Union[int, str] = '', show: bool = '', color: Union[List[int], Tuple[int, ...]] = '', fill: Union[List[int], Tuple[int, ...]] = '', thickness: float = '') -> Union[int, str]:
"""
Draws a triangle from three points.
Parameters:
- p1, p2, p3 (tuple): Triangle vertices
- color (tuple): Outline color
- fill (tuple): Fill color
- thickness (float): Outline thickness
Returns:
Union[int, str]: Drawing item ID
"""
def draw_quad(p1: Union[List[float], Tuple[float, ...]], p2: Union[List[float], Tuple[float, ...]], p3: Union[List[float], Tuple[float, ...]], p4: Union[List[float], Tuple[float, ...]], *, label: str = '', user_data: Any = '', use_internal_label: bool = '', tag: Union[int, str] = '', parent: Union[int, str] = '', before: Union[int, str] = '', show: bool = '', color: Union[List[int], Tuple[int, ...]] = '', fill: Union[List[int], Tuple[int, ...]] = '', thickness: float = '') -> Union[int, str]:
"""
Draws a quadrilateral from four points.
Parameters:
- p1, p2, p3, p4 (tuple): Quad vertices
- color (tuple): Outline color
- fill (tuple): Fill color
- thickness (float): Outline thickness
Returns:
Union[int, str]: Drawing item ID
"""
def draw_polygon(points: Union[List[Union[List[float], Tuple[float, ...]]], Tuple[Union[List[float], Tuple[float, ...]], ...]], *, color: Union[List[int], Tuple[int, ...]] = '', fill: Union[List[int], Tuple[int, ...]] = '', thickness: float = '') -> None:
"""Draws a polygon from a list of points."""
def draw_polyline(points: List[List[float]], *, label: str = '', user_data: Any = '', use_internal_label: bool = '', tag: Union[int, str] = '', parent: Union[int, str] = '', before: Union[int, str] = '', show: bool = '', closed: bool = '', color: Union[List[int], Tuple[int, ...]] = '', thickness: float = '') -> Union[int, str]:
"""
Draws a multi-segment line through points.
Parameters:
- points (list): List of point coordinates [[x1,y1], [x2,y2], ...]
- closed (bool): Connect last point to first
- color (tuple): Line color
- thickness (float): Line thickness
Returns:
Union[int, str]: Drawing item ID
"""
def draw_arrow(p1: Union[List[float], Tuple[float, ...]], p2: Union[List[float], Tuple[float, ...]], *, label: str = '', user_data: Any = '', use_internal_label: bool = '', tag: Union[int, str] = '', parent: Union[int, str] = '', before: Union[int, str] = '', show: bool = '', color: Union[List[int], Tuple[int, ...]] = '', thickness: float = '', size: int = '') -> Union[int, str]:
"""
Draws an arrow from p1 to p2.
Parameters:
- p1, p2 (tuple): Arrow start and end points
- color (tuple): Arrow color
- thickness (float): Line thickness
- size (int): Arrowhead size
Returns:
Union[int, str]: Drawing item ID
"""def draw_bezier_cubic(p1: Union[List[float], Tuple[float, ...]], p2: Union[List[float], Tuple[float, ...]], p3: Union[List[float], Tuple[float, ...]], p4: Union[List[float], Tuple[float, ...]], *, label: str = '', user_data: Any = '', use_internal_label: bool = '', tag: Union[int, str] = '', parent: Union[int, str] = '', before: Union[int, str] = '', show: bool = '', color: Union[List[int], Tuple[int, ...]] = '', thickness: float = '', segments: int = '') -> Union[int, str]:
"""
Draws a cubic Bézier curve.
Parameters:
- p1 (tuple): Start point
- p2, p3 (tuple): Control points
- p4 (tuple): End point
- color (tuple): Line color
- thickness (float): Line thickness
- segments (int): Number of segments for smoothness
Returns:
Union[int, str]: Drawing item ID
"""
def draw_bezier_quadratic(p1: Union[List[float], Tuple[float, ...]], p2: Union[List[float], Tuple[float, ...]], p3: Union[List[float], Tuple[float, ...]], *, label: str = '', user_data: Any = '', use_internal_label: bool = '', tag: Union[int, str] = '', parent: Union[int, str] = '', before: Union[int, str] = '', show: bool = '', color: Union[List[int], Tuple[int, ...]] = '', thickness: float = '', segments: int = '') -> Union[int, str]:
"""
Draws a quadratic Bézier curve.
Parameters:
- p1 (tuple): Start point
- p2 (tuple): Control point
- p3 (tuple): End point
- color (tuple): Line color
- thickness (float): Line thickness
- segments (int): Number of segments for smoothness
Returns:
Union[int, str]: Drawing item ID
"""def draw_text(pos: Union[List[float], Tuple[float, ...]], text: str, *, color: Union[List[int], Tuple[int, ...]] = '', size: float = '') -> None:
"""Draws text at the specified position."""
def draw_image(texture_tag: Union[int, str], pmin: Union[List[float], Tuple[float, ...]], pmax: Union[List[float], Tuple[float, ...]], *, uv_min: Union[List[float], Tuple[float, ...]] = '', uv_max: Union[List[float], Tuple[float, ...]] = '', color: Union[List[int], Tuple[int, ...]] = '') -> None:
"""Draws an image from a texture."""
def draw_image_quad(texture_tag: Union[int, str], p1: Union[List[float], Tuple[float, ...]], p2: Union[List[float], Tuple[float, ...]], p3: Union[List[float], Tuple[float, ...]], p4: Union[List[float], Tuple[float, ...]], *, label: str = '', user_data: Any = '', use_internal_label: bool = '', tag: Union[int, str] = '', parent: Union[int, str] = '', before: Union[int, str] = '', show: bool = '', uv1: Union[List[float], Tuple[float, ...]] = '', uv2: Union[List[float], Tuple[float, ...]] = '', uv3: Union[List[float], Tuple[float, ...]] = '', uv4: Union[List[float], Tuple[float, ...]] = '', color: Union[List[int], Tuple[int, ...]] = '') -> Union[int, str]:
"""
Draws an image mapped to a quadrilateral.
Parameters:
- texture_tag: Texture to use
- p1, p2, p3, p4 (tuple): Quad vertices
- uv1, uv2, uv3, uv4 (tuple): UV coordinates for each vertex
- color (tuple): Tint color
Returns:
Union[int, str]: Drawing item ID
"""def apply_transform(item: Union[int, str], transform: Any) -> None:
"""Applies a transformation matrix to drawing operations."""
def create_translation_matrix(translation: Union[List[float], Tuple[float, ...]]) -> Any:
"""
Creates a translation transformation matrix.
Parameters:
- translation (tuple): Translation vector [x, y] or [x, y, z]
Returns:
Any: Transformation matrix
"""
def create_rotation_matrix(angle: float, axis: Union[List[float], Tuple[float, ...]] = '') -> Any:
"""
Creates a rotation transformation matrix.
Parameters:
- angle (float): Rotation angle in radians
- axis (tuple): Rotation axis for 3D rotations [x, y, z]
Returns:
Any: Transformation matrix
"""
def create_scale_matrix(scales: Union[List[float], Tuple[float, ...]]) -> Any:
"""
Creates a scale transformation matrix.
Parameters:
- scales (tuple): Scale factors [x, y] or [x, y, z]
Returns:
Any: Transformation matrix
"""
def create_perspective_matrix(fov: float, aspect: float, zNear: float, zFar: float) -> Any:
"""
Creates a perspective projection matrix.
Parameters:
- fov (float): Field of view angle in radians
- aspect (float): Aspect ratio (width/height)
- zNear (float): Near clipping plane distance
- zFar (float): Far clipping plane distance
Returns:
Any: Perspective projection matrix
"""
def create_orthographic_matrix(left: float, right: float, bottom: float, top: float, zNear: float, zFar: float) -> Any:
"""
Creates an orthographic projection matrix.
Parameters:
- left, right (float): Left and right clipping planes
- bottom, top (float): Bottom and top clipping planes
- zNear, zFar (float): Near and far clipping planes
Returns:
Any: Orthographic projection matrix
"""
def create_lookat_matrix(eye: Union[List[float], Tuple[float, ...]], target: Union[List[float], Tuple[float, ...]], up: Union[List[float], Tuple[float, ...]]) -> Any:
"""
Creates a look-at view matrix.
Parameters:
- eye (tuple): Camera position [x, y, z]
- target (tuple): Target position [x, y, z]
- up (tuple): Up vector [x, y, z]
Returns:
Any: Look-at view matrix
"""
def create_fps_matrix(eye: Union[List[float], Tuple[float, ...]], pitch: float, yaw: float) -> Any:
"""
Creates a first-person-shooter style view matrix.
Parameters:
- eye (tuple): Camera position [x, y, z]
- pitch (float): Pitch angle in radians
- yaw (float): Yaw angle in radians
Returns:
Any: FPS view matrix
"""import dearpygui.dearpygui as dpg
import math
with dpg.window(label="Drawing Example", width=600, height=500):
with dpg.drawlist(width=500, height=400):
# Draw shapes
dpg.draw_rectangle([50, 50], [150, 100], color=[255, 0, 0], fill=[255, 0, 0, 100])
dpg.draw_circle([250, 150], 50, color=[0, 255, 0], thickness=3)
dpg.draw_line([300, 50], [400, 150], color=[0, 0, 255], thickness=2)
dpg.draw_text([50, 200], "Hello Graphics!", color=[255, 255, 255], size=20)Install with Tessl CLI
npx tessl i tessl/pypi-dearpygui