S or /

SourceClass Memory

from egui import Memory
class Memory:

The data that egui persists between frames.

This includes window positions and sizes, how far the user has scrolled in a ScrollArea etc.

If you want this to persist when closing your app, you should serialize Memory and store it. For this you need to enable the persistence feature.

If you want to store data for your widgets, you should look at Memory.data

Properties§

@property def data(self, /) -> IdTypeMap§
@data.setter def data(self, /, data: IdTypeMap) -> None§
@property def options(self, /) -> Options§
@options.setter def options(self, /, options: Options) -> None§
@property def to_global(self, /) -> list[tuple[LayerId, TSTransform]]§

Methods§

Sourcedef allows_interaction(self, /, layer_id: LayerId) -> bool§

Does this layer allow interaction? Returns true if - the layer is not behind a modal layer - the Order allows interaction

Sourcedef area_rect(self, /, id: Id) -> Rect |None§

Obtain the previous rectangle of an area.

Sourcedef areas(self, /) -> list[LayerId]§

Access memory of the Areas, such as Windows.

@staticmethod def default() -> Memory§
Sourcedef everything_is_visible(self, /) -> bool§

If true, all windows, menus, tooltips, etc., will be visible at once.

This is useful for testing, benchmarking, pre-caching, etc.

Experimental feature!

Sourcedef focused(self, /) -> Id |None§

Which widget has keyboard focus?

Sourcedef had_focus_last_frame(self, /, id: Id) -> bool§

Check if the layer had focus last frame. returns True if the layer had focus last frame, but not this one.

Sourcedef has_focus(self, /, id: Id) -> bool§

Does this widget have keyboard focus?

This function does not consider whether the UI as a whole (e.g. window) has the keyboard focus. That makes this function suitable for deciding widget state that should not be disrupted if the user moves away from the window and back.

Sourcedef interested_in_focus(self, /, id: Id, layer_id: LayerId) -> None§

Register this widget as being interested in getting keyboard focus. This will allow the user to select it with tab and shift-tab. This is normally done automatically when handling interactions, but it is sometimes useful to pre-register interest in focus, e.g. before deciding which type of underlying widget to use, as in the egui.DragValue widget, so a widget can be focused and rendered correctly in a single frame.

Pass in the layer_id of the layer that the widget is in.

Sourcedef interrupt_ime(self, /) -> None§

Interrupt the current IME composition, if any.

Sourcedef is_above_modal_layer(self, /, layer_id: LayerId) -> bool§

Returns true if - this layer is the top-most modal layer or above it - there is no modal layer

Sourcedef layer_id_at(self, /, pos: Pos2) -> LayerId |None§

Top-most layer at the given position.

Sourcedef layer_ids(self, /) -> list[LayerId]§

An iterator over all layers. Back-to-front, top is last.

def layer_transforms(self, /, layer_id: LayerId) -> TSTransform |None§
Sourcedef move_focus(self, /, direction: FocusDirection) -> None§

Move keyboard focus in a specific direction.

Sourcedef owns_ime_events(self, /, id: Id) -> bool§

Check if the widget owns IME events.

A widget should only consume IME events if this returns True. At most one widget can own IME events for each frame.

Sourcedef request_focus(self, /, id: Id) -> None§

Give keyboard focus to a specific widget. See also egui.Response.request_focus.

Calling this will interrupt IME composition.

def reset(self, /) -> None§
Sourcedef reset_areas(self, /) -> None§

Forget window positions, sizes etc. Can be used to auto-layout windows.

Sourcedef set_everything_is_visible(self, /, value: bool) -> None§

If true, all windows, menus, tooltips etc are to be visible at once.

This is useful for testing, benchmarking, pre-caching, etc.

Experimental feature!

Sourcedef set_focus_lock_filter(self, /, id: Id, event_filter: EventFilter) -> None§

Set an event filter for a widget.

This allows you to control whether the widget will loose focus when the user presses tab, arrow keys, or escape.

You must first give focus to the widget before calling this.

Sourcedef set_modal_layer(self, /, layer_id: LayerId) -> None§

Limit focus to widgets on the given layer and above. If this is called multiple times per frame, the top layer wins.

Sourcedef stop_text_input(self, /) -> None§

Stop editing the active TextEdit (if any).

Sourcedef surrender_focus(self, /, id: Id) -> None§

Surrender keyboard focus for a specific widget. See also egui.Response.surrender_focus.

Sourcedef top_modal_layer(self, /) -> LayerId |None§

Get the top modal layer (from the previous frame).