Open In App

How to Convert a Dash app into an Executable GUI

Last Updated : 12 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Dash, a powerful Python framework for building web applications, provides an excellent platform for creating interactive data visualizations and dashboards. In this article, we will see how we can create a Dash app into a GUI using Python.

Convert a Dash app into an Executable GUI in Python

Below are step-by-step explanations to convert a dash app into an executable GUI in Python:

Install Necessary Library

Before we begin, ensure that you have dash, dash_core_components, and dash_html_components installed. To install these libraries, use the following command:

pip install dash
pip install dash_core_components
pip install dash_html_components

Complete Code

Below, Python code create Dash web application with a title, description, and a bar chart using Dash’s core components. It creates a layout structured with HTML components and a Graph component for data visualization. Finally, it runs the application on a local server in debug mode, enabling real-time debugging.

main.py

Python3
import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash(__name__)

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5],
                    'type': 'bar', 'name': u'Montréal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

Run the Server

To run the code use the below command.

python main.py

Output

gitpp

Convert a Dash app into an Executable GUI


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads