S or /

SourceClass Window

from egui import Window
class Window:

Builder for a floating window which can be dragged, closed, collapsed, resized and scrolled (off by default).

You can customize: * title * default, minimum, maximum and/or fixed size, collapsed/expanded * if the window has a scroll area (off by default) * if the window can be collapsed (minimized) to just the title bar (yes, by default) * if there should be a close button (none by default)

The previous rectangle used by this window can be obtained through egui.Memory.area_rect().

Note that this is NOT a native OS window. To create a new native OS window, use egui.Context.show_viewport_deferred.

Methods§

Sourcedef anchor(self, /, anchor: Align2, offset: Vec2) -> Window§

Set anchor and distance.

An anchor of Align2.RIGHT_TOP means "put the right-top corner of the window in the right-top corner of the screen".

The offset is added to the position, so e.g. an offset of [-5.0, 5.0] would move the window left and down from the given anchor.

Anchoring also makes the window immovable.

It is an error to set both an anchor and a position.

Sourcedef auto_sized(self, /) -> Window§

Not resizable, just takes the size of its contents. Also disabled scrolling. Text will not wrap, but will instead make your window width expand.

Sourcedef collapsible(self, /, collapsible: bool) -> Window§

Can the window be collapsed by clicking on its title?

Sourcedef constrain(self, /, constrain: bool) -> Window§

Constrains this window to Context.content_rect.

To change the area to constrain to, use egui.Window.constrain_to.

Default: True.

Sourcedef constrain_to(self, /, rect: Rect) -> Window§

Constrain the movement of the window to the given rectangle.

For instance: .constrain_to(ctx.content_rect()).

Sourcedef current_pos(self, /, pos: Pos2) -> Window§

Set current position of the window. If the window is movable it is up to you to keep track of where it moved to!

Sourcedef default_height(self, /, height: float) -> Window§

Set initial height of the window.

Sourcedef default_open(self, /, default_open: bool) -> Window§

Set initial collapsed state of the window

Sourcedef default_pos(self, /, pos: Pos2) -> Window§

Set initial position of the window.

Sourcedef default_rect(self, /, rect: Rect) -> Window§

Set initial position and size of the window.

Sourcedef default_size(self, /, size: Vec2) -> Window§

Set initial size of the window.

The size refers to the outer window size, including frame margins, stroke, and the title bar.

Sourcedef default_width(self, /, width: float) -> Window§

Set initial width of the window.

Sourcedef drag_area(self, /, drag_area: WindowDrag) -> Window§

Where the user can grab the window to move it.

Defaults to WindowDrag.OnTouch: drag anywhere on touch screens, title bar only otherwise. See WindowDrag for details.

egui.Window.movable(False) forces WindowDrag.Off regardless of this setting. Windows without a title bar (see egui.Window.title_bar) fall back to WindowDrag.Anywhere.

Sourcedef drag_to_scroll(self, /, drag_to_scroll: DragScroll) -> Window§

Controls scrolling the window by dragging the contents with the pointer.

Defaults to DragScroll.OnTouch — only active when a touch screen is detected.

See ScrollArea.scroll_source and DragScroll for more.

Sourcedef enabled(self, /, enabled: bool) -> Window§

If False the window will be grayed out and non-interactive.

Sourcedef fade_in(self, /, fade_in: bool) -> Window§

If True, quickly fade in the Window when it first appears.

Default: True.

Sourcedef fade_out(self, /, fade_out: bool) -> Window§

If True, quickly fade out the Window when it closes.

This only works if you use egui.Window.open to close the window.

Default: True.

Sourcedef fixed_pos(self, /, pos: Pos2) -> Window§

Sets the window position and prevents it from being dragged around.

Sourcedef fixed_rect(self, /, rect: Rect) -> Window§

Sets the window pos and size and prevents it from being moved and resized by dragging its edges.

Sourcedef fixed_size(self, /, size: Vec2) -> Window§

Sets the window size and prevents it from being resized by dragging its edges.

The size refers to the outer window size, including the frame's inner_margin, outer_margin, stroke, and the title bar.

Sourcedef frame(self, /, frame: Frame) -> Window§

Change the background color, margins, etc.

Source@staticmethod def from_viewport(id: ViewportId, viewport: ViewportBuilder) -> Window§

Construct a Window that follows the given viewport.

Sourcedef hscroll(self, /, hscroll: bool) -> Window§

Enable/disable horizontal scrolling. False by default.

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

Assign a unique id to the Window. Required if the title changes, or is shared with another window.

Sourcedef interactable(self, /, interactable: bool) -> Window§

If false, clicks goes straight through to what is behind us.

Can be used for semi-invisible areas that the user should be able to click through.

Default: True.

Sourcedef max_height(self, /, height: float) -> Window§

Set maximum height of the window.

Sourcedef max_size(self, /, size: Vec2) -> Window§

Set maximum size of the window, equivalent to calling both max_width and max_height.

The size refers to the outer window size, including the frame's inner_margin, outer_margin, stroke, and the title bar.

Sourcedef max_width(self, /, width: float) -> Window§

Set maximum width of the window.

Sourcedef min_height(self, /, height: float) -> Window§

Set minimum height of the window.

Sourcedef min_size(self, /, size: Vec2) -> Window§

Set minimum size of the window, equivalent to calling both min_width and min_height.

The size refers to the outer window size, including the frame's inner_margin, outer_margin, stroke, and the title bar.

Sourcedef min_width(self, /, width: float) -> Window§

Set minimum width of the window.

Sourcedef movable(self, /, movable: bool) -> Window§

If False the window will be immovable.

If True, you can move the window by dragging it. Where you can drag to move the window is determined by egui.Window.drag_area.

Sourcedef order(self, /, order: Order) -> Window§

order(Order.Foreground) for a Window that should always be on top

Sourcedef pivot(self, /, pivot: Align2) -> Window§

Where the "root" of the window is.

For instance, if you set this to Align2.RIGHT_TOP then egui.Window.fixed_pos will set the position of the right-top corner of the window.

Default: Align2.LEFT_TOP.

Sourcedef resizable(self, /, resizable: Any) -> Window§

Can the user resize the window by dragging its edges?

Note that even if you set this to False the window may still auto-resize.

You can set the window to only be resizable in one direction by using e.g. [True, False] as the argument, making the window only resizable in the x-direction.

Default is True.

Sourcedef resize(self, /, resize: Resize) -> Window§
Sourcedef scroll(self, /, scroll: Any) -> Window§

Enable/disable horizontal/vertical scrolling. False by default.

You can pass in False, True, [False, True] etc.

Sourcedef scroll_bar_visibility(self, /, visibility: ScrollBarVisibility) -> Window§

Sets the ScrollBarVisibility of the window.

Sourcedef show(self, /, target: Any) -> Any§

Returns None if the window is not open (if Window.open was called with False). Returns Some(InnerResponse { inner: None }) if the window is collapsed.

def show_open(self, /, target: Any, open: Mutable) -> Any§
Sourcedef title_bar(self, /, with_title_bar: bool) -> Window§

Show title bar on top of the window? If False, the window will not be collapsible nor have a close-button.

Sourcedef vscroll(self, /, vscroll: bool) -> Window§

Enable/disable vertical scrolling. False by default.