plotly / dash-renderer

OBSOLETE has been merged into dash
https://github.com/plotly/dash
MIT License
97 stars 32 forks source link

more devtools enhancements #152

Closed chriddyp closed 5 years ago

chriddyp commented 5 years ago

mostly css but a few bug fixes as well

image

byronz commented 5 years ago

@chriddyp can you share your sample app too?

chriddyp commented 5 years ago
import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc

import datetime

app = dash.Dash(__name__)
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True

app.layout = html.Div([
    html.Button(id='python', children='Python exception', n_clicks=0),
    html.Button(id='validation', children='Validation error', n_clicks=0),
    html.Button(id='normal', children='Regular execution', n_clicks=0),
    html.Div(id='output')
])

@app.callback(
    Output('output', 'children'),
    [
        Input('python', 'n_clicks'),
        Input('validation', 'n_clicks'),
        Input('normal', 'n_clicks'),
    ])
def update_output(*args):
    if all([a == 0 for a in args]):
        return ''

    triggered = [t['prop_id'] for t in dash.callback_context.triggered]
    if 'python.n_clicks' in triggered:
        1/0
    elif 'validation.n_clicks' in triggered:
        return dcc.Graph(animate=0)
    else:
        return 'Callback returned at {}'.format(datetime.datetime.now())

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