Metadata-Version: 2.4
Name: pynib
Version: 0.1.14
Summary: Python-SwiftUI Bridge for macOS Status Bar Apps
Project-URL: Homepage, https://codeberg.org/edo/nib
Project-URL: Repository, https://codeberg.org/edo/nib
Author: Edoardo Balducci
License-Expression: MIT
Keywords: macos,menu-bar,python,status-bar,swiftui,ui
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: MacOS X
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Desktop Environment
Classifier: Topic :: Software Development :: User Interfaces
Requires-Python: >=3.10
Requires-Dist: msgpack>=1.1.2
Requires-Dist: watchdog>=6.0.0
Provides-Extra: dev
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

<h1 align="center">
  <span>
      <img width="8%" align="center" src="media/nib-logo-white.svg" alt="logo">
      <p>nib</p>
  </span>
</h1>

<p align="center">
  Build native macOS menu bar apps in Python.
</p>

## Install ![version](https://img.shields.io/pypi/v/pynib?label=&color=white&style=flat-square)

Requires macOS 14+ and Python 3.10+.

```bash
pip install pynib
```

## Create a project

```bash
nib create myapp
cd myapp
```

This scaffolds a project with a `pyproject.toml` and a `src/main.py` entry point.

## Write your app

<img width="40%" src="media/demo-column.png" align="right"/>

```python
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)
```

## Run it

```bash
nib run main.py
```

This starts your app in dev mode with hot reload. Edit your code, save, and the app updates.

## Build it

When you're ready to distribute:

```bash
nib build main.py
```

This produces a self-contained `.app` in `dist/` that bundles a portable Python runtime, your code, and all dependencies. No Python installation needed on the target machine.

| Flag | Effect |
|------|--------|
| `--native` | Compile to native `.so` via Cython |
| `--obfuscate` | Strip debug info from `.pyc` |
| `--no-compile` | Keep `.py` source files |
| `--icon icon.png` | Custom app icon |
| `--name "My App"` | Override display name |
| `--arch arm64` | Target architecture |

Build options can also go in `pyproject.toml`:

```toml
[tool.nib]
entry = "src/main.py"

[tool.nib.build]
name = "My App"
icon = "assets/icon.png"
identifier = "com.example.myapp"
native = true
```

## Features

Nib includes views like Text, Button, TextField, Toggle, Slider, Picker, DatePicker, ColorPicker, Image, Video, Label, Link, ProgressView, Gauge, Markdown, Table, SecureField, TextEditor, Map, WebView, and ShareLink. Layouts include VStack, HStack, ZStack, ScrollView, List, Form, Section, NavigationStack, DisclosureGroup, Grid, and lazy grids. There's also charting with LineMark, BarMark, AreaMark, PointMark, RuleMark, RectMark, and SectorMark.

On the system side: notifications, global hotkeys, clipboard, file dialogs, drag and drop, camera, battery, connectivity, screen info, keychain, and launch at login. Settings get their own window with tabs and auto-persist to UserDefaults. The status bar icon supports a right-click context menu with nested items, shortcuts, and badges.

See the full documentation at [bbalduzz.github.io/nib](https://bbalduzz.github.io/nib/).

## Architecture

<img width="70%" src="media/architecture.svg"/>

## License

MIT
