Window

Reference for the Window class, which manages the application window, its properties, editor UI overlay and runtime stats.

Window

window is created internally when you instantiate Ursina. It extends Panda3D’s WindowProperties to configure windowed/fullscreen modes, aspect ratio, editor UI and on‑screen stats.

Overview

Window handles all window parameters (title, icon, size, position, vsync, render mode) and builds the small editor overlay when in development mode. It also tracks monitors for fullscreen sizing and restores windowed size when exiting fullscreen.

Fields

NameDescription
.titleWindow title string.
.iconPath to window icon.
.monitorsList of available display monitors (via screeninfo).
.main_monitorPrimary monitor object (used for fullscreen sizing).
.monitor_indexIndex of the current monitor in .monitors.
.windowed_sizeSize when in windowed mode.
.fullscreen_sizeSize when in fullscreen mode.
.windowed_positionStored windowed position to restore after fullscreen.
.show_ursina_splashIf True, display the Ursina splash screen on startup.
.top, .bottom, .centerPrecomputed UI‑space Vec2 positions for overlay layout.
.forced_aspect_ratioIf set, locks window to that aspect ratio.
.always_on_topIf True, keep window above other OS windows.
.vsyncVertical‑sync flag (can’t change during play).
.colorBackground clear color.
.render_modesTuple of available render modes ('default', 'wireframe', etc.).
.render_modeCurrent render mode.
.editor_uiRoot Entity for the editor overlay (created in development mode).
.input_entityInvisible Entity that listens for window‑level key shortcuts (F10, F11, F12, etc.).
.exit_button, .fps_counter, .entity_counter, .collider_counterUI elements for close button and runtime stats.
.cog_menu, .cog_buttonButtonList and Button that open the editor cog menu for hot‑reloading, render‑mode toggles, etc.

Properties

PropertyDescription
.left, .rightUI‑space Vec2 at horizontal extremes.
.top_left, .top_right, .bottom_left, .bottom_rightCorner positions in UI space.
.positionWindow position on the desktop.
.sizeCurrent window size.
.aspect_ratioRead‑only width/height ratio.
.forced_aspect_ratioGet/set forced aspect ratio.
.render_modeGet/set current render mode.
.title, .iconGet/set title and icon.
.borderlessGet/set borderless flag.
.fullscreenGet/set fullscreen flag.
.always_on_topGet/set always-on-top.
.colorGet/set background clear color.
.vsyncGet/set vsync (window recreation required).

Methods

MethodDescription
ready(title, icon, borderless, fullscreen, size, forced_aspect_ratio, position, vsync, editor_ui_enabled, window_type, render_mode)Internal setup of PRC data, sizing and monitor detection.
apply_settings()Apply runtime changes (aspect ratio, vsync, color, render mode) and center on screen.
center_on_screen()Move window to the center of the current monitor.
make_editor_gui()Build the editor overlay UI (exit button, counters, cog menu) when in development mode.
update_aspect_ratio()Handler for OS aspect‑ratio changes (recomputes UI positions).
next_render_mode()Cycle through .render_modes.
toggle_editor_camera()Enable or disable the built‑in EditorCamera.
window_input(key)Internal callback for F‑key shortcuts (F10–F12).

Example Usage

from ursina import *

app = Ursina(title='My Game', window_type='onscreen')

# toggle fullscreen and borderless via hotkeys:
#   F11 toggles fullscreen
#   F10 cycles render modes
#   F12 shows/hides the editor overlay

# center the window explicitly
window.center_on_screen()

# change window size and force 16:9 aspect
window.size = Vec2(1280, 720)
window.forced_aspect_ratio = 16/9

app.run()