当前位置: 首页>>代码示例>>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;未经允许,请勿转载。