S or /

SourceClass Context

from egui import Context
class Context:

Your handle to egui.

This is the first thing you need when working with egui. Contains the InputState, Memory, PlatformOutput, and more.

Context is cheap to clone, and any clones refers to the same mutable data (Context uses refcounting internally).

Locking

All methods are marked &self; Context has interior mutability protected by an RwLock.

To access parts of a Context you need to use some of the helper functions that take closures:

Within such a closure you may NOT recursively lock the same Context, as that can lead to a deadlock. Therefore it is important that any lock of Context is short-lived.

These are effectively transactional accesses.

Ui has many of the same accessor functions, and the same applies there.

Example:

Methods§

Sourcedef add_bytes_loader(self, /, loader: BytesLoader) -> None§

Add a new bytes loader.

It will be tried first, before any already installed loaders.

See load for more information.

Sourcedef add_font(self, /, font: FontInsert) -> None§

Add an additional font to egui.

The default egui fonts only support latin and cyrillic alphabets, but you can call this to install additional fonts that support e.g. korean characters.

The new font will become active at the start of the next pass. This will keep the existing fonts.

This font will be used before any system fallback.

Sourcedef add_image_loader(self, /, loader: ImageLoader) -> None§

Add a new image loader.

It will be tried first, before any already installed loaders.

See load for more information.

Sourcedef add_texture_loader(self, /, loader: TextureLoader) -> None§

Add a new texture loader.

It will be tried first, before any already installed loaders.

See load for more information.

Sourcedef animate_bool(self, /, id: Id, value: bool) -> float§

Returns a value in the range [0, 1], to indicate "how on" this thing is.

The first time called it will return if value { 1.0 } else { 0.0 } Calling this with value = True will always yield a number larger than zero, quickly going towards one. Calling this with value = False will always yield a number less than one, quickly going towards zero.

The function will call egui.Context.request_repaint() when appropriate.

The animation time is taken from Style.animation_time.

Sourcedef animate_bool_responsive(self, /, id: Id, value: bool) -> float§

Like egui.Context.animate_bool, but uses an easing function that makes the value move quickly in the beginning and slow down towards the end.

The exact easing function may come to change in future versions of egui.

Sourcedef animate_bool_with_easing(self, /, id: Id, value: bool, easing: str) -> float§

Like egui.Context.animate_bool but allows you to control the easing function.

Sourcedef animate_bool_with_time(self, /, id: Id, target_value: bool, animation_time: float) -> float§

Like egui.Context.animate_bool but allows you to control the animation time.

Sourcedef animate_bool_with_time_and_easing(self, /, id: Id, target_value: bool, animation_time: float, easing: str) -> float§

Like egui.Context.animate_bool but allows you to control the animation time and easing function.

Use e.g. emath.easing.quadratic_out for a responsive start and a slow end.

The easing function flips when target_value is False, so that when going back towards 0.0, we get the reverse behavior.

Sourcedef animate_value_with_time(self, /, id: Id, target_value: float, animation_time: float) -> float§

Smoothly animate an float value.

At the first call the value is written to memory. When it is called with a new value, it linearly interpolates to it in the given time.

Sourcedef any_popup_open(self, /) -> bool§

Is a popup or (context) menu open?

Will return false for egui.Tooltips (which are technically popups as well).

def available_rect(self, /) -> Rect§
def begin_frame(self, /, raw_input: RawInput) -> None§
Sourcedef begin_pass(self, /, raw_input: RawInput) -> None§

An alternative to calling egui.Context.run_ui.

It is usually better to use egui.Context.run_ui, because run_ui supports multi-pass layout using egui.Context.request_discard.

Sourcedef check_for_id_clash(self, /, id: Id, new_rect: Rect, what: str) -> None§

If the given Id has been used previously the same pass at different position, then an error will be printed on screen.

This function is already called for all widgets that do any interaction, but you can call this from widgets that store state but that does not interact.

The given Rect should be approximately where the widget will be. The most important thing is that Rect.min is approximately correct, because that's where the warning will be painted. If you don't know what size to pick, just pick Vec2.ZERO.

Sourcedef clear_animations(self, /) -> None§

Clear memory of any animations.

def clone_ref(self, /) -> Context§
Sourcedef content_rect(self, /) -> Rect§

Returns the position and size of the egui area that is safe for content rendering.

Returns egui.Context.viewport_rect minus areas that might be partially covered by, for example, the OS status bar or display notches.

