duit


Nameduit JSON
Version 0.1.12 PyPI version JSON
download
home_pagehttps://github.com/cansik/duit
SummaryDuit is a toolkit to create simple user-interfaces for python.
upload_time2024-03-28 17:20:09
maintainerNone
docs_urlNone
authorFlorian Bruggisser
requires_pythonNone
licenseMIT License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Duit (Data UI Toolkit)

[![Documentation](https://img.shields.io/badge/read-documentation-blue)](https://cansik.github.io/duit/)
[![Duit Test](https://github.com/cansik/duit/actions/workflows/test.yml/badge.svg)](https://github.com/cansik/duit/actions/workflows/test.yml)
[![PyPI](https://img.shields.io/pypi/v/duit)](https://pypi.org/project/duit/)
[![Github](https://img.shields.io/badge/github-duit-green.svg?logo=github)](https://github.com/cansik/duit)

Duit is a Python library that provides a set of tools for working with data in a structured and efficient way. The goal
of duit is to make it easy for developers to create and manage data models and create simple user interfaces for
data entry and display. The implementation is based on the ideas
of [cansik/bildspur-base](https://github.com/cansik/bildspur-base)
and [cansik/bildspur-ui](https://github.com/cansik/bildspur-ui).

<img width="800" alt="gui-demo" src="./doc/gui-demo.png">

*Example UI rendered with [Open3D](https://github.com/isl-org/Open3D) (left), [tkinter](https://docs.python.org/3/library/tkinter.html) (center) and [wx](https://pypi.org/project/wxPython/) (right)*.

## Features

- **Data Modeling**: duit provides a flexible data modeling framework to create structured data models and fields.

- **Annotations**: Use annotations to attach metadata to data fields, making it easier to work with them.

- **Command-line Arguments**: Easily parse and configure command-line arguments in your applications based on data
  fields.

- **Settings Serialization**: Serialize and deserialize settings from data fields to and from json.

- **User Interface**: Create simple user-interfaces for data fields.

## Installation

By default, only the data modeling, annotation, arguments and settings modules are installed.

```bash
pip install duit
```

To support user interface creation for data fields, one of the following backends can be installed:

- [open3d](https://github.com/isl-org/Open3D) - Cross platform UI framework with support for 3d visualisation.
- [tkinter](https://docs.python.org/3/library/tkinter.html) - More stable UI framework, currently not feature complete.

At the moment `open3d` is the recommended choice as gui backend.

```bash
pip install "duit[open3d]"
```

To install `tkinter` use the following command:

```bash
pip install "duit[tkinter]"
```

To install `wx` use the following command:

```bash
pip install "duit[wx]"
```

To install duit with all backends call pip like this:

```bash
pip install "duit[all]"
```

## Example

This is a very basic example on how to use `duit`. Read to [documentation](https://cansik.github.io/duit/duit.html#documentation) for a more information about the core concepts.

```python
import argparse

from open3d.visualization import gui

from duit import ui
from duit.arguments.Argument import Argument
from duit.arguments.Arguments import DefaultArguments
from duit.model.DataField import DataField
from duit.settings.Settings import DefaultSettings
from duit.ui.ContainerHelper import ContainerHelper
from duit.ui.open3d.Open3dPropertyPanel import Open3dPropertyPanel
from duit.ui.open3d.Open3dPropertyRegistry import init_open3d_registry


class Config:
    def __init__(self):
        container_helper = ContainerHelper(self)

        with container_helper.section("User"):
            self.name = DataField("Cat") | ui.Text("Name")
            self.age = DataField(21) | ui.Slider("Age", limit_min=18, limit_max=99)

        with container_helper.section("Application"):
            self.enabled = DataField(True) | ui.Boolean("Enabled") | Argument()


def main():
    # create initial config
    config = Config()

    # register a custom listener for the enabled flag
    config.enabled.on_changed += lambda e: print(f"Enabled: {e}")

    # add arguments and parse
    parser = argparse.ArgumentParser()
    args = DefaultArguments.add_and_configure(parser, config)

    # store current config
    DefaultSettings.save("config.json", config)

    # create open3d gui for to display config
    init_open3d_registry()

    app = gui.Application.instance
    app.initialize()

    window: gui.Window = gui.Application.instance.create_window("Demo Window", 400, 200)
    panel = Open3dPropertyPanel(window)
    window.add_child(panel)
    panel.data_context = config

    app.run()


if __name__ == "__main__":
    main()
```

Which results in the following GUI.

<img width="480" alt="example-window" src="./doc/example-window.png">

### Development

To develop it is recommended to clone this repository and install the dependencies like this:

```bash
# in the duit directory
pip install -e ".[all]"
```

#### Generate Documentation

```bash
# create documentation into "./docs
python setup.py doc

# launch pdoc webserver
python setup.py doc --launch
```

## About

MIT License - Copyright (c) 2024 Florian Bruggisser

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cansik/duit",
    "name": "duit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Florian Bruggisser",
    "author_email": "github@broox.ch",
    "download_url": null,
    "platform": null,
    "description": "# Duit (Data UI Toolkit)\n\n[![Documentation](https://img.shields.io/badge/read-documentation-blue)](https://cansik.github.io/duit/)\n[![Duit Test](https://github.com/cansik/duit/actions/workflows/test.yml/badge.svg)](https://github.com/cansik/duit/actions/workflows/test.yml)\n[![PyPI](https://img.shields.io/pypi/v/duit)](https://pypi.org/project/duit/)\n[![Github](https://img.shields.io/badge/github-duit-green.svg?logo=github)](https://github.com/cansik/duit)\n\nDuit is a Python library that provides a set of tools for working with data in a structured and efficient way. The goal\nof duit is to make it easy for developers to create and manage data models and create simple user interfaces for\ndata entry and display. The implementation is based on the ideas\nof [cansik/bildspur-base](https://github.com/cansik/bildspur-base)\nand [cansik/bildspur-ui](https://github.com/cansik/bildspur-ui).\n\n<img width=\"800\" alt=\"gui-demo\" src=\"./doc/gui-demo.png\">\n\n*Example UI rendered with [Open3D](https://github.com/isl-org/Open3D) (left), [tkinter](https://docs.python.org/3/library/tkinter.html) (center) and [wx](https://pypi.org/project/wxPython/) (right)*.\n\n## Features\n\n- **Data Modeling**: duit provides a flexible data modeling framework to create structured data models and fields.\n\n- **Annotations**: Use annotations to attach metadata to data fields, making it easier to work with them.\n\n- **Command-line Arguments**: Easily parse and configure command-line arguments in your applications based on data\n  fields.\n\n- **Settings Serialization**: Serialize and deserialize settings from data fields to and from json.\n\n- **User Interface**: Create simple user-interfaces for data fields.\n\n## Installation\n\nBy default, only the data modeling, annotation, arguments and settings modules are installed.\n\n```bash\npip install duit\n```\n\nTo support user interface creation for data fields, one of the following backends can be installed:\n\n- [open3d](https://github.com/isl-org/Open3D) - Cross platform UI framework with support for 3d visualisation.\n- [tkinter](https://docs.python.org/3/library/tkinter.html) - More stable UI framework, currently not feature complete.\n\nAt the moment `open3d` is the recommended choice as gui backend.\n\n```bash\npip install \"duit[open3d]\"\n```\n\nTo install `tkinter` use the following command:\n\n```bash\npip install \"duit[tkinter]\"\n```\n\nTo install `wx` use the following command:\n\n```bash\npip install \"duit[wx]\"\n```\n\nTo install duit with all backends call pip like this:\n\n```bash\npip install \"duit[all]\"\n```\n\n## Example\n\nThis is a very basic example on how to use `duit`. Read to [documentation](https://cansik.github.io/duit/duit.html#documentation) for a more information about the core concepts.\n\n```python\nimport argparse\n\nfrom open3d.visualization import gui\n\nfrom duit import ui\nfrom duit.arguments.Argument import Argument\nfrom duit.arguments.Arguments import DefaultArguments\nfrom duit.model.DataField import DataField\nfrom duit.settings.Settings import DefaultSettings\nfrom duit.ui.ContainerHelper import ContainerHelper\nfrom duit.ui.open3d.Open3dPropertyPanel import Open3dPropertyPanel\nfrom duit.ui.open3d.Open3dPropertyRegistry import init_open3d_registry\n\n\nclass Config:\n    def __init__(self):\n        container_helper = ContainerHelper(self)\n\n        with container_helper.section(\"User\"):\n            self.name = DataField(\"Cat\") | ui.Text(\"Name\")\n            self.age = DataField(21) | ui.Slider(\"Age\", limit_min=18, limit_max=99)\n\n        with container_helper.section(\"Application\"):\n            self.enabled = DataField(True) | ui.Boolean(\"Enabled\") | Argument()\n\n\ndef main():\n    # create initial config\n    config = Config()\n\n    # register a custom listener for the enabled flag\n    config.enabled.on_changed += lambda e: print(f\"Enabled: {e}\")\n\n    # add arguments and parse\n    parser = argparse.ArgumentParser()\n    args = DefaultArguments.add_and_configure(parser, config)\n\n    # store current config\n    DefaultSettings.save(\"config.json\", config)\n\n    # create open3d gui for to display config\n    init_open3d_registry()\n\n    app = gui.Application.instance\n    app.initialize()\n\n    window: gui.Window = gui.Application.instance.create_window(\"Demo Window\", 400, 200)\n    panel = Open3dPropertyPanel(window)\n    window.add_child(panel)\n    panel.data_context = config\n\n    app.run()\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\nWhich results in the following GUI.\n\n<img width=\"480\" alt=\"example-window\" src=\"./doc/example-window.png\">\n\n### Development\n\nTo develop it is recommended to clone this repository and install the dependencies like this:\n\n```bash\n# in the duit directory\npip install -e \".[all]\"\n```\n\n#### Generate Documentation\n\n```bash\n# create documentation into \"./docs\npython setup.py doc\n\n# launch pdoc webserver\npython setup.py doc --launch\n```\n\n## About\n\nMIT License - Copyright (c) 2024 Florian Bruggisser\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Duit is a toolkit to create simple user-interfaces for python.",
    "version": "0.1.12",
    "project_urls": {
        "Homepage": "https://github.com/cansik/duit"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3590ac2ef6c380c6c8fa565d7b9f2b5592f932677f9595d98c734b61e865adab",
                "md5": "70336ffd44fa3b534f7b35cb39ac03bf",
                "sha256": "211972d9048a0a7ace970ef1513d14edabdfffdf99397c27eb3477db25e3e713"
            },
            "downloads": -1,
            "filename": "duit-0.1.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70336ffd44fa3b534f7b35cb39ac03bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 94673,
            "upload_time": "2024-03-28T17:20:09",
            "upload_time_iso_8601": "2024-03-28T17:20:09.869910Z",
            "url": "https://files.pythonhosted.org/packages/35/90/ac2ef6c380c6c8fa565d7b9f2b5592f932677f9595d98c734b61e865adab/duit-0.1.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-28 17:20:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cansik",
    "github_project": "duit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "duit"
}
        
Elapsed time: 0.21327s