ECOSYSTEM / DESKTOP

Dialogs

Open, save, choose a folder, show a message and confirm, with await.

Ecosystem package janelkit-desktop System services: native file and message dialogs, and the clipboard. It adds no interface controls. pip install janelkit-desktop
DESKTOP · PAGE 2 / 4~1 min read
Alpha / 0.2 — These pages document JanelKit 0.2 and its packages. Each series (0.1, 0.2…) may change the public API, always with migration notes: see Changes and migration. The website uses Svelte; the desktop examples use Python and JanelKit, not JavaScript.

Every dialog is awaited

Call a dialog with await from an async def handler. Dialogs are native where the platform provides them, appear over your window, and close on their own if the component that opened them is destroyed while they are open. filters is a list of Qt name filters such as "Images (*.png *.jpg)"; folder sets the starting folder.

FunctionReturnsWhen canceled
open_file(title="Abrir", filters=None, folder=None)PathNone
open_files(title="Abrir", filters=None, folder=None)list[Path]Empty list
save_file(title="Guardar", filters=None, folder=None, name=None)Path (name is the suggested file name)None
choose_folder(title="Elegir carpeta", folder=None)PathNone
message(text, title="", details=None)None, once closed—
confirm(text, title="", details=None)True if acceptedFalse

Common mistakes

  • The default titles are Spanish. Pass a title explicitly in an English application.
  • Calling a dialog without await does not show it and returns a coroutine, not a path.

Ask before something irreversible

confirm shows OK and Cancel and returns True only when the user accepts. Together with before_leave, from the core, it asks before a window closes or, with janelkit-router, before a page is left.

python
# In a component script; items and selected are states of yours.
from janelkit_desktop import dialogs

async def delete():
    if await dialogs.confirm("Delete the selected note?", details="This cannot be undone."):
        items.value.remove(selected.value)
Copy

Learn moreWindows and screens ↗Ask before leaving ↗

English documentation based on the JanelKit source. For additional details, browse the source docs ↗.