If you want to render behind e.g. the dynamic island on iOS, use egui.Context.viewport_rect.

Sourcedef copy_image(self, /, image: ColorImage) -> None§

Copy the given image to the system clipboard.

Note that in web applications, the clipboard is only accessible in secure contexts (e.g., HTTPS or localhost). If this method is used outside of a secure context, it will log an error and do nothing. See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.

Sourcedef copy_text(self, /, text: str) -> None§

Copy the given text to the system clipboard.

Note that in web applications, the clipboard is only accessible in secure contexts (e.g., HTTPS or localhost). If this method is used outside of a secure context, it will log an error and do nothing. See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.

Sourcedef cumulative_frame_nr(self, /) -> int§

The total number of completed frames.

Starts at zero, and is incremented once at the end of each call to egui.Context.run_ui.

This is always smaller or equal to egui.Context.cumulative_pass_nr.

Sourcedef cumulative_frame_nr_for(self, /, viewport_id: ViewportId) -> int§

The total number of completed frames.

Starts at zero, and is incremented once at the end of each call to egui.Context.run_ui.

This is always smaller or equal to egui.Context.cumulative_pass_nr_for.

Sourcedef cumulative_pass_nr(self, /) -> int§

The total number of completed passes (usually there is one pass per rendered frame).

Starts at zero, and is incremented for each completed pass inside of egui.Context.run_ui (usually once).

If you instead want to know which pass index this is within the current frame, use egui.Context.current_pass_index.

Sourcedef cumulative_pass_nr_for(self, /, viewport_id: ViewportId) -> int§

The total number of completed passes (usually there is one pass per rendered frame).

Starts at zero, and is incremented for each completed pass inside of egui.Context.run_ui (usually once).

Sourcedef current_pass_index(self, /) -> int§

The index of the current pass in the current frame, starting at zero.

Usually this is zero, but if something called egui.Context.request_discard to do multi-pass layout, then this will be incremented for each pass.

This just reads the value of PlatformOutput.num_completed_passes.

To know the total number of passes ever completed, use egui.Context.cumulative_pass_nr.

Sourcedef data(self, /) -> Any§

Read-only access to IdTypeMap, which stores superficial widget state.

Sourcedef data_mut(self, /) -> Any§

Read-write access to IdTypeMap, which stores superficial widget state.

Sourcedef debug_on_hover(self, /) -> bool§

Whether or not to debug widget layout on hover.

Sourcedef debug_painter(self, /) -> Painter§

Paint on top of everything else (even on top of tooltips and popups).

Sourcedef debug_text(self, /, text: str) -> None§

Print this text next to the cursor at the end of the pass.

If you call this multiple times, the text will be appended.

This only works if compiled with debug_assertions.

This is just a convenience for calling egui.debug_text.print.

@staticmethod def default() -> Context§
Sourcedef disable_accesskit(self, /) -> None§

Disable generation of AccessKit tree updates in all future frames.

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

This widget just started being dragged this pass.

The same widget should also be found in egui.Context.dragged_id.

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

This widget was being dragged, but was released this pass.

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

The widget currently being dragged, if any.

For widgets that sense both clicks and drags, this will not be set until the mouse cursor has moved a certain distance.

NOTE: if the widget was released this pass, this will be None. Use egui.Context.drag_stopped_id instead.

Sourcedef dragging_something_else(self, /, not_this: Id) -> bool§

Is something else being dragged?

Returns true if we are dragging something, but not the given widget.

Sourcedef egui_is_using_pointer(self, /) -> bool§

Is egui currently using the pointer position (e.g. dragging a slider)?

NOTE: this will return False if the pointer is just hovering over an egui area.

Sourcedef egui_wants_keyboard_input(self, /) -> bool§

If True, egui is currently listening on text input (e.g. typing text in a egui.TextEdit).

Sourcedef egui_wants_pointer_input(self, /) -> bool§

True if egui is currently interested in the pointer (mouse or touch).

Could be the pointer is hovering over a egui.Window or the user is dragging a widget. If False, the pointer is outside of any egui area and so you may be interested in what it is doing (e.g. controlling your game). Returns False if a drag started outside of egui and then moved over an egui area.

Sourcedef embed_viewports(self, /) -> bool§

If True, egui.Context.show_viewport_deferred and egui.Context.show_viewport_immediate will embed the new viewports inside the existing one, instead of spawning a new native window.

eframe sets this to False on supported platforms, but the default value is True.

