SourceClass Ui
from egui import Uiclass Ui:This is what you use to place widgets.
Represents a region of the screen with a type of layout (horizontal or vertical).
Examples
import egui
async def draw(ui: egui.Ui):
ui.label("Hello world!")
ui.separator()
async with ui.horizontal() as row:
row.label("Same row")
if row.button("Click me").clicked():
print("Clicked")Properties§
@property
def shown(self, /) -> bool§
@property
def ui(self, /) -> Ui§
Methods§
Sourcedef add(self, /, widget: Any) -> Response§
Add a Widget to this Ui at a location dependent on the current Layout.
The returned Response can be used to check for interactions,
as well as adding tooltips using Response.on_hover_text.
See also egui.Ui.add_sized, egui.Ui.place and egui.Ui.put.
Sourcedef add_enabled(self, /, enabled: bool, widget: Any) -> Response§
Add a single Widget that is possibly disabled, i.e. greyed out and non-interactive.
If you call add_enabled from within an already disabled Ui,
the widget will always be disabled, even if the enabled argument is true.
See also egui.Ui.add_enabled_ui and egui.Ui.is_enabled.
Sourcedef add_enabled_ui(self, /, enabled: bool) -> Any§
Add a section that is possibly disabled, i.e. greyed out and non-interactive.
If you call add_enabled_ui from within an already disabled Ui,
the result will always be disabled, even if the enabled argument is true.
See also egui.Ui.add_enabled and egui.Ui.is_enabled.
Example
Sourcedef add_sized(self, /, max_size: Vec2, widget: Any) -> Response§
Add a Widget to this Ui with a given size.
The widget will attempt to fit within the given size, but some widgets may overflow.
To fill all remaining area, use ui.add_sized(ui.available_size(), widget);
See also egui.Ui.add, egui.Ui.place and egui.Ui.put.
Sourcedef add_space(self, /, amount: float) -> None§
Add extra space before the next widget.
The direction is dependent on the layout.
Note that add_space isn't supported when in a grid layout.
This will be in addition to the egui.style.Spacing.item_spacing
that is always added, but item_spacing won't be added again by add_space.
egui.Ui.min_rect will expand to contain the space.
Sourcedef add_visible(self, /, visible: bool, widget: Any) -> Response§
Add a single Widget that is possibly invisible.
An invisible widget still takes up the same space as if it were visible.
If you call add_visible from within an already invisible Ui,
the widget will always be invisible, even if the visible argument is true.
See also egui.Ui.set_invisible and egui.Ui.is_visible.
def add_visible_ui(self, /, visible: bool) -> Any§
Sourcedef advance_cursor_after_rect(self, /, rect: Rect) -> Id§
Allocate a rect without interacting with it.
Sourcedef allocate_at_least(self, /, desired_size: Vec2, sense: Sense) -> tuple[Rect, Response]§
Allocate at least as much space as needed, and interact with that rect.
The returned Rect will be the same size as Response.rect.
Sourcedef allocate_exact_size(self, /, desired_size: Vec2, sense: Sense) -> tuple[Rect, Response]§
def allocate_new_ui(self, /, ui_builder: UiBuilder) -> Any§
Sourcedef allocate_painter(self, /, desired_size: Vec2, sense: Sense) -> tuple[Response, Painter]§
Convenience function to get a region to paint on.
Note that egui uses screen coordinates for everything.
Sourcedef allocate_rect(self, /, rect: Rect, sense: Sense) -> Response§
Sourcedef allocate_response(self, /, desired_size: Vec2, sense: Sense) -> Response§
Allocate space for a widget and check for interaction in the space.
Returns a Response which contains a rectangle, id, and interaction info.
How sizes are negotiated
Each widget should have a minimum desired size and a desired size.
When asking for space, ask AT LEAST for your minimum, and don't ask for more than you need.
If you want to fill the space, ask about Ui.available_size and use that.
You may get MORE space than you asked for, for instance for justified layouts, like in menus.
You will never get a rectangle that is smaller than the amount of space you asked for.
Sourcedef allocate_space(self, /, desired_size: Vec2) -> tuple[Id, Rect]§
Reserve this much space and move the cursor. Returns where to put the widget.
How sizes are negotiated
Each widget should have a minimum desired size and a desired size.
When asking for space, ask AT LEAST for your minimum, and don't ask for more than you need.
If you want to fill the space, ask about Ui.available_size and use that.
You may get MORE space than you asked for, for instance for justified layouts, like in menus.
You will never get a rectangle that is smaller than the amount of space you asked for.
Returns an automatic Id (which you can use for interaction) and the Rect of where to put your widget.
Sourcedef allocate_ui(self, /, desired_size: Vec2) -> Any§
Allocated the given space and then adds content to that space.
If the contents overflow, more space will be allocated.
When finished, the amount of space actually used (min_rect) will be allocated.
So you can request a lot of space and then use less.
def allocate_ui_at_rect(self, /, max_rect: Rect) -> Any§
Sourcedef auto_id_with(self, /, id_salt: str) -> Id§
Same as ui.next_auto_id().with(id_salt).
Like egui.Ui.next_auto_id, this is NOT stable over time.
Sourcedef available_height(self, /) -> float§
The available height at the moment, given the current cursor.
See egui.Ui.available_size for more information.
Sourcedef available_rect_before_wrap(self, /) -> Rect§
In case of a wrapping layout, how much space is left on this row/column?
If the layout does not wrap, this will return the same value as egui.Ui.available_size.
Sourcedef available_size(self, /) -> Vec2§
The available space at the moment, given the current cursor.
This how much more space we can take up without overflowing our parent. Shrinks as widgets allocate space and the cursor moves. A small size should be interpreted as "as little as possible". An infinite size should be interpreted as "as much as you want".
Sourcedef available_size_before_wrap(self, /) -> Vec2§
In case of a wrapping layout, how much space is left on this row/column?
If the layout does not wrap, this will return the same value as egui.Ui.available_size.
Sourcedef available_width(self, /) -> float§
The available width at the moment, given the current cursor.
See egui.Ui.available_size for more information.
Sourcedef button(self, /, button: Any) -> Response§
Sourcedef checkbox(self, /, checked: Mutable, text: Any) -> Response§
Show a checkbox.
See also egui.Ui.toggle_value.
Sourcedef clip_rect(self, /) -> Rect§
Screen-space rectangle for clipping what we paint in this ui. This is used, for instance, to avoid painting outside a window that is smaller than its contents.
Sourcedef close(self, /) -> None§
Find and close the first closable parent.
Use UiBuilder.closable to make a Ui closable.
You can then use Ui.should_close to check if it should be closed.
This is implemented for all egui containers, e.g. egui.Popup, egui.Modal,
egui.Area, egui.Window, egui.CollapsingHeader, etc.
What exactly happens when you close a container depends on the container implementation.
egui.Area e.g. will return true from its Response.should_close method.
If you want to close a specific kind of container, use Ui.close_kind instead.
Also note that this won't bubble up across egui.Areas. If needed, you can check
response.should_close() and close the parent manually. (menu does this for example).
See also:
- Ui.close_kind
- Ui.should_close
- Ui.will_parent_close
Sourcedef close_kind(self, /, ui_kind: UiKind) -> None§
Find and close the first closable parent of a specific UiKind.
This is useful if you want to e.g. close a egui.Window. Since it contains a
Collapsible, Ui.close would close the Collapsible instead.
You can close the egui.Window by calling ui.close_kind(UiKind.Window).
See also:
- Ui.close
- Ui.should_close
- Ui.will_parent_close
Sourcedef code(self, /, text: Any) -> Response§
Show text as monospace with a gray background.
Shortcut for ui.label(RichText.new(text).code())
Sourcedef code_editor(self, /, text: Mutable) -> Response§
A TextEdit for code editing.
This will be multiline, monospace, and will insert tabs instead of moving focus.
See also TextEdit.code_editor.
Sourcedef collapsing(self, /, heading: str) -> Any§
A CollapsingHeader that starts out collapsed.
The name must be unique within the current parent,
or you need to use CollapsingHeader.id_salt.
Sourcedef color_edit_button_hsva(self, /, hsva: Hsva) -> Response§
Shows a button with the given color.
If the user clicks the button, a full color picker is shown.
Sourcedef color_edit_button_rgb(self, /, rgb: Mutable) -> Response§
Shows a button with the given color.
If the user clicks the button, a full color picker is shown. The given color is in linear RGB space.
Sourcedef color_edit_button_rgba_premultiplied(self, /, rgba: Mutable) -> Response§
Shows a button with the given color.
If the user clicks the button, a full color picker is shown. The given color is in linear RGBA space with premultiplied alpha
Sourcedef color_edit_button_rgba_unmultiplied(self, /, rgba: Mutable) -> Response§
Shows a button with the given color.
If the user clicks the button, a full color picker is shown. The given color is in linear RGBA space without premultiplied alpha. If unsure, what "premultiplied alpha" is, then this is probably the function you want to use.
Sourcedef color_edit_button_srgb(self, /, srgb: Mutable) -> Response§
Shows a button with the given color.
If the user clicks the button, a full color picker is shown.
The given color is in sRGB space.
Sourcedef color_edit_button_srgba(self, /, srgba: Color32) -> Response§
Shows a button with the given color.
If the user clicks the button, a full color picker is shown.
Sourcedef color_edit_button_srgba_premultiplied(self, /, srgba: Mutable) -> Response§
Shows a button with the given color.
If the user clicks the button, a full color picker is shown.
The given color is in sRGBA space with premultiplied alpha
Sourcedef color_edit_button_srgba_unmultiplied(self, /, srgba: Mutable) -> Response§
Shows a button with the given color.
If the user clicks the button, a full color picker is shown.
The given color is in sRGBA space without premultiplied alpha.
If unsure what "premultiplied alpha" is, then this is probably the function you want to use.
Sourcedef colored_label(self, /, color: Color32, text: Any) -> Response§
Show colored text.
Shortcut for ui.label(RichText.new(text).color(color))
Sourcedef columns(self, /, num_columns: int) -> Any§
Temporarily split a Ui into several columns.
Sourcedef ctx(self, /) -> Context§
Get a reference to the parent Context.
Sourcedef cursor(self, /) -> Rect§
Where the next widget will be put.
One side of this will always be infinite: the direction in which new widgets will be added.
The opposing side is what is incremented.
The crossing sides are initialized to max_rect.
So one can think of cursor as a constraint on the available region.
If something has already been added, this will point to style.spacing.item_spacing beyond the latest child.
The cursor can thus be style.spacing.item_spacing pixels outside of the min_rect.
def data(self, /) -> Any§
def data_mut(self, /) -> Any§
Sourcedef debug_paint_cursor(self, /) -> None§
Shows where the next widget is going to be placed
Sourcedef disable(self, /) -> None§
Calling disable() will cause the Ui to deny all future interaction
and all the widgets will draw with a gray look.
Usually it is more convenient to use egui.Ui.add_enabled_ui or egui.Ui.add_enabled.
Note that once disabled, there is no way to re-enable the Ui.
Example
Sourcedef dnd_drag_source(self, /, id: Id, payload: Any) -> Any§
Create something that can be drag-and-dropped.
The id needs to be globally unique.
The payload is what will be dropped if the user starts dragging.
In contrast to Response.dnd_set_drag_payload,
this function will paint the widget at the mouse cursor while the user is dragging.
Sourcedef dnd_drop_zone(self, /, frame: Frame) -> Any§
Surround the given ui with a frame which changes colors when you can drop something onto it.
Returns the dropped item, if it was released this frame.
The given frame is used for its margins, but the color is ignored.
Sourcedef drag_angle(self, /, radians: Mutable) -> Response§
Modify an angle. The given angle should be in radians, but is shown to the user in degrees. The angle is NOT wrapped, so the user may select, for instance 720° = 2𝞃 = 4π
Sourcedef drag_angle_tau(self, /, radians: Mutable) -> Response§
Modify an angle. The given angle should be in radians, but is shown to the user in fractions of one Tau (i.e. fractions of one turn). The angle is NOT wrapped, so the user may select, for instance 2𝞃 (720°)
def drag_value(self, /, value: Mutable, speed: float |None, prefix: str |None, suffix: str |None) -> Response§
Sourcedef end_row(self, /) -> None§
Move to the next row in a grid layout or wrapping layout. Otherwise does nothing.
Sourcedef expand_to_include_rect(self, /, rect: Rect) -> None§
Expand the min_rect and max_rect of this ui to include a child at the given rect.
Sourcedef expand_to_include_x(self, /, x: float) -> None§
Ensure we are big enough to contain the given x-coordinate. This is sometimes useful to expand a ui to stretch to a certain place.
Sourcedef expand_to_include_y(self, /, y: float) -> None§
Ensure we are big enough to contain the given y-coordinate. This is sometimes useful to expand a ui to stretch to a certain place.
def fonts(self, /) -> Any§
Sourcedef group(self, /) -> Any§
Put into a Frame.group, visually grouping the contents together
See also egui.Ui.scope.
Sourcedef heading(self, /, text: Any) -> Response§
Show large text.
Shortcut for ui.label(RichText.new(text).heading())
Sourcedef horizontal(self, /) -> Any§
Start a ui with horizontal layout. After you have called this, the function registers the contents as any other widget.
Elements will be centered on the Y axis, i.e.
adjusted up and down to lie in the center of the horizontal layout.
The initial height is style.spacing.interact_size.y.
Centering is almost always what you want if you are
planning to mix widgets or use different types of text.
If you don't want the contents to be centered, use egui.Ui.horizontal_top instead.
The returned Response will only have checked for mouse hover
but can be used for tooltips (on_hover_text).
It also contains the Rect used by the horizontal layout.
See also egui.Ui.with_layout for more options.
Sourcedef horizontal_centered(self, /) -> Any§
Like egui.Ui.horizontal, but allocates the full vertical height and then centers elements vertically.
Sourcedef horizontal_top(self, /) -> Any§
Like egui.Ui.horizontal, but aligns content with top.
Sourcedef horizontal_wrapped(self, /) -> Any§
Start a ui with horizontal layout that wraps to a new row
when it reaches the right edge of the max_size.
After you have called this, the function registers the contents as any other widget.
Elements will be centered on the Y axis, i.e.
adjusted up and down to lie in the center of the horizontal layout.
The initial height is style.spacing.interact_size.y.
Centering is almost always what you want if you are
planning to mix widgets or use different types of text.
The returned Response will only have checked for mouse hover
but can be used for tooltips (on_hover_text).
It also contains the Rect used by the horizontal layout.
See also egui.Ui.with_layout for more options.
Sourcedef hyperlink(self, /, url: str) -> Response§
Sourcedef hyperlink_to(self, /, label: Any, url: str) -> Response§
Shortcut for add(Hyperlink.from_label_and_url(label, url)).
See also Hyperlink.
Sourcedef id(self, /) -> Id§
Renamed to egui.Ui.scope_id.
Sourcedef image(self, /, source: Any) -> Response§
Show an image available at the given uri.
⚠ This will do nothing unless you install some image loaders first!
The easiest way to do this is via egui_extras.install_image_loaders.
The loaders handle caching image data, sampled textures, etc. across frames, so calling this is immediate-mode safe.
Using egui.include_image is often the most ergonomic, and the path
will be resolved at compile-time and embedded in the binary.
When using a "file://" url on the other hand, you need to make sure
the files can be found in the right spot at runtime!
See also egui.Image, egui.ImageSource.
Sourcedef indent(self, /, id_salt: str) -> Any§
def indent_with(self, /, id_salt: str) -> Any§
def input(self, /) -> Any§
def input_mut(self, /) -> Any§
Sourcedef interact(self, /, rect: Rect, id: Id, sense: Sense) -> Response§
Check for clicks, drags and/or hover on a specific region of this Ui.
def interact_bg(self, /, sense: Sense) -> Response§
Sourcedef interact_opt(self, /, rect: Rect, id: Id, sense: Sense, options: InteractOptions) -> Response§
Check for clicks, drags and/or hover on a specific region of this Ui.
def interact_with_hovered(self, /, rect: Rect, contains_pointer: bool, id: Id, sense: Sense) -> Response§
Sourcedef is_enabled(self, /) -> bool§
If False, the Ui does not allow any interaction and
the widgets in it will draw with a gray look.
Sourcedef is_rect_visible(self, /, rect: Rect) -> bool§
Can be used for culling: if False, then no part of rect will be visible on screen.
This is false if the whole Ui is invisible (see UiBuilder.invisible)
or if Context.will_discard is true.
Sourcedef is_sizing_pass(self, /) -> bool§
Set to true in special cases where we do one frame where we size up the contents of the Ui, without actually showing it.
Sourcedef is_tooltip(self, /) -> bool§
Is this Ui in a tooltip?
Sourcedef is_visible(self, /) -> bool§
If False, any widgets added to the Ui will be invisible and non-interactive.
This is False if any parent had UiBuilder.invisible
or if Context.will_discard.
Sourcedef label(self, /, text: Any) -> Response§
Sourcedef layer_id(self, /) -> LayerId§
Use this to paint stuff within this Ui.
Sourcedef layout(self, /) -> Layout§
Read the Layout.
Sourcedef link(self, /, text: Any) -> Response§
Sourcedef make_persistent_id(self, /, id_salt: str) -> Id§
Generate an Id for a widget that has persistent state in Memory.
This is the same as ui.scope_id().with(id_salt).
Since it is based on the stable egui.Ui.scope_id, it is stable over time,
as long as id_salt is unique within the current id scope.
Sourcedef max_rect(self, /) -> Rect§
New widgets will try to fit within this rectangle.
Text labels will wrap to fit within max_rect.
Separator lines will span the max_rect.
If a new widget doesn't fit within the max_rect then the
Ui will make room for it by expanding both min_rect and max_rect.
def memory(self, /) -> Any§
def memory_mut(self, /) -> Any§
Sourcedef min_rect(self, /) -> Rect§
Sourcedef min_size(self, /) -> Vec2§
Size of content; same as min_rect().size()
Sourcedef monospace(self, /, text: Any) -> Response§
Show monospace (fixed width) text.
Shortcut for ui.label(RichText.new(text).monospace())
Sourcedef multiply_opacity(self, /, opacity: float) -> None§
Like egui.Ui.set_opacity, but multiplies the given value with the current opacity.
See also: egui.Ui.set_opacity and egui.Ui.opacity.
Sourcedef new_child(self, /, ui_builder: UiBuilder) -> Ui§
Create a child Ui with the properties of the given builder.
This is a very low-level function.
Usually you are better off using egui.Ui.scope_builder.
Note that calling this does not allocate any space in the parent Ui,
so after adding widgets to the child Ui you probably want to allocate
the Ui.min_rect of the child in the parent Ui using e.g.
Ui.advance_cursor_after_rect.
Sourcedef next_auto_id(self, /) -> Id§
The Id that will be assigned to the next widget added to this Ui,
unless it has an explicit Id.
This is based on the egui.Ui.unique_id of this Ui and the number of widgets added so far.
It is therefore NOT stable: it changes if widgets are added or removed before it.
Do not use it for widgets that store state; use egui.Ui.make_persistent_id for that.
Sourcedef next_widget_position(self, /) -> Pos2§
Where do we expect a zero-sized widget to be placed?
Sourcedef opacity(self, /) -> float§
Read the current opacity of the underlying painter.
See also: egui.Ui.set_opacity and egui.Ui.multiply_opacity.
def output(self, /) -> Any§
def output_mut(self, /) -> Any§
Sourcedef painter(self, /) -> Painter§
Use this to paint stuff within this Ui.
Sourcedef painter_at(self, /, rect: Rect) -> Painter§
Sourcedef pixels_per_point(self, /) -> float§
Number of physical pixels for each logical UI point.
Sourcedef place(self, /, max_rect: Rect, widget: Any) -> Response§
Add a Widget to this Ui at a specific location (manual layout) without
affecting this Uis cursor.
See also egui.Ui.add and egui.Ui.add_sized and egui.Ui.put.
def progress_bar(self, /, progress: float, text: str |None) -> Response§
Sourcedef push_id(self, /, id_salt: str) -> Any§
Create a child Ui with an explicit Id.
def push_stack_info(self, /, ui_stack_info: UiStackInfo) -> Any§
Sourcedef put(self, /, max_rect: Rect, widget: Any) -> Response§
Add a Widget to this Ui at a specific location (manual layout) and advance the
cursor after the widget.
See also egui.Ui.add, egui.Ui.add_sized, and egui.Ui.place.
Sourcedef radio(self, /, selected: bool, text: Any) -> Response§
Show a RadioButton.
Often you want to use egui.Ui.radio_value instead.
Sourcedef radio_value(self, /, current_value: Mutable, alternative: Any, text: Any) -> Response§
Show a RadioButton. It is selected if *current_value == selected_value.
If clicked, selected_value is assigned to *current_value.
Sourcedef rect_contains_pointer(self, /, rect: Rect) -> bool§
Is the pointer (mouse/touch) above this rectangle in this Ui?
The clip_rect and layer of this Ui will be respected, so, for instance,
if this Ui is behind some other window, this will always return False.
However, this will NOT check if any other widget in the same layer is covering this widget. For that, use Response.contains_pointer instead.
def request_repaint(self, /) -> None§
Sourcedef reset_style(self, /) -> None§
Reset to the default style set in Context.
Sourcedef response(self, /) -> Response§
Read the Ui's background Response.
Its Sense will be based on the UiBuilder.sense used to create this Ui.
The rectangle of the Response (and interactive area) will be egui.Ui.min_rect
of the last pass.
The very first time when the Ui is created, this will return a Response with a
Rect of Rect.NOTHING.
Sourcedef scope(self, /) -> Any§
Create a scoped child ui.
You can use this to temporarily change the Style of a sub-region, for instance:
See also egui.Ui.scope_builder for more options.
Sourcedef scope_builder(self, /, ui_builder: UiBuilder) -> Any§
Create a scoped child ui, inheriting properties from the parent as specified by the UiBuilder.
In contrast to egui.Ui.new_child, this allocates the space used by the child.
See also egui.Ui.scope and egui.Ui.scope_dyn.
Sourcedef scroll_to_cursor(self, /, align: Align |None) -> None§
Adjust the scroll position of any parent egui.ScrollArea so that the cursor (where the next widget goes) becomes visible.
If align is Align.TOP it means "put the top of the rect at the top of the scroll area", etc.
If align is not provided, it'll scroll enough to bring the cursor into view.
See also: Response.scroll_to_me, Ui.scroll_to_rect. Ui.scroll_with_delta.
Sourcedef scroll_to_cursor_animation(self, /, align: Align |None, animation: ScrollAnimation) -> None§
Same as egui.Ui.scroll_to_cursor, but allows you to specify the style.ScrollAnimation.
Sourcedef scroll_to_rect(self, /, rect: Rect, align: Align |None) -> None§
Adjust the scroll position of any parent egui.ScrollArea so that the given Rect becomes visible.
If align is Align.TOP it means "put the top of the rect at the top of the scroll area", etc.
If align is None, it'll scroll enough to bring the cursor into view.
See also: Response.scroll_to_me, Ui.scroll_to_cursor. Ui.scroll_with_delta..
Sourcedef scroll_to_rect_animation(self, /, rect: Rect, align: Align |None, animation: ScrollAnimation) -> None§
Same as egui.Ui.scroll_to_rect, but allows you to specify the style.ScrollAnimation.
Sourcedef scroll_with_delta(self, /, delta: Vec2) -> None§
Scroll this many points in the given direction, in the parent egui.ScrollArea.
The delta dictates how the content (i.e. this UI) should move.
A positive X-value indicates the content is being moved right, as when swiping right on a touch-screen or track-pad with natural scrolling.
A positive Y-value indicates the content is being moved down, as when swiping down on a touch-screen or track-pad with natural scrolling.
If this is called multiple times per frame for the same egui.ScrollArea, the deltas will be summed.
See also: Response.scroll_to_me, Ui.scroll_to_rect, Ui.scroll_to_cursor
Sourcedef scroll_with_delta_animation(self, /, delta: Vec2, animation: ScrollAnimation) -> None§
Same as egui.Ui.scroll_with_delta, but allows you to specify the style.ScrollAnimation.
Sourcedef selectable_label(self, /, checked: bool, text: Any) -> Response§
Show a label which can be selected or not.
See also Button.selectable and egui.Ui.toggle_value.
Sourcedef selectable_value(self, /, current_value: Mutable, selected_value: Any, text: Any) -> Response§
Show selectable text. It is selected if *current_value == selected_value.
If clicked, selected_value is assigned to *current_value.
Example: ui.selectable_value(my_enum, Enum.Alternative, "Alternative").
See also Button.selectable and egui.Ui.toggle_value.
def send_viewport_cmd(self, /, command: ViewportCommand) -> None§
Sourcedef separator(self, /) -> Response§
Shortcut for add(Separator.default())
See also Separator.
Sourcedef set_clip_rect(self, /, clip_rect: Rect) -> None§
Screen-space rectangle for clipping what we paint in this ui. This is used, for instance, to avoid painting outside a window that is smaller than its contents.
Warning: growing the clip rect might cause unexpected results!
When in doubt, use egui.Ui.shrink_clip_rect instead.
def set_enabled(self, /, enabled: bool) -> None§
Sourcedef set_height(self, /, height: float) -> None§
Set both the minimum and maximum height.
Sourcedef set_height_range(self, /, min: float, max: float) -> None§
ui.set_height_range(min..=max); is equivalent to ui.set_min_height(min); ui.set_max_height(max);.
Sourcedef set_invisible(self, /) -> None§
Calling set_invisible() will cause all further widgets to be invisible,
yet still allocate space.
The widgets will not be interactive (set_invisible() implies disable()).
Once invisible, there is no way to make the Ui visible again.
Usually it is more convenient to use egui.Ui.add_visible.
Example
Sourcedef set_max_height(self, /, height: float) -> None§
Set the maximum height of the ui. You won't be able to shrink it below the current minimum size.
Sourcedef set_max_size(self, /, size: Vec2) -> None§
Set the maximum size of the ui. You won't be able to shrink it below the current minimum size.
Sourcedef set_max_width(self, /, width: float) -> None§
Set the maximum width of the ui. You won't be able to shrink it below the current minimum size.
Sourcedef set_min_height(self, /, height: float) -> None§
Set the minimum height of the ui. This can't shrink the ui, only make it larger.
Sourcedef set_min_size(self, /, size: Vec2) -> None§
Set the minimum size of the ui. This can't shrink the ui, only make it larger.
Sourcedef set_min_width(self, /, width: float) -> None§
Set the minimum width of the ui. This can't shrink the ui, only make it larger.
Sourcedef set_opacity(self, /, opacity: float) -> None§
Make the widget in this Ui semi-transparent.
opacity must be between 0.0 and 1.0, where 0.0 means fully transparent (i.e., invisible)
and 1.0 means fully opaque.
Example
See also: egui.Ui.opacity and egui.Ui.multiply_opacity.
Sourcedef set_row_height(self, /, _height: float) -> None§
Set row height in horizontal wrapping layout.
def set_sizing_pass(self, /) -> None§
Sourcedef set_style(self, /, style: Style) -> None§
Changes apply to this Ui and its subsequent children.
To set the style of all Uis, use Context.set_style_of.
def set_visible(self, /, visible: bool) -> None§
Sourcedef set_width(self, /, width: float) -> None§
Set both the minimum and maximum width.
Sourcedef set_width_range(self, /, min: float, max: float) -> None§
ui.set_width_range(min..=max); is equivalent to ui.set_min_width(min); ui.set_max_width(max);.
def set_wrap_mode(self, /, wrap_mode: TextWrapMode) -> None§
Sourcedef should_close(self, /) -> bool§
Was Ui.close called on this Ui or any of its children?
Only works if the Ui was created with UiBuilder.closable.
You can also check via this Ui's Response.should_close.
See also:
- Ui.will_parent_close
- Ui.close
- Ui.close_kind
- Response.should_close
def show_viewport_immediate(self, /, viewport_id: ViewportId, builder: ViewportBuilder) -> Any§
Sourcedef shrink_clip_rect(self, /, new_clip_rect: Rect) -> None§
Constrain the rectangle in which we can paint.
Short for ui.set_clip_rect(ui.clip_rect().intersect(new_clip_rect)).
See also: egui.Ui.clip_rect and egui.Ui.set_clip_rect.
Sourcedef shrink_height_to_current(self, /) -> None§
Helper: shrinks the max height to the current height, so further widgets will try not to be taller than previous widgets.
Sourcedef shrink_width_to_current(self, /) -> None§
Helper: shrinks the max width to the current width, so further widgets will try not to be wider than previous widgets. Useful for normal vertical layouts.
Sourcedef skip_ahead_auto_ids(self, /, count: int) -> None§
Pretend like count widgets have been allocated, advancing egui.Ui.next_auto_id.
def slider(self, /, value: Mutable, min: float, max: float, text: str |None, prefix: str |None, suffix: str |None) -> Response§
Sourcedef small(self, /, text: Any) -> Response§
Show small text.
Shortcut for ui.label(RichText.new(text).small())
Sourcedef small_button(self, /, text: Any) -> Response§
A button as small as normal body text.
Usage: if ui.small_button("Click me").clicked() { … }
Shortcut for add(Button.new(atoms).small())
Sourcedef spacing(self, /) -> Spacing§
The current spacing options for this Ui.
Short for ui.style().spacing.
Sourcedef spacing_mut(self, /) -> Any§
Sourcedef spinner(self, /) -> Response§
Shortcut for add(Spinner.new())
See also Spinner.
Sourcedef strong(self, /, text: Any) -> Response§
Show text that stand out a bit (e.g. slightly brighter).
Shortcut for ui.label(RichText.new(text).strong())
Sourcedef style(self, /) -> Style§
Style options for this Ui and its children.
Note that this may be a different Style than that of Context.global_style.
Sourcedef style_mut(self, /) -> Any§
Mutably borrow internal Style.
Changes apply to this Ui and its subsequent children.
To set the style of all Uis, use Context.set_style_of.
Sourcedef take_available_height(self, /) -> None§
Makes the ui always fill up the available space in the y axis.
This can be useful to call inside a top bottom panel with
resizable == True to make sure the resized space is used.
Sourcedef take_available_space(self, /) -> None§
Makes the ui always fill up the available space.
This can be useful to call inside a panel with resizable == True
to make sure the resized space is used.
Sourcedef take_available_width(self, /) -> None§
Makes the ui always fill up the available space in the x axis.
This can be useful to call inside a side panel with
resizable == True to make sure the resized space is used.
def tessellation_options(self, /) -> TessellationOptions§
def tessellation_options_mut(self, /) -> Any§
Sourcedef text_edit_multiline(self, /, text: Mutable) -> Response§
Sourcedef text_edit_singleline(self, /, text: Mutable) -> Response§
Sourcedef text_style_height(self, /, style: TextStyle) -> float§
The height of text of this text style.
Returns a value rounded to emath.GUI_ROUNDING.
Sourcedef text_valign(self, /) -> Align§
How to vertically align text
Sourcedef toggle_value(self, /, selected: Mutable, text: Any) -> Response§
Acts like a checkbox, but looks like a Button.selectable.
Click to toggle to bool.
See also egui.Ui.checkbox.
Sourcedef ui_contains_pointer(self, /) -> bool§
Is the pointer (mouse/touch) above the current Ui?
Equivalent to ui.rect_contains_pointer(ui.min_rect())
Note that this tests against the current Ui.min_rect.
If you want to test against the final min_rect,
use egui.Ui.response instead.
Sourcedef unique_id(self, /) -> Id§
A globally unique, but unstable, Id of this Ui.
This is NOT stable: it is based on where in the widget hierarchy this Ui is,
so it changes if widgets are added or removed before it.
It should therefore only be used for transient interactions (clicks etc),
never for storing state over time.
For a stable Id to base widget state on, see egui.Ui.scope_id.
Sourcedef vertical(self, /) -> Any§
Start a ui with vertical layout. Widgets will be left-justified.
See also egui.Ui.with_layout for more options.
Sourcedef vertical_centered(self, /) -> Any§
Start a ui with vertical layout. Widgets will be horizontally centered.
Sourcedef vertical_centered_justified(self, /) -> Any§
Start a ui with vertical layout. Widgets will be horizontally centered and justified (fill full width).
Sourcedef visuals(self, /) -> Visuals§
The current visuals settings of this Ui.
Short for ui.style().visuals.
Sourcedef visuals_mut(self, /) -> Any§
Mutably borrow internal visuals.
Changes apply to this Ui and its subsequent children.
To set the visuals of all Uis, use Context.set_visuals_of.
Sourcedef weak(self, /, text: Any) -> Response§
Show text that is weaker (fainter color).
Shortcut for ui.label(RichText.new(text).weak())
Sourcedef will_parent_close(self, /) -> bool§
Will this Ui or any of its parents close this frame?
See also
- Ui.should_close
- Ui.close
- Ui.close_kind
def with_layer_id(self, /, layer_id: LayerId) -> Any§
Sourcedef with_layout(self, /, layout: Layout) -> Any§
The new layout will take up all available space.
If you don't want to use up all available space, use egui.Ui.allocate_ui_with_layout.
See also the helpers egui.Ui.horizontal, egui.Ui.vertical, etc.
Sourcedef with_visual_transform(self, /, transform: TSTransform) -> Any§
Create a new Scope and transform its contents via a emath.TSTransform.
This only affects visuals, inputs will not be transformed. So this is mostly useful
to create visual effects on interactions, e.g. scaling a button on hover / click.
Check out Context.set_transform_layer for a persistent transform that also affects
inputs.
Sourcedef wrap_mode(self, /) -> TextWrapMode§
Which wrap mode should the text use in this Ui?
This is determined first by Style.wrap_mode, and then by the layout of this Ui.