Home
Nib¶
Build native macOS menu bar apps in Python.
Nib renders your interface with SwiftUI through a small Swift runtime. You write Python; the result is a real menu bar app with native controls, not a web view.
import nib
def main(app: nib.App):
app.icon = nib.SFSymbol(
"apple.meditate", rendering_mode=nib.SymbolRenderingMode.HIERARCHICAL
)
app.title = "Your Nib app"
app.menu = [
nib.MenuItem(
content=nib.VStack(
controls=[
nib.Text("Custom Item"),
nib.Text(
"You can place any control you want!",
font=nib.Font.CAPTION,
foreground_color=nib.Color.WHITE.with_opacity(0.5),
),
],
alignment=nib.Alignment.LEADING,
),
height=35,
),
nib.MenuDivider(),
nib.MenuItem("Quit", shortcut="cmd+q", action=app.quit),
]
count = nib.Text("0", font=nib.Font.TITLE2)
def increment():
count.content = str(int(count.content) + 1)
def decrement():
count.content = str(int(count.content) - 1)
app.build(
nib.HStack(
controls=[
nib.Button(content=nib.SFSymbol("minus"), action=decrement),
count,
nib.Button(content=nib.SFSymbol("plus"), action=increment),
]
)
)
nib.run(main)
Assigning to count.content is all it takes: the change is diffed and sent to the runtime, which updates the native view.
Install¶
pip install pynib
nib create myapp
cd myapp
nib run
Requires macOS 14 and Python 3.10 or newer. The wheel ships the Swift runtime; you do not need Xcode.
Documentation¶
- Getting Started: install, create a project, first app, concepts.
- Guides: how-to pages by topic.
- API Reference: views,
App, modifiers, types, services, notifications, CLI. - Examples: four complete apps.