Sourcedef enable_accesskit(self, /) -> None§

Enable generation of AccessKit tree updates in all future frames.

def end_frame(self, /) -> FullOutput§
Sourcedef end_pass(self, /) -> FullOutput§

Call at the end of each frame if you called Context.begin_pass.

Sourcedef fonts(self, /) -> Any§

Read-only access to Fonts.

Not valid until first call to Context.run_ui(). That's because since we don't know the proper pixels_per_point until then.

Sourcedef fonts_mut(self, /) -> Any§

Read-write access to Fonts.

Not valid until first call to Context.run_ui(). That's because since we don't know the proper pixels_per_point until then.

Sourcedef forget_all_images(self, /) -> None§

Release all memory and textures related to images used in Ui.image or egui.Image.

If you attempt to load any images again, they will be reloaded from scratch.

Sourcedef forget_image(self, /, uri: str) -> None§

Release all memory and textures related to the given image URI.

If you attempt to load the image again, it will be reloaded from scratch. Also this cancels any ongoing loading of the image.

Sourcedef format_modifiers(self, /, modifiers: Modifiers) -> str§

Format the given modifiers in a human-readable way (e.g. Ctrl+Shift+X).

Sourcedef format_shortcut(self, /, shortcut: KeyboardShortcut) -> str§

Format the given shortcut in a human-readable way (e.g. Ctrl+Shift+X).

Can be used to get the text for egui.Button.shortcut_text.

Sourcedef global_style(self, /) -> Style§

The currently active Style used by all subsequent popups, menus, etc.

Sourcedef global_style_mut(self, /) -> Any§

Mutate the currently active Style used by all subsequent popups, menus, etc. Use egui.Context.all_styles_mut to mutate both dark and light mode styles.

Sourcedef globally_used_rect(self, /) -> Rect§

How much space is used by windows and the top-level Ui.

Sourcedef has_pending_images(self, /) -> bool§

Returns True if any image is currently being loaded.

Sourcedef has_requested_repaint(self, /) -> bool§

Has a repaint been requested for the current viewport?

Sourcedef has_requested_repaint_for(self, /, viewport_id: ViewportId) -> bool§

Has a repaint been requested for the given viewport?

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

Highlight this widget, to make it look like it is hovered, even if it isn't.

If you call this after the widget has been fully rendered, then it won't be highlighted until the next ui pass.

See also Response.highlight.

Sourcedef include_bytes(self, /, uri: str, bytes: Bytes) -> None§

Associate some static bytes with a uri.

The same uri may be passed to Ui.image later to load the bytes as an image.

By convention, the uri should start with bytes://. Following that convention will lead to better error messages.

Sourcedef input(self, /) -> Any§

Read-only access to InputState.

Note that this locks the Context.

Sourcedef input_for(self, /, viewport_id: ViewportId) -> Any§

This will create a InputState.default() if there is no input state for that viewport

Sourcedef input_mut(self, /) -> Any§

Read-write access to InputState.

Sourcedef input_mut_for(self, /, viewport_id: ViewportId) -> Any§

This will create a InputState.default() if there is no input state for that viewport

Sourcedef interaction_snapshot(self, /) -> InteractionSnapshot§

Read which widgets are currently being interacted with.

Sourcedef interactive_rects_last_pass(self, /) -> list[Rect]§

Rectangles that could receive pointer input in the last completed pass.

This exposes the same widget rectangles egui uses for hit-testing, after filtering out disabled widgets, non-interactive widgets, and layers that are currently blocked from interaction. The returned rectangles are in global viewport coordinates, with layer transforms applied.

This is meant for integrations that must declare platform input regions before pointer events can be delivered to egui, such as transparent or click-through overlays.

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

Is this specific widget being dragged?

A widget that sense both clicks and drags is only marked as "dragged" when the mouse has moved a bit.

See also: egui.Response.dragged.

def is_context_menu_open(self, /) -> bool§
Sourcedef is_loader_installed(self, /, id: str) -> bool§

Returns True if the chain of bytes, image, or texture loaders contains a loader with the given id.

def is_pointer_over_area(self, /) -> bool§
Sourcedef is_pointer_over_egui(self, /) -> bool§

Is the pointer (mouse/touch) over any egui area?

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

Top-most layer at the given position.

Sourcedef layer_painter(self, /, layer_id: LayerId) -> Painter§

Get a full-screen painter for a new or existing layer

