Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.

better-dash-callback

A library that enables running clientside callback functions in Dash applications using Python syntax, eliminating the need for inline JavaScript.

Problem

When building Dash applications, you often need to write clientside callback functions using inline JavaScript. This can be cumbersome and error-prone, especially for complex logic. Moreover, inline JavaScript code lacks syntax highlighting and debugging capabilities.

Solution

better-dash-callback provides a solution to this problem by allowing you to write clientside callback functions using Python syntax. This makes your code more readable, maintainable, and efficient.

Dependencies

better-dash-callback depends on metapensiero.pj, a Python-to-JavaScript compiler that allows you to write Python code that can be executed in a JavaScript environment.

Supported Python-to-JavaScript Syntax

The supported Python-to-JavaScript syntax is listed in the metapensiero.pj documentation. This includes support for many Python features, such as functions, classes, loops, and conditional statements.

Example

Let's consider a simple example where we want to update the text of a component based on the value of an input component.

Using Dash's clientside_callback

from dash import clientside_callback

clientside_callback(
    """
    function(value) {
        return 'You entered: ' + value;
    }
    """,
    Output("output", "children"),
    Input("input", "value")
)

Using better-dash-callback

from better-dash-callback import callback

@callback(
    Output("output", "children"),
    Input("input", "value"),
    clientside=True
)
def update_output(value):
    return f"You entered: {value}"

As you can see, the better-dash-callback example is more elegant and easier to read. You can write your callback function using Python syntax, without having to worry about inline JavaScript code, and the code you write also includes all the python syntax highlighting rather than being javascript code inside of a python string.

The callback function takes the following additional arguments:

  • clientside: A boolean indicating whether the callback should be executed on the client-side (default is False).
  • disable_es6: A boolean indicating whether to disable ES6 syntax in the generated JavaScript code and revert back to ES5 support (default is False).
  • enable_stage3: A boolean indicating whether to enable Stage 3 syntax in the generated JavaScript code (default is False).
  • Any arguments and keyword-arguments supported by dash.callback are also supported by better-dash-callback.callback

Installation

To install better-dash-callback, you can use pip:

pip3 install better-dash-callback

License

better-dash-callback is licensed under the MIT License.

Metadata

Release files for better-dash-callback 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for better-dash-callback 0.1.4
File Size Uploaded Provenance Actions
better_dash_callback-0.1.4.tar.gz 4.0 kB Without provenance Details for better_dash_callback-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for better-dash-callback 0.1.4
File Interpreter ABI Platform Actions
better_dash_callback-0.1.4-py3-none-any.whl Python 3 none any Details for better_dash_callback-0.1.4-py3-none-any.whl

Total release size: 8.3 kB

Release files / better_dash_callback-0.1.4.tar.gz

Download URL better_dash_callback-0.1.4.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
97fe19ba350b109913bb7bc89e565b5231356b57f5defdbf16f0638cc4e3a66e
BLAKE2b-256 checksum
How to use checksums
4bf6a87c7c919593f644bffed73a87f1d6977e0a82cbd770ecb5ded0b6225630
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / better_dash_callback-0.1.4-py3-none-any.whl

Download URL better_dash_callback-0.1.4-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f8ca70c4d0007fbe1a5bd408e04333fef22d509ab9eda06c8f68ceda1395a2d
BLAKE2b-256 checksum
How to use checksums
0fedf0e731ef54790e3fb973c46e2c3dbf74952a56ec856463fc526e1eeaa531
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Security for better-dash-callback 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page