Metadata-Version: 2.4
Name: omnipython-pdwidgets
Version: 0.0.26.dev3
Summary: Cross-platform widget toolkit for OmniPython
Author: Brad Barnett
License-Expression: MIT
Project-URL: Homepage, https://github.com/PyDevices/omnipython/tree/main/pdwidgets
Project-URL: Issues, https://github.com/PyDevices/omnipython/issues
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: omnipython
Requires-Dist: omnipython-pygraphics
Requires-Dist: omnipython-palettes
Dynamic: license-file

<img src="docs/images/pdwidgets.png" width="240" alt="A label reading Taps: 3 above a button labelled Tap me, on black">

# pdwidgets

pdwidgets is a whole user-interface toolkit written in Python, with no C:
labels, buttons, sliders, lists, dialogs and layouts, built on OmniPython's
displaydev, boarddev, appdev and multimer. It shows that the core is a
foundation other UI frameworks can stand on, and it runs the same code on
MicroPython-compatible boards, CPython and in the browser. For an interface you
ship, [LVGL](https://docs.omnipython.org/en/latest/omnipython/guides/lvgl.html) is the toolkit to reach for.

```bash
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ omnipython-pdwidgets omnipython-desktop
```

```python
import omip
for package in ("omnipython", "pygraphics", "palettes", "pdwidgets"):
    omip.install(package)
```

`omip` comes with OmniPython firmware. On other MicroPython firmware, run
`mip.install("github:PyDevices/omnipython/lib/omip.py")` once to put it on the board.

The first is for a desktop, and `omnipython-desktop` brings the display it draws
on. The second installs onto a board, which also needs its board config:
[Install](docs/get-started/install.md) has every board and channel.

```python
import board_config
import appdev
import pdwidgets as pd

app = appdev.App(board_config)
display = pd.Display(board_config.display_drv, app)
screen = pd.Screen(display, bg=0x0000)

label = pd.Label(screen, value="Taps: 0", align=pd.ALIGN.TOP, y=40, bg=screen.bg)
button = pd.Button(screen, label="Tap me", align=pd.ALIGN.CENTER, w=160, h=50)
taps = 0

def on_tap(sender, event):
    global taps
    taps += 1
    label.value = f"Taps: {taps}"
    print(label.value)

button.add_event_cb(pd.events.MOUSEBUTTONUP, on_tap)
app.run()
```

```text
Taps: 1
Taps: 2
Taps: 3
```

That opens a window with a button in it, and each click prints a line. The
picture at the top of this page is the window after three clicks.

[Docs](https://docs.omnipython.org/en/latest/pdwidgets/) · [Examples](https://gallery.omnipython.org/pyscript/) · [Roadmap](ROADMAP.md)

OmniPython is made by [PyDevices](https://pydevices.com).
