SettingsWindow & SettingsTab¶
SettingsWindow is the app's preferences window, with a toolbar of SettingsTab items. Assign it to app.settings_window and open it with app.settings_window.open(). It only shows views; bind them to app.settings to save what the user chooses.

import nib
def main(app: nib.App):
app.title = "Settings"
app.icon = nib.SFSymbol("gearshape")
app.settings = {"launch_at_login": False, "theme": "System", "volume": 50}
app.settings_window = nib.SettingsWindow(
nib.SettingsTab(
"General",
icon="gear",
content=nib.Form(
controls=[
nib.Section(
header="Startup",
controls=[
nib.Toggle(
"Launch at login",
is_on=app.settings.bind("launch_at_login"),
),
],
),
nib.Section(
header="Appearance",
controls=[
nib.Picker(
"Theme",
selection=app.settings.bind("theme"),
options=["System", "Light", "Dark"],
),
],
),
],
style=nib.FormStyle.GROUPED,
),
),
nib.SettingsTab(
"Sound",
icon="speaker.wave.2",
content=nib.Form(
controls=[
nib.Slider(
label="Volume",
value=app.settings.bind("volume"),
min_value=0,
max_value=100,
),
],
style=nib.FormStyle.GROUPED,
),
),
title="Preferences",
width=440,
height=300,
)
app.menu = [
nib.MenuItem("Settings…", shortcut="cmd+,", on_click=app.settings_window.open),
nib.MenuDivider(),
nib.MenuItem("Quit", shortcut="cmd+q", on_click=app.quit),
]
# The window also opens from the context menu; opening it with the
# popover makes the demo show it.
app.on_appear = app.settings_window.open
app.build(nib.Text("Settings are in the window", padding=20))
nib.run(main)
SettingsWindow¶
nib.SettingsWindow(
*tabs: SettingsTab,
content: View | None = None,
width: float = 450,
height: float = 300,
title: str = "Settings",
)
| Parameter | Type | Default | Description |
|---|---|---|---|
*tabs |
SettingsTab |
The tabs, in toolbar order. With one tab no toolbar is shown | |
content |
View |
None |
A single view instead of tabs; no toolbar is shown |
width, height |
float |
450, 300 |
Window size in points |
title |
str |
"Settings" |
Window title; with tabs the selected tab's title is shown |
Passing both tabs and content raises ValueError.
Methods¶
| Method | Description |
|---|---|
open() |
Show the window and bring the app to the front |
close() |
Close the window |
The window updates when a view in it changes, whether the user or code changed it, and keeps the selected tab.
A menu bar app has no app menu, so Cmd+, works only through a menu item that declares it:
app.menu = [nib.MenuItem("Settings…", on_click=app.settings_window.open, shortcut="cmd+,")]
SettingsTab¶
nib.SettingsTab(title: str, icon: str | None = None, content: View | None = None)
| Parameter | Type | Description |
|---|---|---|
title |
str |
The tab's label in the toolbar |
icon |
str |
An SF Symbol name |
content |
View |
What the tab shows, usually a nib.Form |