Python dash_html_components.Pre() Examples
The following are 13
code examples of dash_html_components.Pre().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
dash_html_components
, or try the search function
.
Example #1
Source File: test_surface_selector.py From webviz-subsurface with GNU General Public License v3.0 | 6 votes |
def test_surface_selector(dash_duo): app = dash.Dash(__name__) app.config.suppress_callback_exceptions = True realizations = pd.read_csv("tests/data/realizations.csv") s = SurfaceSelector(app, surface_context, realizations) app.layout = html.Div(children=[s.layout, html.Pre(id="pre", children="ok")]) @app.callback(Output("pre", "children"), [Input(s.storage_id, "data")]) def _test(data): return json.dumps(json.loads(data)) dash_duo.start_server(app) dash_duo.wait_for_contains_text("#pre", json.dumps(return_value), timeout=4)
Example #2
Source File: dash-datatable-filter.py From dash-recipes with MIT License | 5 votes |
def display_filters(filters): return html.Pre(json.dumps(filters, indent=2))
Example #3
Source File: multiple-hover-data.py From dash-recipes with MIT License | 5 votes |
def updateContent(hoverData1, hoverData2): print(hoverData1) print(hoverData2) if hoverData1 is not None: return html.Div([ html.Div('Graph 1'), html.Pre(hoverData1) ]) if hoverData2 is not None: return html.Div([ html.Div('Graph 2'), html.Pre(hoverData1) ])
Example #4
Source File: dash-upload-simple.py From dash-recipes with MIT License | 5 votes |
def update_output(contents): if contents is not None: content_type, content_string = contents.split(',') if 'csv' in content_type: df = pd.read_csv(io.StringIO(base64.b64decode(content_string).decode('utf-8'))) return html.Div([ dt.DataTable(rows=df.to_dict('records')), html.Hr(), html.Div('Raw Content'), html.Pre(contents, style=pre_style) ]) elif 'image' in content_type: return html.Div([ html.Img(src=contents), html.Hr(), html.Div('Raw Content'), html.Pre(contents, style=pre_style) ]) else: # xlsx will have 'spreadsheet' in `content_type` but `xls` won't # have anything try: df = pd.read_excel(io.BytesIO(base64.b64decode(content_string))) return html.Div([ dt.DataTable(rows=df.to_dict('records')), html.Hr(), html.Div('Raw Content'), html.Pre(contents, style=pre_style) ]) except: return html.Div([ html.Hr(), html.Div('Raw Content'), html.Pre(contents, style=pre_style) ])
Example #5
Source File: dash-datatable-editable-update-self.py From dash-recipes with MIT License | 5 votes |
def display_output(row_update, rows): return html.Div(className='row', children=[ html.Div([ html.Code('row_update'), html.Pre(json.dumps(row_update, indent=2)) ], className='six columns'), html.Div([ html.Code('rows'), html.Pre(json.dumps(rows, indent=2)) ], className='six columns'), ])
Example #6
Source File: dash-pandas-filesystem-cache.py From dash-recipes with MIT License | 5 votes |
def serve_layout(): df = dataframe() return html.Div([ html.Pre(df.to_json()), html.Hr(), ])
Example #7
Source File: dash-cache-signal-session.py From dash-recipes with MIT License | 5 votes |
def display_value_2(value, session_id): df = get_dataframe(session_id) return html.Div([ 'Output 2 - Button has been clicked {} times'.format(value), html.Pre(df.to_csv()) ])
Example #8
Source File: dash-datatable-generate.py From dash-recipes with MIT License | 5 votes |
def update_output(rows): return html.Pre( json.dumps(rows, indent=2) )
Example #9
Source File: last_clicked_button.py From dash-docs with MIT License | 5 votes |
def display(btn1, btn2, btn3): ctx = dash.callback_context if not ctx.triggered: button_id = 'No clicks yet' else: button_id = ctx.triggered[0]['prop_id'].split('.')[0] ctx_msg = json.dumps({ 'states': ctx.states, 'triggered': ctx.triggered, 'inputs': ctx.inputs }, indent=2) return html.Div([ html.Table([ html.Tr([html.Th('Button 1'), html.Th('Button 2'), html.Th('Button 3'), html.Th('Most Recent Click')]), html.Tr([html.Td(btn1 or 0), html.Td(btn2 or 0), html.Td(btn3 or 0), html.Td(button_id)]) ]), html.Pre(ctx_msg) ])
Example #10
Source File: editing_prune_empty_cells.py From dash-docs with MIT License | 5 votes |
def display_output(rows): pruned_rows = [] for row in rows: # require that all elements in a row are specified # the pruning behavior that you need may be different than this if all([cell != '' for cell in row.values()]): pruned_rows.append(row) return html.Div([ html.Div('Raw Data'), html.Pre(pprint.pformat(rows)), html.Hr(), html.Div('Pruned Data'), html.Pre(pprint.pformat(pruned_rows)), ])
Example #11
Source File: sharing_state_filesystem_sessions.py From dash-docs with MIT License | 5 votes |
def display_value_1(value, session_id): df = get_dataframe(session_id) return html.Div([ 'Output 1 - Button has been clicked {} times'.format(value), html.Pre(df.to_csv()) ])
Example #12
Source File: sharing_state_filesystem_sessions.py From dash-docs with MIT License | 5 votes |
def display_value_2(value, session_id): df = get_dataframe(session_id) return html.Div([ 'Output 2 - Button has been clicked {} times'.format(value), html.Pre(df.to_csv()) ])
Example #13
Source File: upload-datafile.py From dash-docs with MIT License | 5 votes |
def parse_contents(contents, filename, date): content_type, content_string = contents.split(',') decoded = base64.b64decode(content_string) try: if 'csv' in filename: # Assume that the user uploaded a CSV file df = pd.read_csv( io.StringIO(decoded.decode('utf-8'))) elif 'xls' in filename: # Assume that the user uploaded an excel file df = pd.read_excel(io.BytesIO(decoded)) except Exception as e: print(e) return html.Div([ 'There was an error processing this file.' ]) return html.Div([ html.H5(filename), html.H6(datetime.datetime.fromtimestamp(date)), dash_table.DataTable( data=df.to_dict('records'), columns=[{'name': i, 'id': i} for i in df.columns] ), html.Hr(), # horizontal line # For debugging, display the raw contents provided by the web browser html.Div('Raw Content'), html.Pre(contents[0:200] + '...', style={ 'whiteSpace': 'pre-wrap', 'wordBreak': 'break-all' }) ])