Window API Reference¶
The Window class represents a desktop window managed by SDL2.
Creating Windows¶
Windows are created via wa.window():
See Core API for full constructor documentation.
Position Properties¶
x¶
The window's X coordinate.
y¶
The window's Y coordinate.
position¶
The window's (x, y) position as a tuple.
Setting position is more efficient than setting x and y separately.
Size Properties¶
w¶
The window's width.
h¶
The window's height.
width¶
Alias for w.
height¶
Alias for h.
size¶
The window's (width, height) as a tuple.
Appearance Properties¶
color¶
The window's background color.
Accepts CSS color names, hex codes, RGB tuples, or Color objects.
opacity¶
The window's opacity (0.0 = transparent, 1.0 = opaque).
title¶
The window's title bar text.
Only visible when borderless=False.
Behavior Properties¶
borderless¶
Whether the window has decorations (title bar, borders).
always_on_top¶
Whether the window stays above other windows.
resizable¶
Whether the user can resize the window.
shadow¶
Whether the window has a drop shadow (macOS only).
Image Properties¶
image¶
Path to the displayed image file.
image_region¶
Source region to display from the image.
win.image_region -> tuple[int, int, int, int] | None # (x, y, w, h)
win.image_region = (x, y, w, h) # or None for full image
image_size¶
Dimensions of the loaded image.
Read-only.
GIF Properties¶
gif¶
Path to the displayed GIF file.
gif_playing¶
Whether the GIF animation is playing.
gif_loop¶
Whether the GIF loops continuously.
gif_speed¶
Playback speed multiplier.
gif_frame¶
Current frame index.
gif_frame_count¶
Total number of frames.
Read-only.
gif_region¶
Source region to display from each frame.
gif_size¶
Dimensions of the GIF.
Read-only.
Video Properties¶
video¶
Path to the displayed video file.
video_playing¶
Whether video playback is active.
video_loop¶
Whether video loops continuously.
video_speed¶
Playback speed multiplier.
video_position¶
Current playback position in seconds.
video_duration¶
Total video duration in seconds.
Read-only.
video_frame¶
Current frame index.
Read-only.
video_region¶
Source region to display.
video_size¶
Dimensions of the video.
Read-only.
State Properties¶
closed¶
Whether the window has been closed.
Read-only.
id¶
Unique window identifier.
Read-only.
Methods¶
close()¶
Close and destroy the window.
show()¶
Make the window visible.
hide()¶
Make the window invisible.
raise_window()¶
Bring the window to the front of the z-order.
Example¶
import window_art as wa
with wa.run():
# Create window
win = wa.window(100, 100, 200, 200, color="coral")
# Modify properties
win.position = (300, 200)
win.size = (300, 250)
win.color = "dodgerblue"
win.opacity = 0.8
win.title = "Hello"
win.borderless = False
wa.wait(2)
# Check state
if not win.closed:
win.close()