Package: duit
Duit (Data UI Toolkit)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
ofcansik/bildspur-baseandcansik/bildspur-ui.Example UI rendered withOpen3D(left) andtkinter(right).FeaturesData 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.InstallationBy default, only the data modeling, annotation, arguments and settings modules are installed.pipinstallduitTo support user interface creation for data fields, one of the following backends can be installed:open3d- Cross platform UI framework with support for 3d visualisation.tkinter- More stable UI framework, currently not feature complete.At the momentopen3dis the recommended choice as gui backend.pipinstall"duit[open3d]"To installtkinteruse the following command:pipinstall"duit[tkinter]"To install duit with all backends call pip like this:pipinstall"duit[all]"ExampleThis is a very basic example on how to useduit. Read todocumentationfor a more information about the core concepts.importargparsefromopen3d.visualizationimportguifromduitimportuifromduit.arguments.ArgumentimportArgumentfromduit.arguments.ArgumentsimportDefaultArgumentsfromduit.model.DataFieldimportDataFieldfromduit.settings.SettingsimportDefaultSettingsfromduit.ui.ContainerHelperimportContainerHelperfromduit.ui.open3d.Open3dPropertyPanelimportOpen3dPropertyPanelfromduit.ui.open3d.Open3dPropertyRegistryimportinit_open3d_registryclassConfig:def__init__(self):container_helper=ContainerHelper(self)withcontainer_helper.section("User"):self.name=DataField("Cat")|ui.Text("Name")self.age=DataField(21)|ui.Slider("Age",limit_min=18,limit_max=99)withcontainer_helper.section("Application"):self.enabled=DataField(True)|ui.Boolean("Enabled")|Argument()defmain():# create initial configconfig=Config()# register a custom listener for the enabled flagconfig.enabled.on_changed+=lambdae:print(f"Enabled:{e}")# add arguments and parseparser=argparse.ArgumentParser()args=DefaultArguments.add_and_configure(parser,config)# store current configDefaultSettings.save("config.json",config)# create open3d gui for to display configinit_open3d_registry()app=gui.Application.instanceapp.initialize()window:gui.Window=gui.Application.instance.create_window("Demo Window",400,200)panel=Open3dPropertyPanel(window)window.add_child(panel)panel.data_context=configapp.run()if__name__=="__main__":main()Which results in the following GUI.DevelopmentTo develop it is recommended to clone this repository and install the dependencies like this:# in the duit directorypipinstall-e".[all]"Generate Documentation# create documentation into "./docspythonsetup.pydoc# launch pdoc webserverpythonsetup.pydoc--launchAboutMIT License - Copyright (c) 2023 Florian Bruggisser