Add a Python script to a widget in a dashboard to register and respond to events you specify.
In Dashboards, open the dashboard you want to add a Python
Add a widget to the panel.
configuration pane, under
+ to add an event script to the widget.
Script window opens.
Select the type of event.
|Type of Event
||Executes when the values for the widget's binding updates.
||Registers when the widget loads.
||Registers when the widget transitions from one state to another state.
||Executes the script at the time interval you specify.
||Executes when a user provides new values
Only output widgets have the option to create a script for the user input event.
Enter a unique name for the main function, or the entry point that the script calls when the event executes.
If you do not name the main function,
Dashboards automatically wraps the script in an anonymous Python function
and nests all of the functions inside of it.
In the Script window, enter
def and press Ctrl+Space to autogenerate the function definition and return statement.
Add your Python code.
You can call two Python functions from a script to access the dashboard widgets. Refer to the following table to learn more
about the Python functions.
|Name of Function
|Get Widget Properties
||Returns the value of the requested widget property in the configuration pane.
|Set Widget Properties
||Writes the value of the requested widget property.
set_widget_prop(widget_name, property_name, value)
When you finish adding your Python code, click
Dashboards lists the script in the configuration pane.
Play to view your dashboard.
To make changes to the event script, double-click the event script in the
You cannot change a script's event type. To do so, you must delete the existing event script and add it to a new event.
After you add an event script to a widget, add a virtual tag script to your dashboard to enable communication between your
event script and widget.