class arcade.gui.UIButtonRow(vertical: bool = False, align: str = 'center', size_hint: ~typing.Any = (0, 0), size_hint_min: ~typing.Any | None = None, size_hint_max: ~typing.Any | None = None, space_between: int = 10, style: ~typing.Any | None = None, button_factory: type = <class 'arcade.gui.widgets.buttons.UIFlatButton'>)[source]#

Places buttons in a row. :param bool vertical: Whether the button row is vertical or not. :param str align: Where to align the button row. :param Any size_hint: Tuple of floats (0.0 - 1.0) of how much space of the parent should be requested. :param size_hint_min: Min width and height in pixel. :param size_hint_max: Max width and height in pixel. :param int space_between: The space between the children. :param Any style: Not used. :param Tuple[str, …] button_labels: The labels for the buttons. :param Callable callback: The callback function which will receive the text of the clicked button.


class arcade.gui.UIMessageBox(*, width: float, height: float, message_text: str, buttons=('Ok',))[source]#

A simple dialog box that pops up a message with buttons to close. Subclass this class or overwrite the ‘on_action’ event handler with

box = UIMessageBox(...)
def on_action(event: UIOnActionEvent):
  • width – Width of the message box

  • height – Height of the message box

  • message_text – Text to show as message to the user

  • buttons – List of strings, which are shown as buttons

on_action(event: UIOnActionEvent)[source]#

Called when button was pressed


class arcade.gui.UIDraggableMixin(*, x: float = 0, y: float = 0, width: float = 100, height: float = 100, children: Iterable[UIWidget] = (), size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[source]#

UIDraggableMixin can be used to make any UIWidget draggable.

Example, create a draggable Frame, with a background, useful for window like constructs:

class DraggablePane(UITexturePane, UIDraggableMixin):

This does overwrite UILayout behaviour which position themselves, like UIAnchorWidget


class arcade.gui.UIMouseFilterMixin(*, x: float = 0, y: float = 0, width: float = 100, height: float = 100, children: Iterable[UIWidget] = (), size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[source]#

UIMouseFilterMixin can be used to catch all mouse events which occur inside this widget.

Useful for window like widgets, UIMouseEvents should not trigger effects which are under the widget.


class arcade.gui.UIWindowLikeMixin(*, x: float = 0, y: float = 0, width: float = 100, height: float = 100, children: Iterable[UIWidget] = (), size_hint=None, size_hint_min=None, size_hint_max=None, **kwargs)[source]#

Makes a widget window like:

  • handles all mouse events that occur within the widgets boundaries

  • can be dragged


class arcade.gui.Surface(*, size: Tuple[int, int], position: Tuple[int, int] = (0, 0), pixel_ratio: float = 1.0)[source]#

Holds a and abstracts the drawing on it. Used internally for rendering widgets.


Save and restore projection and activate Surface buffer to draw on. Also resets the limit of the surface (viewport).


Blend mode for when we’re drawing the surface


Blend modes for when we’re drawing into the surface

clear(color: Tuple[int, int, int, int] = Color(r=0, g=0, b=0, a=0))[source]#

Clear the surface

draw(area: Tuple[int, int, int, int] | List[int] | None = None) None[source]#

Draws the contents of the surface.

The surface will be rendered at the configured position and limited by the given area. The area can be out of bounds.

  • position (Optional[Point]) – The position to draw the surface at.

  • area (Optional[Rect]) – Limit the area in the surface we’re drawing (x, y, w, h)

draw_sprite(x, y, width, height, sprite)[source]#

Draw a sprite to the surface

limit(x, y, width, height)[source]#

Reduces the draw area to the given rect

property position: Tuple[float, float]#

Get or set the surface position

resize(*, size: Tuple[int, int], pixel_ratio: float) None[source]#

Resize the internal texture by re-allocating a new one

  • size (Tuple[int,int]) – The new size in pixels (xy)

  • pixel_ratio (float) – The pixel scale of the window

property size#

Size of the surface in window coordinates

property size_scaled#

The physical size of the buffer


class arcade.gui.NinePatchTexture(*, left: int, right: int, bottom: int, top: int, texture: Texture, atlas: TextureAtlas | None = None)[source]#

Keeps borders & corners at constant widths while stretching the middle.

It can be used with new or existing UIWidget subclasses wherever an ordinary arcade.Texture is supported. This is useful for GUI elements which must grow or shrink while keeping their border decorations constant, such as dialog boxes or text boxes.

The diagram below explains the stretching behavior of this class:

  • Numbered regions with arrows (<--->) stretch along the direction(s) of any arrows present

  • Bars (|---|) mark the distances specified by the border parameters (left, etc)

Stretch Axes & Border Parameters#
    left                        right
    |------|                 |------|
    +------+-----------------+------+  ---
    | (1)  | (2)             | (3)  |   |
    |      | <-------------> |      |   |
    +------+-----------------+------+  ---
    | (4)  | (5)    ^        | (6)  |
    |  ^   |        |        |   ^  |
    |  |   |        |        |   |  |
    |  |   | <------+------> |   |  |
    |  |   |        |        |   |  |
    |  |   |        |        |   |  |
    |  v   |        v        |   v  |
    +------+-----------------+------+  ---
    | (7)  | (8)             | (9)  |   |
    |      | <-------------> |      |   |
    +------+-----------------+------+  ---

As the texture is stretched, the numbered slices of the texture behave as follows:

  • Areas (1), (3), (7) and (9) never stretch.

  • Area (5) stretches both horizontally and vertically.

  • Areas (2) and (8) only stretch horizontally.

  • Areas (4) and (6) only stretch vertically.

  • left (int) – The width of the left border of the 9-patch (in pixels)

  • right (int) – The width of the right border of the 9-patch (in pixels)

  • bottom (int) – The height of the bottom border of the 9-patch (in pixels)

  • top (int) – The height of the top border of the 9-patch (in pixels)

  • texture (Texture) – The raw texture to use for the 9-patch

  • atlas (TextureAtlas) – Specify an atlas other than arcade’s default texture atlas

property bottom: int#

Get or set the bottom border of the 9-patch.

property ctx: ArcadeContext#

The OpenGL context.

draw_sized(*, position: Tuple[float, float] = (0.0, 0.0), size: Tuple[float, float], pixelated: bool = False, **kwargs)[source]#

Draw the 9-patch texture with a specific size.


This method assumes the passed dimensions are proper!

Unexpected behavior may occur if you specify a size smaller than the total size of the border areas.

  • position – Bottom left offset of the texture in pixels

  • size – Size of the 9-patch as width, height in pixels

  • pixelated – Whether to draw with nearest neighbor interpolation

property height: int#

The height of the texture in pixels.

property left: int#

Get or set the left border of the 9-patch.

property program: Program#

Get or set the shader program.

Returns the default shader if no other shader is assigned.

property right: int#

Get or set the right border of the 9-patch.

property size: Tuple[int, int]#

The size of texture as a width, height tuple in pixels.

property texture: Texture#

Get or set the texture.

property top: int#

Get or set the top border of the 9-patch.

property width: int#

The width of the texture in pixels.


class arcade.gui.UIManager(window: Window | None = None)[source]#

UIManager is the central component within Arcade’s GUI system. Handles window events, layout process and rendering.

To process window events, UIManager.enable() has to be called, which will inject event callbacks for all window events and redirects them through the widget tree.

If used within a view UIManager.enable() should be called from View.on_show_view() and UIManager.disable() should be called from View.on_hide_view()

Supports size_hint to grow/shrink direct children dependent on window size. Supports size_hint_min to ensure size of direct children (e.g. UIBoxLayout). Supports size_hint_max to ensure size of direct children (e.g. UIBoxLayout).

class MyView(arcade.View):
    def __init__():
        manager = UIManager()


    def on_show_view(self):
        # Set background color
        self.window.background_color = arcade.color.DARK_BLUE_GRAY

        # Enable UIManager when view is shown to catch window events

    def on_hide_view(self):
        # Disable UIManager when view gets inactive

    def on_draw():


        manager.draw() # draws the UI on screen
add(widget: W, *, index=None, layer=0) W[source]#

Add a widget to the UIManager. Added widgets will receive ui events and be rendered.

By default the latest added widget will receive ui events first and will be rendered on top of others.

The UIManager supports layered setups, widgets added to a higher layer are drawn above lower layers and receive events first. The layer 10 is reserved for overlaying components like dropdowns or tooltips.

  • widget – widget to add

  • index – position a widget is added, None has the highest priority

  • layer – layer which the widget should be added to, higher layer are above


the widget

adjust_mouse_coordinates(x, y)[source]#

This method is used, to translate mouse coordinates to coordinates respecting the viewport and projection of cameras. The implementation should work in most common cases.

If you use scrolling in the arcade.Camera you have to reset scrolling or overwrite this method using the camera conversion:

ui_manager.adjust_mouse_coordinates = camera.mouse_coordinates_to_world

Camera used when drawing the UI


Remove all widgets from UIManager


Walks through all widgets of a UIManager and prints out the rect

disable() None[source]#

Remove handler functions (on_…) from arcade.Window

If every arcade.View uses its own arcade.gui.UIManager, this method should be called in arcade.View.on_hide_view().

enable() None[source]#

Registers handler functions (on_…) to arcade.gui.UIElement

on_draw is not registered, to provide full control about draw order, so it has to be called by the devs themselves.

Within a view, this method should be called from arcade.View.on_show_view().

get_widgets_at(pos, cls: ~typing.Type[~arcade.gui.ui_manager.W] = <class 'arcade.gui.widgets.UIWidget'>) Iterable[W][source]#

Yields all widgets containing a position, returns first top laying widgets which is instance of cls.

  • pos – Pos within the widget bounds

  • cls – class which the widget should be instance of


iterator of widgets of given type at position

remove(child: UIWidget)[source]#

Removes the given widget from UIManager.


child (UIWidget) – widget to remove


Request rendering of all widgets

walk_widgets(*, root: UIWidget | None = None) Iterable[UIWidget][source]#

walks through widget tree, in reverse draw order (most top drawn widget first)