當前位置: 首頁>>代碼示例>>Python>>正文


Python dash_html_components.Pre方法代碼示例

本文整理匯總了Python中dash_html_components.Pre方法的典型用法代碼示例。如果您正苦於以下問題:Python dash_html_components.Pre方法的具體用法?Python dash_html_components.Pre怎麽用?Python dash_html_components.Pre使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dash_html_components的用法示例。


在下文中一共展示了dash_html_components.Pre方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_surface_selector

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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) 
開發者ID:equinor,項目名稱:webviz-subsurface,代碼行數:18,代碼來源:test_surface_selector.py

示例2: display_filters

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
def display_filters(filters):
    return html.Pre(json.dumps(filters, indent=2)) 
開發者ID:plotly,項目名稱:dash-recipes,代碼行數:4,代碼來源:dash-datatable-filter.py

示例3: updateContent

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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)
        ]) 
開發者ID:plotly,項目名稱:dash-recipes,代碼行數:15,代碼來源:multiple-hover-data.py

示例4: update_output

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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)
                ]) 
開發者ID:plotly,項目名稱:dash-recipes,代碼行數:37,代碼來源:dash-upload-simple.py

示例5: display_output

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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'),
    ]) 
開發者ID:plotly,項目名稱:dash-recipes,代碼行數:13,代碼來源:dash-datatable-editable-update-self.py

示例6: serve_layout

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
def serve_layout():
    df = dataframe()
    return html.Div([
        html.Pre(df.to_json()),
        html.Hr(),
    ]) 
開發者ID:plotly,項目名稱:dash-recipes,代碼行數:8,代碼來源:dash-pandas-filesystem-cache.py

示例7: display_value_2

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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())
    ]) 
開發者ID:plotly,項目名稱:dash-recipes,代碼行數:8,代碼來源:dash-cache-signal-session.py

示例8: update_output

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
def update_output(rows):
    return html.Pre(
        json.dumps(rows, indent=2)
    ) 
開發者ID:plotly,項目名稱:dash-recipes,代碼行數:6,代碼來源:dash-datatable-generate.py

示例9: display

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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)
    ]) 
開發者ID:plotly,項目名稱:dash-docs,代碼行數:29,代碼來源:last_clicked_button.py

示例10: display_output

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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)),
    ]) 
開發者ID:plotly,項目名稱:dash-docs,代碼行數:17,代碼來源:editing_prune_empty_cells.py

示例11: display_value_1

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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())
    ]) 
開發者ID:plotly,項目名稱:dash-docs,代碼行數:8,代碼來源:sharing_state_filesystem_sessions.py

示例12: parse_contents

# 需要導入模塊: import dash_html_components [as 別名]
# 或者: from dash_html_components import Pre [as 別名]
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'
        })
    ]) 
開發者ID:plotly,項目名稱:dash-docs,代碼行數:38,代碼來源:upload-datafile.py


注:本文中的dash_html_components.Pre方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。