Skip to main content

An agile, powerful Python framework for creating dynamic UIs with seamless web integration.

Project description

Trunco

Trunco is a modern Python framework for building dynamic, reusable, and modular HTML components. Designed with web developers in mind, Trunco provides a simple and Pythonic API that integrates seamlessly with popular web frameworks like Django, Flask, and FastAPI. Whether you’re building simple pages or complex web applications, Trunco gives you the tools to create clean, maintainable, and reusable components.

Features

  • Component-Based Architecture: Trunco encourages the use of components, making your HTML more modular and easier to manage.
  • Context Support: Pass dynamic data into your components easily, allowing for flexible and adaptive UI elements.
  • Alpine.js and HTMX Integration: Build reactive and interactive components with built-in support for Alpine.js and HTMX directives.
  • Seamless Integration: Trunco works out-of-the-box with Django, Flask, FastAPI, and other popular web frameworks.
  • Extensible: Easily extend and customize components, or create your own, to fit your specific needs.
  • Custom Directives and Attributes: Leverage the power of custom HTML attributes and directives to build rich, interactive UIs.

Installation

To start using Trunco, you can install it directly from PyPI using pip:

pip install trunco

Trunco requires Python 3.6+.

Basic Usage

Creating components with Trunco is straightforward. Here’s an example of how to create a basic button component:

from trunco.components import ButtonComponent

button = ButtonComponent(label="Click Me", on_click="alert('Hello World!')")
print(button)

This will output the following HTML:

<button id="unique-button-id" class="btn" x-on:click="alert('Hello World!')">Click Me</button>

Advanced Usage

Trunco is more than just simple components. It allows for complex layouts and interactions. Here’s an example of a form with multiple inputs:

from trunco.components import FormComponent, InputComponent, ButtonComponent

form = FormComponent(action="/submit", method="post")
form.add_child(InputComponent(input_type="text", placeholder="Enter your name"))
form.add_child(InputComponent(input_type="email", placeholder="Enter your email"))
form.add_child(ButtonComponent(label="Submit", on_click="submitForm()"))

print(form)

This will generate the following HTML:

<form id="unique-form-id" action="/submit" method="post">
    <input id="input1-id" type="text" placeholder="Enter your name">
    <input id="input2-id" type="email" placeholder="Enter your email">
    <button id="button-id" class="btn" x-on:click="submitForm()">Submit</button>
</form>

Documentation

Full documentation is available in the docs directory, covering everything from installation to advanced component usage.

Examples

Check out the examples directory for more code samples demonstrating how to use Trunco in different scenarios:

  • basic_usage.py: Simple examples to get you started.
  • advanced_usage.py: More complex usage involving forms, tables, and dynamic content.
  • form_example.py: Demonstrates how to build and handle forms using Trunco.

Contributing

We welcome contributions from the community! If you'd like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Implement your changes.
  4. Write tests to ensure your changes work as expected.
  5. Submit a pull request with a clear description of your changes.

License

Trunco is open-source software licensed under the MIT License. See the LICENSE file for more details.

Contact

If you have any questions, suggestions, or feedback, feel free to reach out. We’re here to help you get the most out of Trunco.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trunco-0.3.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trunco-0.3.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file trunco-0.3.1.tar.gz.

File metadata

  • Download URL: trunco-0.3.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for trunco-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f80a76346fdc0a01bc7557d094c793f14abee8412866165c47e0e3ace9dec551
MD5 0edd6d659448187866b7495b39172da5
BLAKE2b-256 934a7f67b24c236aae4501263747e418d0b24d49d89c09efbfe6fcfd996f6e23

See more details on using hashes here.

File details

Details for the file trunco-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: trunco-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for trunco-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f7e72077d3b04a54dd299e380a565bae893297145b113cc741ed43a90cc5a5
MD5 2e5c3672af0f957383c2290baaed0378
BLAKE2b-256 c557e207f6c762842faf000ccef35eeb0b5768319691cd7e08c269d59debde7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page