SourceClass ViewportBuilder
from egui import ViewportBuilderclass ViewportBuilder:Control the building of a new egui viewport (i.e. native window).
See egui.viewport for how to build new viewports (native windows).
The fields are public, but you should use the builder pattern to set them, and that's where you'll find the documentation too.
Since egui is immediate mode, ViewportBuilder is accumulative in nature.
Setting any option to None means "keep the current value",
or "Use the default" if it is the first call.
The default values are implementation defined, so you may want to explicitly configure the size of the window, and what buttons are shown.
Properties§
@property
def active(self, /) -> bool |None§
@active.setter
def active(self, /, active: bool |None) -> None§
@property
def app_id(self, /) -> str |None§
@app_id.setter
def app_id(self, /, app_id: str |None) -> None§
@property
def clamp_size_to_monitor_size(self, /) -> bool |None§
@clamp_size_to_monitor_size.setter
def clamp_size_to_monitor_size(self, /, value: bool |None) -> None§
@property
def close_button(self, /) -> bool |None§
@close_button.setter
def close_button(self, /, value: bool |None) -> None§
@property
def decorations(self, /) -> bool |None§
@decorations.setter
def decorations(self, /, decorations: bool |None) -> None§
@property
def drag_and_drop(self, /) -> bool |None§
@drag_and_drop.setter
def drag_and_drop(self, /, value: bool |None) -> None§
@property
def fullscreen(self, /) -> bool |None§
@fullscreen.setter
def fullscreen(self, /, fullscreen: bool |None) -> None§
@property
def fullsize_content_view(self, /) -> bool |None§
@fullsize_content_view.setter
def fullsize_content_view(self, /, value: bool |None) -> None§
@property
def has_shadow(self, /) -> bool |None§
@has_shadow.setter
def has_shadow(self, /, value: bool |None) -> None§
@property
def icon(self, /) -> Any |None§
@icon.setter
def icon(self, /, icon: Any |None) -> None§
@property
def inner_size(self, /) -> Vec2 |None§
@inner_size.setter
def inner_size(self, /, inner_size: Vec2 |None) -> None§
@property
def max_inner_size(self, /) -> Vec2 |None§
@max_inner_size.setter
def max_inner_size(self, /, max_inner_size: Vec2 |None) -> None§
@property
def maximize_button(self, /) -> bool |None§
@maximize_button.setter
def maximize_button(self, /, value: bool |None) -> None§
@property
def maximized(self, /) -> bool |None§
@maximized.setter
def maximized(self, /, maximized: bool |None) -> None§
@property
def min_inner_size(self, /) -> Vec2 |None§
@min_inner_size.setter
def min_inner_size(self, /, min_inner_size: Vec2 |None) -> None§
@property
def minimize_button(self, /) -> bool |None§
@minimize_button.setter
def minimize_button(self, /, value: bool |None) -> None§
@property
def monitor(self, /) -> int |None§
@monitor.setter
def monitor(self, /, value: int |None) -> None§
@property
def mouse_passthrough(self, /) -> bool |None§
@mouse_passthrough.setter
def mouse_passthrough(self, /, value: bool |None) -> None§
@property
def movable_by_window_background(self, /) -> bool |None§
@movable_by_window_background.setter
def movable_by_window_background(self, /, value: bool |None) -> None§
@property
def override_redirect(self, /) -> bool |None§
@override_redirect.setter
def override_redirect(self, /, value: bool |None) -> None§
@property
def position(self, /) -> Pos2 |None§
@position.setter
def position(self, /, position: Pos2 |None) -> None§
@property
def resizable(self, /) -> bool |None§
@resizable.setter
def resizable(self, /, resizable: bool |None) -> None§
@property
def taskbar(self, /) -> bool |None§
@taskbar.setter
def taskbar(self, /, value: bool |None) -> None§
@property
def title(self, /) -> str |None§
@title.setter
def title(self, /, title: str |None) -> None§
@property
def title_shown(self, /) -> bool |None§
@title_shown.setter
def title_shown(self, /, value: bool |None) -> None§
@property
def titlebar_buttons_shown(self, /) -> bool |None§
@titlebar_buttons_shown.setter
def titlebar_buttons_shown(self, /, value: bool |None) -> None§
@property
def titlebar_shown(self, /) -> bool |None§
@titlebar_shown.setter
def titlebar_shown(self, /, value: bool |None) -> None§
@property
def transparent(self, /) -> bool |None§
@transparent.setter
def transparent(self, /, transparent: bool |None) -> None§
@property
def visible(self, /) -> bool |None§
@visible.setter
def visible(self, /, visible: bool |None) -> None§
@property
def window_level(self, /) -> WindowLevel |None§
@window_level.setter
def window_level(self, /, level: WindowLevel |None) -> None§
@property
def window_type(self, /) -> X11WindowType |None§
@window_type.setter
def window_type(self, /, value: X11WindowType |None) -> None§
Methods§
@staticmethod
def default() -> ViewportBuilder§
Sourcedef patch(self, /, new_builder: ViewportBuilder) -> tuple[list[ViewportCommand], bool]§
Update this ViewportBuilder with a delta,
returning a list of commands and a bool indicating if the window needs to be recreated.
Sourcedef with_active(self, /, active: bool) -> ViewportBuilder§
Whether the window will be initially focused or not.
The window should be assumed as not focused by default
Platform-specific:
Android / iOS / X11 / Wayland / Orbital: Unsupported.
Look at winit for more details
Sourcedef with_always_on_top(self, /) -> ViewportBuilder§
This window is always on top
For platform compatibility see egui.viewport.WindowLevel documentation
Sourcedef with_app_id(self, /, app_id: str) -> ViewportBuilder§
On Wayland
On Wayland this sets the Application ID for the window.
The application ID is used in several places of the compositor, e.g. for
grouping windows of the same application. It is also important for
connecting the configuration of a .desktop file with the window, by
using the application ID as file name. This allows e.g. a proper icon
handling under Wayland.
See Waylands XDG shell documentation for more information on this Wayland-specific option.
The app_id should match the .desktop file distributed with your program.
For details about application ID conventions, see the Desktop Entry Spec
eframe
On eframe, the app_id of the root window is also used to determine
the storage location of persistence files.
Sourcedef with_clamp_size_to_monitor_size(self, /, clamp: bool) -> ViewportBuilder§
Sets whether clamp the window's size to monitor's size. The default is True on linux, otherwise it is False.
Note: On some Linux systems, a window size larger than the monitor causes crashes
Sourcedef with_close_button(self, /, value: bool) -> ViewportBuilder§
Does not work on X11.
Sourcedef with_decorations(self, /, decorations: bool) -> ViewportBuilder§
Sets whether the window should have a border, a title bar, etc.
The default is True.
Look at winit for more details
Sourcedef with_drag_and_drop(self, /, value: bool) -> ViewportBuilder§
On Windows: enable drag and drop support. Drag and drop can not be disabled on other platforms.
See [winit's documentation]drag_and_drop for information on why you
might want to disable this on windows.
drag_and_drop: https://docs.rs/winit/latest/x86_64-pc-windows-msvc/winit/platform/windows/trait.WindowAttributesExtWindows.html#tymethod.with_drag_and_drop
Sourcedef with_fullscreen(self, /, fullscreen: bool) -> ViewportBuilder§
Sets whether the window should be put into fullscreen upon creation.
The default is None.
Look at winit for more details This will use borderless
Sourcedef with_fullsize_content_view(self, /, value: bool) -> ViewportBuilder§
macOS: Makes the window content appear behind the titlebar.
You often want to combine this with egui.ViewportBuilder.with_titlebar_shown
and egui.ViewportBuilder.with_title_shown.
Sourcedef with_has_shadow(self, /, value: bool) -> ViewportBuilder§
macOS: Set to False to make the window render without a drop shadow.
The default is True.
Disabling this feature can solve ghosting issues experienced if using egui.ViewportBuilder.with_transparent.
Look at winit for more details
Sourcedef with_icon(self, /, icon: Any) -> ViewportBuilder§
The application icon, e.g. in the Windows task bar or the alt-tab menu.
The default icon is a white e on a black background (for "egui" or "eframe").
If you prefer the OS default, set this to IconData.default().
Sourcedef with_inner_size(self, /, size: Vec2) -> ViewportBuilder§
Requests the window to be of specific dimensions.
If this is not set, some platform-specific dimensions will be used.
Should be bigger than 0 Look at winit for more details
Sourcedef with_max_inner_size(self, /, size: Vec2) -> ViewportBuilder§
Sets the maximum dimensions a window can have.
If this is not set, the window will have no maximum or will be set to the primary monitor's dimensions by the platform.
Should be bigger than 0 Look at winit for more details
Sourcedef with_maximize_button(self, /, value: bool) -> ViewportBuilder§
Does not work on X11.
Sourcedef with_maximized(self, /, maximized: bool) -> ViewportBuilder§
Request that the window is maximized upon creation.
The default is False.
Look at winit for more details
Sourcedef with_min_inner_size(self, /, size: Vec2) -> ViewportBuilder§
Sets the minimum dimensions a window can have.
If this is not set, the window will have no minimum dimensions (aside from reserved).
Should be bigger than 0 Look at winit for more details
Sourcedef with_minimize_button(self, /, value: bool) -> ViewportBuilder§
Does not work on X11.
Sourcedef with_monitor(self, /, index: int) -> ViewportBuilder§
Place the window in borderless fullscreen on the monitor at index.
The index refers to the order returned by winit's available_monitors().
Works cross-platform (Windows, macOS, Linux X11 + Wayland). On Wayland
this is the only reliable way to target a specific output, since
absolute window positions are not exposed.
If the index is out of range, the flag is ignored at window creation time.
Sourcedef with_mouse_passthrough(self, /, value: bool) -> ViewportBuilder§
On desktop: mouse clicks pass through the window, used for non-interactable overlays.
Generally you would use this in conjunction with egui.ViewportBuilder.with_transparent
and egui.ViewportBuilder.with_always_on_top.
Sourcedef with_movable_by_background(self, /, value: bool) -> ViewportBuilder§
macOS: Set to True to allow the window to be moved by dragging the background.
Enabling this feature can result in unexpected behavior with draggable UI widgets such as sliders.
def with_movable_by_window_background(self, /, value: bool) -> ViewportBuilder§
Sourcedef with_override_redirect(self, /, value: bool) -> ViewportBuilder§
On X11
This sets the override-redirect flag. When this is set to true the window type should be specified.
Maps directly to Override-redirect windows.
Sourcedef with_position(self, /, position: Pos2) -> ViewportBuilder§
The initial "outer" position of the window, i.e. where the top-left corner of the frame/chrome should be.
eframe notes:
- iOS: Sets the top left coordinates of the window in the screen space coordinate system.
- Web: Sets the top-left coordinates relative to the viewport. Doesn't account for CSS
transform. - Android / Wayland: Unsupported.
transform: https://developer.mozilla.org/en-US/docs/Web/CSS/transform
Sourcedef with_resizable(self, /, resizable: bool) -> ViewportBuilder§
Sets whether the window is resizable or not.
The default is True.
Look at winit for more details
Sourcedef with_taskbar(self, /, value: bool) -> ViewportBuilder§
windows: Whether show or hide the window icon in the taskbar.
Sourcedef with_title(self, /, title: str) -> ViewportBuilder§
Sets the initial title of the window in the title bar.
Look at winit for more details
Sourcedef with_title_shown(self, /, value: bool) -> ViewportBuilder§
macOS: Set to False to hide the window title.
Sourcedef with_titlebar_buttons_shown(self, /, value: bool) -> ViewportBuilder§
macOS: Set to False to hide the titlebar button (close, minimize, maximize)
Sourcedef with_titlebar_shown(self, /, value: bool) -> ViewportBuilder§
macOS: Set to False to make the titlebar transparent, allowing the content to appear behind it.
Sourcedef with_transparent(self, /, transparent: bool) -> ViewportBuilder§
Sets whether the background of the window should be transparent.
You should avoid having a egui.CentralPanel, or make sure its frame is also transparent.
In eframe you control the transparency with eframe.App.clear_color().
If this is True, writing colors with alpha values different than
1.0 will produce a transparent window. On some platforms this
is more of a hint for the system and you'd still have the alpha
buffer.
The default is False.
If this is not working, it's because the graphic context doesn't support transparency,
you will need to set the transparency in the eframe!
Platform-specific
macOS: When using this feature to create an overlay-like UI, you likely want to combine this with egui.ViewportBuilder.with_has_shadow set to False in order to avoid ghosting artifacts.
Sourcedef with_visible(self, /, visible: bool) -> ViewportBuilder§
Sets whether the window will be initially visible or hidden.
The default is to show the window.
Look at winit for more details
Sourcedef with_window_level(self, /, level: WindowLevel) -> ViewportBuilder§
Control if window is always-on-top, always-on-bottom, or neither.
For platform compatibility see egui.viewport.WindowLevel documentation
Sourcedef with_window_type(self, /, window_type: X11WindowType) -> ViewportBuilder§
On X11
This sets the window type.
Maps directly to _NET_WM_WINDOW_TYPE.