当前位置: 首页>>代码示例>>Python>>正文


Python dash_html_components.Img方法代码示例

本文整理汇总了Python中dash_html_components.Img方法的典型用法代码示例。如果您正苦于以下问题:Python dash_html_components.Img方法的具体用法?Python dash_html_components.Img怎么用?Python dash_html_components.Img使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dash_html_components的用法示例。


在下文中一共展示了dash_html_components.Img方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_output

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [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

示例2: layout

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def layout(self) -> html.Img:
        return html.Img(src=self.asset_url) 
开发者ID:equinor,项目名称:webviz-config,代码行数:4,代码来源:_example_assets.py

示例3: build_proj_hover_children

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def build_proj_hover_children(proj):
    if proj is None:
        return None
    return [
        html.I(className="ico-help-outline", style=dict(color="white")),
        html.Div(
            [html.Div(proj), html.Img(src=build_img_src(proj))],
            className="hoverable__content",
            style=dict(width="auto"),
        ),
    ] 
开发者ID:man-group,项目名称:dtale,代码行数:13,代码来源:layout.py

示例4: build_map_type_tabs

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def build_map_type_tabs(map_type):
    def _build_hoverable():
        for t in MAP_TYPES:
            if t.get("image", False):
                yield html.Div(
                    [
                        html.Span(t.get("label", t["value"].capitalize())),
                        html.Img(src=build_img_src(t["value"], img_type="map_type")),
                    ],
                    className="col-md-6",
                )

    return html.Div(
        [
            dcc.Tabs(
                id="map-type-tabs",
                value=map_type or "choropleth",
                children=[
                    build_tab(t.get("label", t["value"].capitalize()), t["value"])
                    for t in MAP_TYPES
                ],
                style=dict(height="36px"),
            ),
            html.Div(
                html.Div(list(_build_hoverable()), className="row"),
                className="hoverable__content map-types",
            ),
        ],
        style=dict(paddingLeft=15, borderBottom="none", width="20em"),
        className="hoverable",
    ) 
开发者ID:man-group,项目名称:dtale,代码行数:33,代码来源:layout.py

示例5: parse_contents

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def parse_contents(contents, filename, date):
    return html.Div([
        html.H5(filename),
        html.H6(datetime.datetime.fromtimestamp(date)),

        # HTML images accept base64 encoded strings in the same format
        # that is supplied by the upload
        html.Img(src=contents),
        html.Hr(),
        html.Div('Raw Content'),
        html.Pre(contents[0:200] + '...', style={
            'whiteSpace': 'pre-wrap',
            'wordBreak': 'break-all'
        })
    ]) 
开发者ID:plotly,项目名称:dash-docs,代码行数:17,代码来源:upload-image.py

示例6: DisplayImagePIL

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def DisplayImagePIL(id, image, **kwargs):
    encoded_image = pil_to_b64(image, enc_format='png')

    return html.Img(
        id=f'img-{id}',
        src=HTML_IMG_SRC_PARAMETERS + encoded_image,
        width='100%',
        **kwargs
    ) 
开发者ID:plotly,项目名称:dash-image-processing,代码行数:11,代码来源:dash_reusable_components.py

示例7: create_app

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def create_app(dir_name):
        def encode(name):
            path = os.path.join(
                os.path.dirname(__file__),
                'screenshots',
                dir_name,
                name
            )

            with open(path, 'rb') as image_file:
                encoded_string = base64.b64encode(image_file.read())
            return "data:image/png;base64," + encoded_string.decode('ascii')

        # Define the app
        app = dash.Dash(__name__)

        app.layout = html.Div([
            # represents the URL bar, doesn't render anything
            dcc.Location(id='url', refresh=False),
            # content will be rendered in this element
            html.Div(id='page-content')
        ])

        @app.callback(dash.dependencies.Output('page-content', 'children'),
                      [dash.dependencies.Input('url', 'pathname')])
        def display_image(pathname):  # pylint: disable=W0612
            """
            Assign the url path to return the image it represent. For example,
            to return "usage.png", you can visit localhost/usage.png.
            :param pathname: name of the screenshot, prefixed with "/"
            :return: An html.Img object containing the base64 encoded image
            """
            if not pathname or pathname == '/':
                return None

            name = pathname.replace('/', '')
            return html.Img(id=name, src=encode(name))

        return app 
开发者ID:plotly,项目名称:dash-cytoscape,代码行数:41,代码来源:test_percy_snapshot.py

示例8: get_logo

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def get_logo():
    logo = html.Div([

        html.Div([
            html.Img(src='http://logonoid.com/images/vanguard-logo.png', height='40', width='160')
        ], className="ten columns padded"),

        html.Div([
            dcc.Link('Full View   ', href='/full-view')
        ], className="two columns page-view no-print")

    ], className="row gs-header")
    return logo 
开发者ID:timkpaine,项目名称:lantern,代码行数:15,代码来源:app.py

示例9: build_banner

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def build_banner():
    return html.Div(
        id="banner",
        className="banner",
        children=[
            html.Img(src=app.get_asset_url("logo_programmer_a.png")),
            html.H6("时空数据——时空分布动态"),
        ],
    ) 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:11,代码来源:app.py

示例10: imageComponentBlock

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def imageComponentBlock(
        example_string,
        location,
        height=None,
        width=400
):
    '''Generate a container that is visually similar to the
    ComponentBlock for components that require an externally hosted image.

    :param (str) example_string: String containing the code that is
    used in the application from the image.
    :param (str) location: The URL of the image.
    :param (int) height: The height of the image.
    :param (int) width: The width of the image.

    :rtype (dict): A dash_html_components div containing the code
    container and the image.

    '''

    try:
        exec(example_string, {})
    except Exception as e:
        print('\nError running\n{}\n{}'.format(
            example_string,
            ('======================================' +
             '======================================')
        ))
        raise e

    demo_location = re.match('.*pic_(.*)\.png\?raw=true', location)

    if demo_location is not None:
        demo_location = demo_location.group(1)
    else:
        demo_location = ''

    return html.Div([
        rc.Markdown(
            '```python  \n' + example_string + '  \n```',
            style=styles.code_container
        ),
        html.Div(
            className='example-container',
            children=[
                dcc.Markdown(
                    '> Try a live demo at http://dash-gallery.plotly.host/docs-demos-dashbio/{}'.format(demo_location, demo_location)
                ),
                html.Img(
                    style={'border': 'none', 'width': '75%', 'max-width': '500px'},
                    src=location
                )
            ]
        )
    ]) 
开发者ID:plotly,项目名称:dash-docs,代码行数:57,代码来源:utils.py

示例11: convert_to_html

# 需要导入模块: import dash_html_components [as 别名]
# 或者: from dash_html_components import Img [as 别名]
def convert_to_html(component):
    if component is None:
        return ''
    if not isinstance(component, Component):
        # likely a str, int, float
        return str(component)
    component_dict = component.to_plotly_json()
    if component_dict['type'] == 'Link':
        component_dict['namespace'] = 'dash_html_components'
        component_dict['type'] = 'A'

    if component_dict['namespace'] != 'dash_html_components':
        component = dcc_to_html(component)
        component_dict = component.to_plotly_json()
    tag = component_dict['type'].lower()
    attrib_str = ['='.join([_translate_attrib(k).lower(),
                            '"{}"'.format(_translate_attrib(v))])
                  for k, v in component_dict['props'].items()
                  if _translate_attrib(k).lower()
                  not in ['style', 'children'] + bool_html_attrs]
    attrib_str = ' '.join(attrib_str)
    bool_str, style_str = '', ''
    bool_attrs = []
    for bool_attr in component_dict['props']:
        if _translate_attrib(bool_attr).lower() in bool_html_attrs:
            if bool(component_dict['props'][bool_attr]):
                bool_attrs.append(_translate_attrib(bool_attr).lower())
        bool_str = ' '.join(bool_attrs)
    if 'style' in component_dict['props']:
        style_str = 'style=' + _style_to_attrib(component_dict['props']['style'])
    attrib_str = ' '.join([attrib_str, style_str, bool_str]).strip()
    initial_indent = 0

    comp_children = component_dict['props'].get('children', None)
    if comp_children:
        if isinstance(comp_children, (tuple, list)):
            children = '\n' + '\n'.join([re.sub('^', '\g<0>' + (' ' * i if tag not in list_tags else ' ' * 2),
                                            convert_to_html(child))
                                            for i, child in enumerate(comp_children)])
        else:
            children = convert_to_html(comp_children)
    else:
        # e.g. html.Img doesn't have any children
        children = ''

    initial_indent += 2
    closing_tag = '\n</{}>'.format(tag) if tag not in empty_tags else ''
    attrib_str = ' ' + attrib_str if attrib_str else ''
    return '<{}{}>{}{}'.format(tag, attrib_str, children, closing_tag) 
开发者ID:plotly,项目名称:dash-docs,代码行数:51,代码来源:convert_to_html.py


注:本文中的dash_html_components.Img方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。