Sourcedef layer_transform_from_global(self, /, layer_id: LayerId) -> TSTransform |None§

Return how to transform the graphics of the global coordinate system into the local coordinate system of the given layer.

This returns the inverse of egui.Context.layer_transform_to_global.

Sourcedef layer_transform_to_global(self, /, layer_id: LayerId) -> TSTransform |None§

Return how to transform the graphics of the given layer into the global coordinate system.

Set this with egui.Context.layer_transform_to_global.

Sourcedef load_texture(self, /, name: str, image: ColorImage, texture_options: TextureOptions) -> TextureHandle§

Allocate a texture.

This is for advanced users. Most users should use egui.Ui.image or egui.Context.try_load_texture instead.

In order to display an image you must convert it to a texture using this function. The function will hand over the image data to the egui backend, which will upload it to the GPU.

⚠️ Make sure to only call this ONCE for each image, i.e. NOT in your main GUI code. The call is NOT immediate safe.

The given name can be useful for later debugging, and will be visible if you call egui.Context.texture_ui.

For how to load an image, see egui.ImageData and egui.ColorImage.from_rgba_unmultiplied.

See also egui.ImageData, egui.Ui.image and egui.Image.

Sourcedef loaders(self, /) -> Loaders§

The loaders of bytes, images, and textures.

Sourcedef loaders_ui(self, /, ui: Ui) -> None§

Show stats about different image loaders.

Sourcedef memory(self, /) -> Any§

Read-only access to Memory.

Sourcedef memory_mut(self, /) -> Any§

Read-write access to Memory.

Sourcedef memory_ui(self, /, ui: Ui) -> None§

Shows the contents of egui.Context.memory.

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

Moves the given area to the top in its Order.

egui.Areas and egui.Windows also do this automatically when being clicked on or interacted with.

Sourcedef multi_touch(self, /) -> MultiTouchInfo |None§
Sourcedef native_pixels_per_point(self, /) -> float |None§

The number of physical pixels for each logical point on this monitor.

This is given as input to egui via egui.ViewportInfo.native_pixels_per_point and cannot be changed.

Sourcedef open_url(self, /, open_url: OpenUrl) -> None§

Open an URL in a browser.

Sourcedef options(self, /) -> Options§

Read-only access to Options.

Sourcedef options_mut(self, /) -> Any§

Read-write access to Options.

Sourcedef os(self, /) -> OperatingSystem§

What operating system are we running on?

When compiling natively, this is figured out from the target_os.

For web, this can be figured out from the user-agent, and is done so by eframe.

Sourcedef output(self, /) -> Any§

Read-only access to PlatformOutput.

This is what egui outputs each pass and frame.

Sourcedef output_mut(self, /) -> Any§

Read-write access to PlatformOutput.

Sourcedef parent_viewport_id(self, /) -> ViewportId§

Return the ViewportId of his parent.

If this is the root viewport, this will return ViewportId.ROOT.

Don't use this outside of egui.Context.run, or after egui.Context.end_pass.

Sourcedef pixels_per_point(self, /) -> float§

The number of physical pixels for each logical point.

This is calculated as egui.Context.zoom_factor * egui.Context.native_pixels_per_point

Sourcedef pointer_hover_pos(self, /) -> Pos2 |None§

If it is a good idea to show a tooltip, where is pointer?

Sourcedef pointer_interact_pos(self, /) -> Pos2 |None§

If you detect a click or drag and want to know where it happened, use this.

Latest position of the mouse, but ignoring any egui.Event.PointerGone if there were interactions this pass. When tapping a touch screen, this will be the location of the touch.

Sourcedef pointer_latest_pos(self, /) -> Pos2 |None§

Latest reported pointer position.

When tapping a touch screen, this will be None.

Sourcedef read_response(self, /, id: Id) -> Response |None§

Read the response of some widget, which may be called before creating the widget (!).

This is because widget interaction happens at the start of the pass, using the widget rects from the previous pass.

If the widget was not visible the previous pass (or this pass), this will return None.

If you try to read a Ui's response, while still inside, this will return the Rect from the previous frame.

Sourcedef rect_contains_pointer(self, /, layer_id: LayerId, rect: Rect) -> bool§

Does the given rectangle contain the mouse pointer?

Will return false if some other area is covering the given layer.

The given rectangle is assumed to have been clipped by its parent clip rect.

See also Response.contains_pointer.

Sourcedef register_widget_info(self, /, id: Id, widget_info: WidgetInfo) -> None§

