Window Options & the OS¶
App(...) takes these options, which are the window's. dpi_scaling, present_mode, glyph_cache, blur_behind and click_through are also properties that can change while the app runs (app.present_mode = "low_latency"). The window's size, title, borders, minimum size, fullscreen and icon are in Apps & Screens.
| Option | Default | What it does |
|---|---|---|
dpi_scaling |
True |
Scales the window by the screen's density, so a 16-pixel size is the same size on every screen. False draws in device pixels. |
present_mode |
"vsync" |
How frames reach the screen: vsync paces frames to the display, low_latency shows the newest frame at once, at the cost of drawing as fast as it can while something animates. |
transparent |
False |
A window with no background of its own: what is not drawn shows the desktop. Fixed when the window opens. app.transparent_active says whether the platform could. |
blur_behind |
False |
The OS blurs the desktop behind a transparent window. |
click_through |
False |
Presses fall through the window to what is under it. |
ripple |
"nodes" |
How a press ripple is drawn: nodes grows a circle per press and lets the engine animate it; shader draws up to three at once with one fill shader (soft edges, one node per clickable thing), moved a frame at a time. |
focus_ring |
"solid" |
The ring around a keyboard-focused node: solid is one colour; gradient is a sweep through secondary, primary and tertiary that turns once every three seconds (standing still when motion is reduced). tess_re does not animate a gradient border, so Python sets the angle 30 times a second while a ring shows. |
glyph_cache |
False |
Keeps the shapes of letters between frames: less work for a lot of text. |
system_fonts |
False |
Lets a font family that isn't registered be found among the system's. |
app.scale_factor is the current density (1.0 until the window opens). A platform that can't do an option says so, naming it. A ripple or focus_ring that is not one of its two values is an error.
In a window view¶
A view whose root is a Window sets Transparent, Blur_Behind, Click_Through, Fullscreen, Maximized, Borderless, Min_Width, Min_Height and Remember itself, as properties of the window; see Windows, Docks & Embedded Views.
Window {
Title: Notes
Transparent: true
Blur_Behind: true
Children {
Container {
Style { Width: 320, Height: 200, Background: "surface@72%", Corner_Radius: 24 }
}
}
}
Less motion, more contrast¶
Operating systems let users ask for less animation and for more contrast. An app follows both unless told otherwise:
App(reduced_motion="system", high_contrast="system") is the default, True or False fixes the setting, and
app.set_reduced_motion(...) and app.set_high_contrast(...) change it later.
- Reduced motion: animations take no time, so things are where they are going at once, and indicators that would repeat for ever (the indeterminate progress bar and spinner, the loading indicator) stay still.
- High contrast: the theme is made again at the highest contrast level of Material 3's palette, so text and outlines stand out, and the app re-themes at once, as it does for dark mode. It follows the OS as the user turns it on and off.
app.reduced_motion and app.high_contrast are what the app is doing now. For your own animations,
tess_ui.motion.duration(window, ms) is ms, or 0 when motion is reduced.
Spring easing¶
An animation's easing can be a spring: Theme.easing("spring"), or Theme.spring(bounce) with a bounce above -1
and below 1 (above 0 overshoots). The duration is the spring's period, and it runs until it settles:
node.animate("scale", 1.0, 300, easing=Theme.spring(0.3))
What a frame costs¶
app.frame_stats() says what the frames cost: frames and skipped, last (the last frame's stage times in milliseconds) and recent (the last 240 frames: fps, and the mean, 95th
percentile and maximum of the total and the CPU time). app.frame_stats(reset=True) clears the history after reading it. app.profile_nodes = True measures each node's drawing too, and
app.start_trace("trace.json") / app.stop_trace() record every frame for Perfetto.
app.stats_handle() is an object another thread can read the stats from.
For a quick look, app.stats_overlay = True shows the frame rate and time in the window's corner, and running with
TESS_UI_STATS=1 in the environment turns it on for a run from the terminal:
TESS_UI_STATS=1 python app.py