GUI¶
Contents
arcade.gui.Surface¶
- class arcade.gui.Surface(*, size: Tuple[int, int], position: Tuple[int, int] = (0, 0), pixel_ratio: float = 1.0)[source]¶
Holds a
arcade.gl.Framebufferand abstracts the drawing on it. Used internally for rendering widgets.- activate()[source]¶
Save and restore projection and activate Surface buffer to draw on. Also resets the limit of the surface (viewport).
- clear(color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]] = (0, 0, 0, 0))[source]¶
Clear the surface
- property position: Tuple[int, int]¶
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
- property size¶
Size of the surface in window coordinates
- property size_scaled¶
The physical size of the buffer
arcade.gui.UIManager¶
- class arcade.gui.UIManager(window: Optional[arcade.application.Window] = None, auto_enable=False)[source]¶
V2 UIManager
manager = UIManager() manager.enable() # hook up window events
manager.add(Dummy())
- def on_draw():
arcade.start_render()
…
manager.draw() # draws the UI on screen
- add(widget: arcade.gui.widgets.UIWidget, *, index=None) arcade.gui.widgets.UIWidget[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.
- Parameters
widget – widget to add
index – position a widget is added, None has the highest priority
- Returns
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.Camerayou have to reset scrolling or overwrite this method using the camera conversion: ui_manager.adjust_mouse_coordinates = camera.mouse_coordinates_to_world
- disable()[source]¶
Remove handler functions (on_…) from
arcade.WindowIf every
arcade.Viewuses its ownarcade.gui.UIManager, this method should be called inarcade.View.on_hide_view().
arcade.gui.UIDraggableMixin¶
- class arcade.gui.UIDraggableMixin(x=0, y=0, width=100, height=100, children: Iterable[arcade.gui.widgets.UIWidget] = (), size_hint=None, size_hint_min=None, size_hint_max=None, style=None, **kwargs)[source]¶
UIDraggableMixin can be used to make any
UIWidgetdraggable.Example, create a draggable Frame, with a background, useful for window like constructs:
- class DraggablePane(UITexturePane, UIDraggableMixin):
…
This does overwrite
UILayoutbehaviour which position themselves, likeUIAnchorWidget
arcade.gui.UIMouseFilterMixin¶
- class arcade.gui.UIMouseFilterMixin(x: float = 0, y: float = 0, width: float = 100, height: float = 100, children: Iterable[arcade.gui.widgets.UIWidget] = (), size_hint=None, size_hint_min=None, size_hint_max=None, style=None, **kwargs)[source]¶
UIMouseFilterMixincan be used to catch all mouse events which occur inside this widget.Usefull for window like widgets,
UIMouseEventsshould not trigger effects which are under the widget.
arcade.gui.UIWindowLikeMixin¶
- class arcade.gui.UIWindowLikeMixin(x=0, y=0, width=100, height=100, children: Iterable[arcade.gui.widgets.UIWidget] = (), size_hint=None, size_hint_min=None, size_hint_max=None, style=None, **kwargs)[source]¶
Makes a widget window like:
handles all mouse events that occur within the widgets boundaries
can be dragged