This is called by Response.widget_info, but can also be called directly.

With some debug flags it will store the widget info in egui.WidgetRects for later display.

Sourcedef repaint_causes(self, /) -> list[RepaintCause]§

Why are we repainting?

This can be helpful in debugging why egui is constantly repainting.

Sourcedef request_discard(self, /, reason: str) -> None§

Request to discard the visual output of this pass, and to immediately do another one.

This can be called to cover up visual glitches during a "sizing pass". For instance, when a egui.Grid is first shown we don't yet know the width and heights of its columns and rows. egui will do a best guess, but it will likely be wrong. Next pass it can read the sizes from the previous pass, and from there on the widths will be stable. This means the first pass will look glitchy, and ideally should not be shown to the user. So egui.Grid calls egui.Context.request_discard to cover up this glitches.

There is a limit to how many passes egui will perform, set by Options.max_passes (default=2). Therefore, the request might be declined.

You can check if the current pass will be discarded with egui.Context.will_discard.

You should be very conservative with when you call egui.Context.request_discard, as it will cause an extra ui pass, potentially leading to extra CPU use and frame judder.

The given reason should be a human-readable string that explains why request_discard was called. This will be shown in certain debug situations, to help you figure out why a pass was discarded.

Sourcedef request_repaint(self, /) -> None§

Call this if there is need to repaint the UI, i.e. if you are showing an animation.

If this is called at least once in a frame, then there will be another frame right after this. Call as many times as you wish, only one repaint will be issued.

To request repaint with a delay, use egui.Context.request_repaint_after.

If called from outside the UI thread, the UI thread will wake up and run, provided the egui integration has set that up via egui.Context.set_request_repaint_callback (this will work on eframe).

This will repaint the current viewport.

Sourcedef request_repaint_after(self, /, seconds: float) -> None§

Request repaint after at most the specified duration elapses.

The backend can chose to repaint sooner, for instance if some other code called this method with a lower duration, or if new events arrived.

The function can be multiple times, but only the smallest duration will be considered. So, if the function is called two times with 1 second and 2 seconds, egui will repaint after 1 second

This is primarily useful for applications who would like to save battery by avoiding wasted redraws when the app is not in focus. But sometimes the GUI of the app might become stale and outdated if it is not updated for too long.

Let's say, something like a stopwatch widget that displays the time in seconds. You would waste resources repainting multiple times within the same second (when you have no input), just calculate the difference of duration between current time and next second change, and call this function, to make sure that you are displaying the latest updated time, but not wasting resources on needless repaints within the same second.

Quirk:

Duration begins at the next frame. Let's say for example that it's a very inefficient app and takes 500 milliseconds per frame at 2 fps. The widget / user might want a repaint in next 500 milliseconds. Now, app takes 1000 ms per frame (1 fps) because the backend event timeout takes 500 milliseconds AFTER the vsync swap buffer. So, it's not that we are requesting repaint within X duration. We are rather timing out during app idle time where we are not receiving any new input events.

This repaints the current viewport.

Sourcedef request_repaint_after_for(self, /, seconds: float, viewport_id: ViewportId) -> None§

Request repaint after at most the specified duration elapses.

The backend can chose to repaint sooner, for instance if some other code called this method with a lower duration, or if new events arrived.

The function can be multiple times, but only the smallest duration will be considered. So, if the function is called two times with 1 second and 2 seconds, egui will repaint after 1 second

This is primarily useful for applications who would like to save battery by avoiding wasted redraws when the app is not in focus. But sometimes the GUI of the app might become stale and outdated if it is not updated for too long.

Let's say, something like a stopwatch widget that displays the time in seconds. You would waste resources repainting multiple times within the same second (when you have no input), just calculate the difference of duration between current time and next second change, and call this function, to make sure that you are displaying the latest updated time, but not wasting resources on needless repaints within the same second.

Quirk:

Duration begins at the next frame. Let's say for example that it's a very inefficient app and takes 500 milliseconds per frame at 2 fps. The widget / user might want a repaint in next 500 milliseconds. Now, app takes 1000 ms per frame (1 fps) because the backend event timeout takes 500 milliseconds AFTER the vsync swap buffer. So, it's not that we are requesting repaint within X duration. We are rather timing out during app idle time where we are not receiving any new input events.

This repaints the specified viewport.

Sourcedef request_repaint_after_secs(self, /, seconds: float) -> None§

Repaint after this many seconds.

See egui.Context.request_repaint_after for details.

