trame-dataclass
----------------------------------------
Dataclass for trame UI binding
License
----------------------------------------
This library is OpenSource and follow the Apache Software License
Installation
----------------------------------------
Install the application/library
.. code-block:: console
pip install trame-dataclass
Usage example
----------------------------------------
.. code-block:: console
from trame.app import TrameApp, StateDataModel
from trame.ui.html import DivLayout
from trame.widgets import html
class SimpleStructure(StateDataModel):
name: str = "John Doe"
age: int = 1
derived_value: int
@watch("age")
def _update_derived(self, age):
self.derived_value = 80 - age
class GettingStarted(TrameApp):
def __init__(self, server=None):
super().__init__(server)
self._data = SimpleStructure(self.server)
self._data.watch(["age"], self.print_age)
self._build_ui()
def print_age(self, age):
print(f"{age=}")
def _modify_data(self):
self._data.age += 1
def _build_ui(self):
with DivLayout(self.server) as self.ui:
html.Button("Server change", click=self._modify_data)
html.Div("Getting started with StateDataModel")
with self._data.Provider(name="user"):
html.Pre("{{ JSON.stringify(user, null, 2) }}")
html.Hr()
html.Div(
"Hello {{ user.name }} - derived value = {{ user.derived_value }}"
)
html.Hr()
html.Span("Your name:")
html.Input(type="text", v_model="user.name")
html.Hr()
html.Span("Your age:")
html.Input(
type="range", min=0, max=120, step=1, v_model_number="user.age"
)
def main():
app = GettingStarted()
app.server.start()
if __name__ == "__main__":
main()
Development setup
----------------------------------------
We recommend using uv for setting up and managing a virtual environment for your development.
.. code-block:: console
# Create venv and install all dependencies
uv sync --all-extras --dev
# Activate environment
source .venv/bin/activate
# Install commit analysis
pre-commit install
pre-commit install --hook-type commit-msg
# Allow live code edit
uv pip install -e .
Build and install the Vue components
.. code-block:: console
cd vue-components
npm i
npm run build
cd -
For running tests and checks, you can run ``nox``.
.. code-block:: console
# run all
nox
# lint
nox -s lint
# tests
nox -s tests
Professional Support
----------------------------------------
* `Training <https://www.kitware.com/courses/trame/>`_: Learn how to confidently use trame from the expert developers at Kitware.
* `Support <https://www.kitware.com/trame/support/>`_: Our experts can assist your team as you build your web application and establish in-house expertise.
* `Custom Development <https://www.kitware.com/trame/support/>`_: Leverage Kitware’s 25+ years of experience to quickly build your web application.
Raw data
{
"_id": null,
"home_page": null,
"name": "trame-dataclass",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "Application, Framework, Interactive, Python, Web",
"author": "Kitware Inc.",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/92/57/d1debebe713efe9b9339157a3a01f1d0821dd5c4c527447eff217a1bffaa/trame_dataclass-1.1.3.tar.gz",
"platform": null,
"description": "trame-dataclass\n----------------------------------------\n\nDataclass for trame UI binding\n\nLicense\n----------------------------------------\n\nThis library is OpenSource and follow the Apache Software License\n\nInstallation\n----------------------------------------\n\nInstall the application/library\n\n.. code-block:: console\n\n pip install trame-dataclass\n\nUsage example\n----------------------------------------\n\n.. code-block:: console\n\n from trame.app import TrameApp, StateDataModel\n from trame.ui.html import DivLayout\n from trame.widgets import html\n\n\n class SimpleStructure(StateDataModel):\n name: str = \"John Doe\"\n age: int = 1\n derived_value: int\n\n @watch(\"age\")\n def _update_derived(self, age):\n self.derived_value = 80 - age\n\n\n class GettingStarted(TrameApp):\n def __init__(self, server=None):\n super().__init__(server)\n self._data = SimpleStructure(self.server)\n self._data.watch([\"age\"], self.print_age)\n self._build_ui()\n\n def print_age(self, age):\n print(f\"{age=}\")\n\n def _modify_data(self):\n self._data.age += 1\n\n def _build_ui(self):\n with DivLayout(self.server) as self.ui:\n html.Button(\"Server change\", click=self._modify_data)\n html.Div(\"Getting started with StateDataModel\")\n with self._data.Provider(name=\"user\"):\n html.Pre(\"{{ JSON.stringify(user, null, 2) }}\")\n html.Hr()\n html.Div(\n \"Hello {{ user.name }} - derived value = {{ user.derived_value }}\"\n )\n html.Hr()\n html.Span(\"Your name:\")\n html.Input(type=\"text\", v_model=\"user.name\")\n html.Hr()\n html.Span(\"Your age:\")\n html.Input(\n type=\"range\", min=0, max=120, step=1, v_model_number=\"user.age\"\n )\n\n\n def main():\n app = GettingStarted()\n app.server.start()\n\n\n if __name__ == \"__main__\":\n main()\n\n\nDevelopment setup\n----------------------------------------\n\nWe recommend using uv for setting up and managing a virtual environment for your development.\n\n.. code-block:: console\n\n # Create venv and install all dependencies\n uv sync --all-extras --dev\n\n # Activate environment\n source .venv/bin/activate\n\n # Install commit analysis\n pre-commit install\n pre-commit install --hook-type commit-msg\n\n # Allow live code edit\n uv pip install -e .\n\n\nBuild and install the Vue components\n\n.. code-block:: console\n\n cd vue-components\n npm i\n npm run build\n cd -\n\nFor running tests and checks, you can run ``nox``.\n\n.. code-block:: console\n\n # run all\n nox\n\n # lint\n nox -s lint\n\n # tests\n nox -s tests\n\nProfessional Support\n----------------------------------------\n\n* `Training <https://www.kitware.com/courses/trame/>`_: Learn how to confidently use trame from the expert developers at Kitware.\n* `Support <https://www.kitware.com/trame/support/>`_: Our experts can assist your team as you build your web application and establish in-house expertise.\n* `Custom Development <https://www.kitware.com/trame/support/>`_: Leverage Kitware\u2019s 25+ years of experience to quickly build your web application.\n",
"bugtrack_url": null,
"license": "Apache Software License",
"summary": "Dataclass for trame UI binding",
"version": "1.1.3",
"project_urls": null,
"split_keywords": [
"application",
" framework",
" interactive",
" python",
" web"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a86dae88ba6054838cea3d8675f92b3ac9002f10ebb490951ea3c02092718efb",
"md5": "478335cef064da8aaf9c0217f7ce07c3",
"sha256": "0b996abcd837481320947023301fd6b577e9adf1c3bcd14dc56ef0b52912d71e"
},
"downloads": -1,
"filename": "trame_dataclass-1.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "478335cef064da8aaf9c0217f7ce07c3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 13772,
"upload_time": "2025-09-12T21:53:28",
"upload_time_iso_8601": "2025-09-12T21:53:28.810777Z",
"url": "https://files.pythonhosted.org/packages/a8/6d/ae88ba6054838cea3d8675f92b3ac9002f10ebb490951ea3c02092718efb/trame_dataclass-1.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9257d1debebe713efe9b9339157a3a01f1d0821dd5c4c527447eff217a1bffaa",
"md5": "fb051961eeae5a6e55cb2652736fe74b",
"sha256": "2b4b8223db015db26f222c0a049ac81d9c18e260c59a2d892a25760be62d9919"
},
"downloads": -1,
"filename": "trame_dataclass-1.1.3.tar.gz",
"has_sig": false,
"md5_digest": "fb051961eeae5a6e55cb2652736fe74b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 11776,
"upload_time": "2025-09-12T21:53:30",
"upload_time_iso_8601": "2025-09-12T21:53:30.302496Z",
"url": "https://files.pythonhosted.org/packages/92/57/d1debebe713efe9b9339157a3a01f1d0821dd5c4c527447eff217a1bffaa/trame_dataclass-1.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-12 21:53:30",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "trame-dataclass"
}