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


Python dash_core_components.Location方法代码示例

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


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

示例1: display_page

# 需要导入模块: import dash_core_components [as 别名]
# 或者: from dash_core_components import Location [as 别名]
def display_page(pathname):
    print(pathname)
    if pathname == '/':
        return html.Div([
            html.Div('You are on the index page.'),

            # the dcc.Link component updates the `Location` pathname
            # without refreshing the page
            dcc.Link(html.A('Go to page 2 without refreshing!'), href="/page-2", style={'color': 'blue', 'text-decoration': 'none'}),
            html.Hr(),
            html.A('Go to page 2 but refresh the page', href="/page-2")
        ])
    elif pathname == '/page-2':
        return html.Div([
            html.H4('Welcome to Page 2'),
            dcc.Link(html.A('Go back home'), href="/"),
        ])
    else:
        return html.Div('I guess this is like a 404 - no content available')

# app.css.append_css({"external_url": "https://codepen.io/chriddyp/pen/bWLwgP.css"}) 
开发者ID:plotly,项目名称:dash-recipes,代码行数:23,代码来源:multi_page.py

示例2: main_layout_sidebar

# 需要导入模块: import dash_core_components [as 别名]
# 或者: from dash_core_components import Location [as 别名]
def main_layout_sidebar():
    """Dash layout with a sidebar"""
    return html.Div(
        [
            dbc.Container(
                fluid=True,
                children=dbc.Row(
                    [
                        dbc.Col(
                            make_sidebar(className="px-2"), width=2, className="px-0"
                        ),
                        dbc.Col(id=server.config["CONTENT_CONTAINER_ID"], width=10),
                    ]
                ),
            ),
            dcc.Location(id=server.config["LOCATION_COMPONENT_ID"], refresh=False),
        ]
    ) 
开发者ID:ned2,项目名称:slapdash,代码行数:20,代码来源:layouts.py

示例3: add_dash

# 需要导入模块: import dash_core_components [as 别名]
# 或者: from dash_core_components import Location [as 别名]
def add_dash(server):
    """
    Adds dash support to main D-Tale Flask process.

    :param server: main D-Tale Flask process
    :type server: :class:`flask:flask.Flask`
    :return: server with dash added
    :rtype: :class:`flask:flask.Flask`
    """

    dash_app = DtaleDash(
        server=server, routes_pathname_prefix="/charts/", eager_loading=True
    )

    # Since we're adding callbacks to elements that don't exist in the app.layout,
    # Dash will raise an exception to warn us that we might be
    # doing something wrong.
    # In this case, we're adding the elements through a callback, so we can ignore
    # the exception.
    dash_app.config.suppress_callback_exceptions = True
    dash_app.layout = html.Div(
        [dcc.Location(id="url", refresh=False), html.Div(id="popup-content")]
    )
    dash_app.scripts.config.serve_locally = True
    dash_app.css.config.serve_locally = True

    init_callbacks(dash_app)

    return dash_app.server 
开发者ID:man-group,项目名称:dtale,代码行数:31,代码来源:views.py

示例4: main_layout_header

# 需要导入模块: import dash_core_components [as 别名]
# 或者: from dash_core_components import Location [as 别名]
def main_layout_header():
    """Dash layout with a top-header"""
    return html.Div(
        [
            make_header(),
            dbc.Container(
                dbc.Row(dbc.Col(id=server.config["CONTENT_CONTAINER_ID"])), fluid=True
            ),
            dcc.Location(id=server.config["LOCATION_COMPONENT_ID"], refresh=False),
        ]
    ) 
开发者ID:ned2,项目名称:slapdash,代码行数:13,代码来源:layouts.py

示例5: create_app

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

示例6: getLayout

# 需要导入模块: import dash_core_components [as 别名]
# 或者: from dash_core_components import Location [as 别名]
def getLayout(app):
    layout = html.Div([
        dcc.Location(id='url', refresh=False),
        getHeader(app),
        html.Div(id='page-content')
    ])
    return layout 
开发者ID:Gab0,项目名称:japonicus,代码行数:9,代码来源:layout.py


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