Sourcedef request_repaint_of(self, /, viewport_id: ViewportId) -> None§

Call this if there is need to repaint the UI, i.e. if you are showing an animation.

If this is called at least once in a frame, then there will be another frame right after this. Call as many times as you wish, only one repaint will be issued.

To request repaint with a delay, use egui.Context.request_repaint_after_for.

If called from outside the UI thread, the UI thread will wake up and run, provided the egui integration has set that up via egui.Context.set_request_repaint_callback (this will work on eframe).

This will repaint the specified viewport.

Sourcedef requested_repaint_last_pass(self, /) -> bool§

Was a repaint requested last pass for the current viewport?

Sourcedef requested_repaint_last_pass_for(self, /, viewport_id: ViewportId) -> bool§

Was a repaint requested last pass for the given viewport?

def screen_rect(self, /) -> Rect§
Sourcedef send_cmd(self, /, command: OutputCommand) -> None§

Add a command to PlatformOutput.commands, for the integration to execute at the end of the frame.

Sourcedef send_viewport_cmd(self, /, command: ViewportCommand) -> None§

Send a command to the current viewport.

This lets you affect the current viewport, e.g. resizing the window.

Sourcedef send_viewport_cmd_to(self, /, viewport_id: ViewportId, command: ViewportCommand) -> None§

Send a command to a specific viewport.

This lets you affect another viewport, e.g. resizing its window.

Sourcedef set_cursor_icon(self, /, cursor_icon: CursorIcon) -> None§

Set the cursor icon.

Sourcedef set_cursor_image(self, /, image: CustomCursorImage |None) -> None§

Request that the integration display this RGBA bitmap as the OS cursor for the next frame, instead of the standard cursor_icon. Backends that don't support custom cursors (web, eframe with non-winit integrations) silently fall back to the icon.

Pass None to clear and revert to cursor_icon selection.

