How to...

Overview

The Glue42 Dash library offers components based on React that enable you to use Glue42 features in your apps built with the Dash framework for Python.

Note that all Glue42 Dash components aren't represented visually and will be invisible in your apps. Their only purpose is to provide access to Glue42 functionalities.

Installation

The Glue42 Dash library is available as a package on the Python Package Index. To install it, execute the following command:

pip install dash_glue42

Referencing

To reference the Glue42 Dash library in your Dash app:

import dash_glue42

Initialization

To initialize the Glue42 Dash library, use the Glue42 component and pass an id for it:

import dash
import dash_glue42

app = dash.Dash(__name__)

app.layout = dash_glue42.Glue42(id="glue42")

The Glue42 component has the following properties:

Property Description
id The ID of this component. Used to identify Dash components in callbacks. The ID must be unique across all components in an app.
isEnterprise Indicates whether the app is running in Glue42 Enterprise or Glue42 Core.
children The children of this component.
settings An object containing configurations for the respective Glue42 libraries.
fallback An optional component to display while initializing Glue42.

The underlying Glue42 JavaScript library accepts an optional settings object used for configuring the library features. The example below demonstrates how to enable the Glue42 Channels API by using the settings property when the app is meant to run in Glue42 Enterprise:

import dash
import dash_glue42

glue_settings = {
    # Enabling Channels in Glue42 Enterprise.
    "desktop": {
        "config": {
            "channels": True
        }
    }
}

app = dash.Dash(__name__)

# Initializing the Glue42 library with custom settings.
app.layout = dash_glue42.Glue42(id="glue42", settings=glue_settings, children=[
    # Instantiating the Channels component.
    dash_glue42.Channels(id="glue42-channels")
])

The table below describes the properties of the optional settings object:

Property Description
type Optional. Accepts either "platform" or "client" as a value. Specifies whether this is a Main app or a Web Client in the context of Glue42 Core. The default is "client".
web Optional. An object with one property: config. The config property accepts a configuration object for the Glue42 Web library. You should define this object if your app is a Web Client.
webPlatform Optional. An object with one property: config. The config property accepts a configuration object for the Web Platform library. You should define this object if your app is a Main app in the context of Glue42 Core.
desktop Optional. An object with one property: config. The config property accepts a configuration object for the @glue42/desktop library used in Glue42 Enterprise. You should define this object if your app is a Glue42 Enterprise app.

Note that in Python it isn't possible to pass a function as a value, therefore the properties of the config objects which accept a function as a value can't be set.

App Configuration

To add your Dash app to the Glue42 Toolbar, you must create a JSON file with app configuration. Place this file in the %LocalAppData%\Tick42\UserData\<ENV>-<REG>\apps folder, where <ENV>-<REG> must be replaced with the environment and region of your Glue42 Enterprise copy (e.g., T42-DEMO).

Note that this step isn't necessary if your app is running in a Glue42 Core project. For more details, see the App Management > App Definitions section in the Glue42 Core documentation.

The following is an example configuration for a Dash app:

{
    "title": "Dash App",
    "type": "window",
    "name": "dash-app",
    "details": {
        "url": "http://127.0.0.1:5000/dash-app",
        "top": 25,
        "left": 800,
        "height": 400,
        "width": 400
    }
}

For more details, see the Developers > Configuration > Application section.

See also the Glue42 Dash examples on GitHub, demonstrating the various Glue42 Enterprise features.

Glue42 Dash Concepts

For more detailed information on the different Glue42 concepts and APIs, see: