Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Window options

from dry import Webview

wv = Webview(
    app_id='com.example.myapp',
    title='My App',
    size=(1080, 720),
    min_size=(800, 600),
    decorations=True,
    icon_path='assets/app.ico',
    dev_tools=True,
    html=HTML,
)
wv.run()

Sizes are logical pixels

size and min_size are logical pixels, independent of display scaling: a window declared 800 by 600 opens at that apparent size on a display scaled to 150% as on one scaled to 100%, and the page’s own window.innerWidth reports the same 800. They are the numbers CSS is working in.

Every size and position Dry reports back — in Window Events — is in the same unit, for the same reason.

decorations

decorations=False removes the native titlebar and borders, and the Webview draws its own resize edges instead. data-drag-region is what then moves the window.

icon_path

A path to an .ico file — a str or any os.PathLike. ICO is the only format the build decodes.

The icon is a Windows feature. macOS has no per-window icon, so the setting has no effect there.

An icon that cannot be read is a warning on the dry.webview logger, not a failure: the window opens with the platform’s default icon.

dev_tools

dev_tools=True enables the platform’s web inspector. Leave it off in a release build.

title

Purely cosmetic since 0.4.0. It no longer decides where your data is stored, so it may contain any character — see Where your data lives.

What can change after run()

Every option is also a property, and most of them are read once, while the Webview is being built. Assigning one of those after run() raises a RuntimeError naming the setting, rather than silently doing nothing:

wv.api = {'hello': hello}
# RuntimeError: api is fixed at construction and the Webview is already
# running, so assigning it now would change nothing. Pass api to Webview(...)
# instead.
SettingAfter run()
html, url, rootraises
api, defaultraises
dev_toolsraises
app_id, user_data_folderraises
on_closeraises
title, size, min_size, decorations, icon_pathassignable, and applied to the open window

Since run() never returns, “after run()” means from inside a callback: an Api callable, an Event listener or a close hook.

Beside those five settings are five states a window only has once it is on screen — position, visible, maximized, minimized and fullscreen — which are not constructor arguments at all, and a wv.state() that reads the window back in one piece. They are all in Runtime window control.

decorations assigned at runtime adds or removes the native titlebar, but does not add or remove the resize edges an undecorated Webview draws for itself: those are installed from the decorations the constructor was given. A window that means to toggle its titlebar should be built with decorations=False — see Runtime window control.