The integration is expected to dedupe by Arc pointer identity, so reusing the same Arc<[int](https://github.com/emilk/egui/blob/e44f9f60d93bba451c513b3c193f24bd0260f969/crates/egui/src/context.rs#L1872)> across frames is cheap.

Sourcedef set_debug_on_hover(self, /, debug_on_hover: bool) -> None§

Turn on/off whether or not to debug widget layout on hover.

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

Set which widget is being dragged.

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

If True, egui.Context.show_viewport_deferred and egui.Context.show_viewport_immediate will embed the new viewports inside the existing one, instead of spawning a new native window.

eframe sets this to False on supported platforms, but the default value is True.

Sourcedef set_fonts(self, /, font_definitions: FontDefinitions) -> None§

Tell egui which fonts to use.

The default egui fonts only support latin and cyrillic alphabets, but you can call this to install additional fonts that support e.g. korean characters.

The new fonts will become active at the start of the next pass. This will overwrite the existing fonts.

These fonts will be used before any system fallback.

Sourcedef set_global_style(self, /, style: Style) -> None§

The currently active Style used by all new popups, menus, etc.

Use egui.Context.all_styles_mut to mutate both dark and light mode styles.

You can also change this using egui.Context.global_style_mut.

You can use Ui.style_mut to change the style of a single Ui.

Sourcedef set_os(self, /, os: OperatingSystem) -> None§

Set the operating system we are running on.

If you are writing wasm-based integration for egui you may want to set this based on e.g. the user-agent.

Sourcedef set_pixels_per_point(self, /, pixels_per_point: float) -> None§

Set the number of physical pixels for each logical point. Will become active at the start of the next pass.

This will actually translate to a call to egui.Context.set_zoom_factor.

def set_request_repaint_handler(self, /, handler: Any) -> None§
def set_style(self, /, style: Style) -> None§
Sourcedef set_style_of(self, /, theme: Theme, style: Style) -> None§

The Style used by all new popups, menus, etc. Use egui.Context.set_theme to choose between dark and light mode.

You can also change this using egui.Context.style_mut_of.

You can use Ui.style_mut to change the style of a single Ui.

Sourcedef set_sublayer(self, /, parent: LayerId, child: LayerId) -> None§

Mark the child layer as a sublayer of parent.

Sublayers are moved directly above the parent layer at the end of the frame. This is mainly intended for adding a new egui.Area inside a egui.Window.

This currently only supports one level of nesting. If parent is a sublayer of another layer, the behavior is unspecified.

Sourcedef set_theme(self, /, theme_preference: ThemePreference) -> None§

The Theme used to select between dark and light egui.Context.global_style as the active style used by all subsequent popups, menus, etc.

Sourcedef set_transform_layer(self, /, layer_id: LayerId, transform: TSTransform) -> None§

Transform the graphics of the given layer.

This will also affect input. The direction of the given transform is "into the global coordinate system".

This is a sticky setting, remembered from one frame to the next.

Can be used to implement pan and zoom (see relevant demo).

For a temporary transform, use egui.Context.transform_layer_shapes or Ui.with_visual_transform.

Sourcedef set_visuals(self, /, visuals: Visuals) -> None§

The egui.Visuals used by all subsequent popups, menus, etc.

You can also use Ui.visuals_mut to change the visuals of a single Ui.

Sourcedef set_visuals_of(self, /, theme: Theme, visuals: Visuals) -> None§

The egui.Visuals used by all subsequent popups, menus, etc.

You can also use Ui.visuals_mut to change the visuals of a single Ui.

Sourcedef set_zoom_factor(self, /, zoom_factor: float) -> None§

Sets zoom factor of the UI. Will become active at the start of the next pass.

Note that calling this will not update egui.Context.zoom_factor until the end of the pass.

This is used to calculate the pixels_per_point for the UI as pixels_per_point = zoom_fator * native_pixels_per_point.

The default is 1.0. Make larger to make everything larger.

It is better to call this than modifying Options.zoom_factor.

Sourcedef settings_ui(self, /, ui: Ui) -> None§

Show a ui for settings (style and tessellation options).

Sourcedef show_viewport_immediate(self, /, viewport_id: ViewportId, builder: ViewportBuilder, add_contents: Any) -> ViewportClass§

Show an immediate viewport, creating a new native window, if possible.

This is the easier type of viewport to use, but it is less performant as it requires both parent and child to repaint if any one of them needs repainting, which effectively produce double work for two viewports, and triple work for three viewports, etc. To avoid this, use egui.Context.show_viewport_deferred instead.

The given id must be unique for each viewport.

You need to call this each pass when the child viewport should exist.

You can check if the user wants to close the viewport by checking the egui.ViewportInfo.close_requested flags found in egui.InputState.viewport.

The given ui function will be called immediately. This may only be called on the main thread. This call will pause the current viewport and render the child viewport in its own window. This means that the child viewport will not be repainted when the parent viewport is repainted, and vice versa.

If Context.embed_viewports is True (e.g. if the current egui backend does not support multiple viewports), the given callback will be called immediately, embedding the new viewport in the current one, inside of a egui.Window. You can know by checking for ViewportClass.EmbeddedWindow.

See egui.viewport for more information about viewports.

Sourcedef stop_dragging(self, /) -> None§

Stop dragging any widget.

def style(self, /) -> Style§
def style_mut(self, /) -> Any§
Sourcedef style_mut_of(self, /, theme: Theme) -> Any§

Mutate the Style used by all subsequent popups, menus, etc.

Sourcedef style_of(self, /, theme: Theme) -> Style§

The Style used by all subsequent popups, menus, etc.

Sourcedef style_ui(self, /, ui: Ui, theme: Theme) -> None§

Edit the Style.

Sourcedef system_theme(self, /) -> Theme |None§

Does the OS use dark or light mode? This is used when the theme preference is set to egui.ThemePreference.System.

Sourcedef tessellate(self, /, shapes: Sequence[ClippedShape], pixels_per_point: float) -> list[ClippedPrimitive]§

Tessellate the given shapes into triangle meshes.

pixels_per_point is used for feathering (anti-aliasing). For this you can use FullOutput.pixels_per_point, egui.Context.pixels_per_point, or whatever is appropriate for your viewport.

Sourcedef tessellation_options(self, /) -> TessellationOptions§

Read-only access to TessellationOptions.

Sourcedef tessellation_options_mut(self, /) -> Any§

Read-write access to TessellationOptions.

Sourcedef text_edit_focused(self, /) -> bool§

Is the currently focused widget a text edit?

Sourcedef texture_ui(self, /, ui: Ui) -> None§

Show stats about the allocated textures.

Sourcedef theme(self, /) -> Theme§

The Theme used to select the appropriate Style (dark or light) used by all subsequent popups, menus, etc.

Sourcedef time(self, /) -> float§

Current time in seconds, relative to some unknown epoch.

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

Retrieve the LayerId of the top level windows.

Sourcedef transform_layer_shapes(self, /, layer_id: LayerId, transform: TSTransform) -> None§

Transform all the graphics at the given layer.

Is used to implement drag-and-drop preview.

This only applied to the existing graphics at the layer, not to new graphics added later.

For a persistent transform, use egui.Context.set_transform_layer instead.

Sourcedef try_load_bytes(self, /, uri: str) -> BytesPoll§

Try loading the bytes from the given uri using any available bytes loaders.

Loaders are expected to cache results, so that this call is immediate-mode safe.

This calls the loaders one by one in the order in which they were registered. If a loader returns LoadError.NotSupportednot_supported, then the next loader is called. This process repeats until all loaders have been exhausted, at which point this returns LoadError.NotSupportednot_supported.

Errors

This may fail with: - LoadError.NotSupportednot_supported if none of the registered loaders support loading the given uri. - LoadError.Loadingcustom if one of the loaders does support loading the uri, but the loading process failed.

⚠ May deadlock if called from within a BytesLoader!

not_supported: crate::load::LoadError::NotSupported custom: crate::load::LoadError::Loading

Sourcedef try_load_image(self, /, uri: str, size_hint: SizeHint) -> ImagePoll§

Try loading the image from the given uri using any available image loaders.

Loaders are expected to cache results, so that this call is immediate-mode safe.

This calls the loaders one by one in the order in which they were registered. If a loader returns LoadError.NotSupportednot_supported, then the next loader is called. This process repeats until all loaders have been exhausted, at which point this returns LoadError.NotSupportednot_supported.

Errors

This may fail with: - LoadError.NoImageLoadersno_image_loaders if tbere are no registered image loaders. - LoadError.NotSupportednot_supported if none of the registered loaders support loading the given uri. - LoadError.Loadingcustom if one of the loaders does support loading the uri, but the loading process failed.

⚠ May deadlock if called from within an ImageLoader!

no_image_loaders: crate::load::LoadError::NoImageLoaders not_supported: crate::load::LoadError::NotSupported custom: crate::load::LoadError::Loading

Sourcedef try_load_texture(self, /, uri: str, texture_options: TextureOptions, size_hint: SizeHint) -> TexturePoll§

Try loading the texture from the given uri using any available texture loaders.

Loaders are expected to cache results, so that this call is immediate-mode safe.

This calls the loaders one by one in the order in which they were registered. If a loader returns LoadError.NotSupportednot_supported, then the next loader is called. This process repeats until all loaders have been exhausted, at which point this returns LoadError.NotSupportednot_supported.

Errors

This may fail with: - LoadError.NotSupportednot_supported if none of the registered loaders support loading the given uri. - LoadError.Loadingcustom if one of the loaders does support loading the uri, but the loading process failed.

⚠ May deadlock if called from within a TextureLoader!

not_supported: crate::load::LoadError::NotSupported custom: crate::load::LoadError::Loading

def used_rect(self, /) -> Rect§
def used_size(self, /) -> Vec2§
Sourcedef viewport(self, /) -> ViewportInfo§

Read the state of the current viewport.

Sourcedef viewport_for(self, /, viewport_id: ViewportId) -> ViewportInfo§

Read the state of a specific current viewport.

Sourcedef viewport_id(self, /) -> ViewportId§

Return the ViewportId of the current viewport.

If this is the root viewport, this will return ViewportId.ROOT.

Don't use this outside of egui.Context.run, or after egui.Context.end_pass.

Sourcedef viewport_rect(self, /) -> Rect§

Returns the position and size of the full area available to egui

This includes reas that might be partially covered by, for example, the OS status bar or display notches. See egui.Context.content_rect to get a rect that is safe for content.

This rectangle includes e.g. the dynamic island on iOS. If you want to only render below the that (not behind), then you should use egui.Context.content_rect instead.

See also RawInput.safe_area_insets.

def visuals_of(self, /, theme: Theme) -> Visuals§
def wants_keyboard_input(self, /) -> bool§
def wants_pointer_input(self, /) -> bool§
Sourcedef will_discard(self, /) -> bool§

Will the visual output of this pass be discarded?

If true, you can early-out from expensive graphics operations.

See egui.Context.request_discard for more.

Sourcedef zoom_factor(self, /) -> float§

Global zoom factor of the UI.

This is used to calculate the pixels_per_point for the UI as pixels_per_point = zoom_factor * native_pixels_per_point.

The default is 1.0. Make larger to make everything larger.