Python dash_html_components.Span() Examples

The following are 30 code examples of dash_html_components.Span(). 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: _well_cross_section_fmu.py    From webviz-subsurface with GNU General Public License v3.0 7 votes vote down vote up
def surface_names_layout(self):
        return html.Div(
            style=self.set_style(marginTop="20px"),
            children=html.Label(
                children=[
                    html.Span("Surface:", style={"font-weight": "bold"}),
                    dcc.Dropdown(
                        id=self.ids("surfacenames"),
                        options=[
                            {"label": name, "value": name} for name in self.surfacenames
                        ],
                        value=self.surfacenames,
                        clearable=True,
                        multi=True,
                    ),
                ]
            ),
        ) 
Example #2
Source File: _reservoir_simulation_timeseries_onebyone.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def smry_selector(self):
        """Dropdown to select ensemble"""
        return html.Div(
            style={"paddingBottom": "30px"},
            children=html.Label(
                children=[
                    html.Span("Time series:", style={"font-weight": "bold"}),
                    dcc.Dropdown(
                        id=self.ids("vector"),
                        options=[
                            {
                                "label": f"{simulation_vector_description(vec)} ({vec})",
                                "value": vec,
                            }
                            for vec in self.smry_cols
                        ],
                        clearable=False,
                        value=self.initial_vector,
                    ),
                ]
            ),
        ) 
Example #3
Source File: run.py    From dash-docs with MIT License 6 votes vote down vote up
def create_backlinks(pathname):
    parts = pathname.strip('/').split('/')
    links = [
        dcc.Link('Home', href='/')
    ]
    for i, part in enumerate(parts[:-1]):
        href='/' + '/'.join(parts[:i + 1])
        name = chapter_index.URL_TO_BREADCRUMB_MAP.get(href, '? {} ?'.format(href))
        links += [
            html.Span(' > '),
            dcc.Link(name, href=href)
        ]
    current_chapter_name = chapter_index.URL_TO_BREADCRUMB_MAP.get(
        pathname.rstrip('/'), '? {} ?'.format(pathname)
    )
    links += [html.Span(' > ' + current_chapter_name)]
    return links 
Example #4
Source File: layout.py    From dtale with GNU Lesser General Public License v2.1 6 votes vote down vote up
def build_error(error, tb):
    """
    Returns error/traceback information in standard component with styling

    :param error: execption message
    :type error: str
    :param tb: tracebackF
    :type tb: str
    :return: error component
    :rtype: :dash:`dash_html_components.Div <dash-html-components/div>`
    """
    if isinstance(error, ChartBuildingError):
        if error.details:
            tb = error.details
        error = error.error
    return html.Div(
        [
            html.I(className="ico-error"),
            html.Span(str(error)),
            html.Div(html.Pre(str(tb)), className="traceback"),
        ],
        className="dtale-alert alert alert-danger",
    ) 
Example #5
Source File: layout.py    From dtale with GNU Lesser General Public License v2.1 6 votes vote down vote up
def build_mapbox_token_children():
    from dtale.charts.utils import get_mapbox_token

    msg = "To access additional styles enter a token here..."
    if get_mapbox_token() is None:
        msg = "Change your token here..."
    return [
        html.I(className="ico-help-outline", style=dict(color="white")),
        html.Div(
            [
                html.Span("Mapbox Access Token:"),
                dcc.Input(
                    id="mapbox-token-input",
                    type="text",
                    placeholder=msg,
                    className="form-control",
                    value="",
                    style={"lineHeight": "inherit"},
                ),
            ],
            className="hoverable__content",
            style=dict(width="20em", right="-1.45em"),
        ),
    ] 
Example #6
Source File: _parameter_distribution.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def layout(self):
        return html.Div(
            id=self.ids("layout"),
            children=[
                html.Span("Parameter distribution:", style={"font-weight": "bold"}),
                html.Div(
                    style=self.set_grid_layout("8fr 1fr 2fr"),
                    children=[
                        dcc.Dropdown(
                            id=self.ids("parameter"),
                            options=[
                                {"value": col, "label": col}
                                for col in self.parameter_columns
                            ],
                            value=self.parameter_columns[0],
                            clearable=False,
                        ),
                        self.make_buttons(self.ids("prev-btn"), self.ids("next-btn")),
                    ],
                ),
                wsc.PriorPosteriorDistribution(id=self.ids("graph")),
            ],
        ) 
Example #7
Source File: _well_cross_section.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def seismic_layout(self):
        return html.Div(
            style={} if self.segyfiles else {"display": "none"},
            children=html.Label(
                children=[
                    html.Span("Seismic:", style={"font-weight": "bold"}),
                    dcc.Dropdown(
                        id=self.ids("cube"),
                        options=[
                            {"label": Path(segy).stem, "value": segy}
                            for segy in self.segyfiles
                        ]
                        if self.segyfiles
                        else None,
                        value=self.segyfiles[0] if self.segyfiles else None,
                        clearable=False,
                    ),
                ]
            ),
        ) 
Example #8
Source File: _well_cross_section.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def well_layout(self):
        return html.Div(
            children=html.Label(
                children=[
                    html.Span("Well:", style={"font-weight": "bold"}),
                    dcc.Dropdown(
                        id=self.ids("wells"),
                        options=[
                            {"label": Path(well).stem, "value": well}
                            for well in self.wellfiles
                        ],
                        value=self.wellfiles[0],
                        clearable=False,
                    ),
                ]
            ),
        ) 
Example #9
Source File: _inplace_volumes_onebyone.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def response_selector(self):
        """Dropdown to select volumetric response"""
        return html.Div(
            children=html.Label(
                children=[
                    html.Span("Volumetric calculation:", style={"font-weight": "bold"}),
                    dcc.Dropdown(
                        id=self.uuid("response"),
                        options=[
                            {"label": volume_description(i), "value": i}
                            for i in self.responses
                        ],
                        clearable=False,
                        value=self.initial_response
                        if self.initial_response in self.responses
                        else self.responses[0],
                    ),
                ]
            ),
        ) 
Example #10
Source File: _inplace_volumes_onebyone.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def plot_selector(self):
        """Radiobuttons to select plot type"""
        return html.Div(
            children=[
                html.Span("Plot type:", style={"font-weight": "bold"}),
                dcc.Dropdown(
                    id=self.uuid("plot-type"),
                    options=[
                        {"label": i, "value": i}
                        for i in [
                            "Per realization",
                            "Per sensitivity name",
                            "Per sensitivity case",
                        ]
                    ],
                    value="Per realization",
                    clearable=False,
                ),
            ]
        ) 
Example #11
Source File: _well_cross_section_fmu.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def seismic_layout(self):
        if self.segyfiles:
            return html.Div(
                style=self.set_style(marginTop="20px")
                if self.segyfiles
                else {"display": "none"},
                children=html.Label(
                    children=[
                        html.Span("Seismic:", style={"font-weight": "bold"}),
                        dcc.Dropdown(
                            id=self.ids("cube"),
                            options=[
                                {"label": Path(segy).stem, "value": segy}
                                for segy in self.segyfiles
                            ],
                            value=self.segyfiles[0],
                            clearable=False,
                        ),
                    ]
                ),
            )
        return html.Div(
            style={"visibility": "hidden"}, children=dcc.Dropdown(id=self.ids("cube"))
        ) 
Example #12
Source File: multi-page-dropdown.py    From dash-recipes with MIT License 6 votes vote down vote up
def display_page(pathname):
    return html.Div([
        html.Div([
            html.Span(
                dcc.Link(link_mapping['/'], href="/") if pathname != '/' else 'Exhibit A',
                style=styles['link']
            ),

            html.Span(
                dcc.Link(link_mapping['/exhibit-b'], href="/exhibit-b") if pathname != '/exhibit-b' else 'Exhibit B',
                style=styles['link']
            ),

            html.Span(
                dcc.Link(link_mapping['/exhibit-c'], href="/exhibit-c") if pathname != '/exhibit-c' else 'Exhibit C',
                style=styles['link']
            )

        ]),

        dcc.Markdown('### {}'.format(link_mapping[pathname])),
    ]) 
Example #13
Source File: _well_cross_section_fmu.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def well_layout(self):
        return html.Div(
            children=html.Label(
                children=[
                    html.Span("Well:", style={"font-weight": "bold"}),
                    dcc.Dropdown(
                        id=self.ids("wells"),
                        options=[
                            {"label": Path(well).stem, "value": well}
                            for well in self.wellfiles
                        ],
                        value=self.wellfiles[0],
                        clearable=False,
                    ),
                ]
            )
        ) 
Example #14
Source File: _well_cross_section_fmu.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def ensemble_layout(self):
        return html.Div(
            style=self.set_style(marginTop="20px"),
            children=html.Label(
                children=[
                    html.Span("Ensemble:", style={"font-weight": "bold"}),
                    dcc.Dropdown(
                        id=self.ids("ensembles"),
                        options=[
                            {"label": ens, "value": ens}
                            for ens in self.ensembles.keys()
                        ],
                        value=list(self.ensembles.keys())[0],
                        clearable=False,
                        multi=False,
                    ),
                ]
            ),
        ) 
Example #15
Source File: _well_cross_section_fmu.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def marginal_log_layout(self):
        if self.marginal_logs is not None:
            return html.Div(
                children=html.Label(
                    children=[
                        html.Span("Marginal log:", style={"font-weight": "bold"}),
                        dcc.Dropdown(
                            id=self.ids("marginal-log"),
                            options=[
                                {"label": log, "value": log}
                                for log in self.marginal_logs
                            ],
                            placeholder="Display log",
                            clearable=True,
                        ),
                    ]
                ),
            )
        return html.Div(
            style={"visibility": "hidden"},
            children=dcc.Dropdown(id=self.ids("marginal-log")),
        ) 
Example #16
Source File: layout.py    From dtale with GNU Lesser General Public License v2.1 5 votes vote down vote up
def build_proj_hover(proj):
    return html.Span(
        [
            "Projection",
            html.Div(
                build_proj_hover_children(proj),
                className="ml-3 hoverable",
                style=dict(display="none")
                if proj is None
                else dict(borderBottom="none"),
                id="proj-hover",
            ),
        ],
        className="input-group-addon",
    ) 
Example #17
Source File: dash_mess.py    From socialsentiment with MIT License 5 votes vote down vote up
def update_related_terms(sentiment_term):
    try:

        # get data from cache
        for i in range(100):
            related_terms = cache.get('related_terms', sentiment_term) # term: {mean sentiment, count}
            if related_terms:
                break
            time.sleep(0.1)

        if not related_terms:
            return None

        buttons = [html.Button('{}({})'.format(term, related_terms[term][1]), id='related_term_button', value=term, className='btn', type='submit', style={'background-color':'#4CBFE1',
                                                                                                                                                           'margin-right':'5px',
                                                                                                                                                           'margin-top':'5px'}) for term in related_terms]
        #size: related_terms[term][1], sentiment related_terms[term][0]
        

        sizes = [related_terms[term][1] for term in related_terms]
        smin = min(sizes)
        smax = max(sizes) - smin  

        buttons = [html.H5('Terms related to "{}": '.format(sentiment_term), style={'color':app_colors['text']})]+[html.Span(term, style={'color':sentiment_colors[round(related_terms[term][0]*2)/2],
                                                              'margin-right':'15px',
                                                              'margin-top':'15px',
                                                              'font-size':'{}%'.format(generate_size(related_terms[term][1], smin, smax))}) for term in related_terms]


        return buttons
        

    except Exception as e:
        with open('errors.txt','a') as f:
            f.write(str(e))
            f.write('\n')


#recent-trending div
# term: [sent, size] 
Example #18
Source File: layout.py    From dtale with GNU Lesser General Public License v2.1 5 votes vote down vote up
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",
    ) 
Example #19
Source File: _example_tour.py    From webviz-config with MIT License 5 votes vote down vote up
def layout(self) -> html.Div:
        return html.Div(
            children=[
                html.Span(
                    "Here is some blue text to explain... ",
                    id=self.uuid("blue_text"),
                    style={"color": "blue"},
                ),
                html.Span(
                    " ...and here is some red text that also needs an explanation.",
                    id=self.uuid("red_text"),
                    style={"color": "red"},
                ),
            ]
        ) 
Example #20
Source File: layout.py    From dtale with GNU Lesser General Public License v2.1 5 votes vote down vote up
def build_loc_mode_hover(loc_mode):
    return html.Span(
        [
            html.Span("Location Mode", style=dict(whiteSpace="pre-line")),
            html.Div(
                build_loc_mode_hover_children(loc_mode),
                className="ml-3 hoverable",
                style=dict(display="none")
                if loc_mode is None
                else dict(borderBottom="none"),
                id="loc-mode-hover",
            ),
        ],
        className="input-group-addon pt-1 pb-0",
    ) 
Example #21
Source File: layout.py    From dtale with GNU Lesser General Public License v2.1 5 votes vote down vote up
def build_mapbox_token_hover():
    return html.Span(
        [
            "Style",
            html.Div(
                build_mapbox_token_children(),
                className="ml-3 hoverable",
                style=dict(borderBottom="none"),
                id="token-hover",
            ),
        ],
        className="input-group-addon",
    ) 
Example #22
Source File: test_integration.py    From sd-material-ui with MIT License 5 votes vote down vote up
def test_flat_button(self):
        app = dash.Dash(__name__)

        app.layout = html.Div([
            html.Div(id='waitfor'),
            sd_material_ui.SDFlatButton('test', id='flat-button'),
            html.Div(children=[
                html.Span('num clicks:'),
                html.Span(0, id='test-span-output'),
            ], id='test-output')
        ])

        @app.callback(
            output=Output(component_id='test-span-output', component_property='children'),
            inputs=[Input(component_id='flat-button', component_property='n_clicks')])
        def click_button(n_clicks: int) -> int:
            if n_clicks is not None and n_clicks > 0:
                return n_clicks

        self.startServer(app)

        waiter(self.wait_for_element_by_id)

        self.driver.find_element_by_css_selector('#flat-button button').click()
        self.assertEqual(self.driver.find_element_by_id('test-span-output').text, '1')

        self.driver.find_element_by_css_selector('#flat-button button').click()
        self.assertEqual(self.driver.find_element_by_id('test-span-output').text, '2') 
Example #23
Source File: _parameter_parallel_coordinates.py    From webviz-subsurface with GNU General Public License v3.0 5 votes vote down vote up
def control_layout(self):
        """Layout to select ensembles and parameters"""
        return html.Div(
            children=[
                html.Div(
                    [
                        html.Span("Selected ensembles:", style={"font-weight": "bold"}),
                        wcc.Select(
                            id=self.uuid("ensembles"),
                            options=[
                                {"label": ens, "value": ens} for ens in self.ensembles
                            ],
                            multi=True,
                            value=self.ensembles,
                            size=len(self.ensembles),
                        ),
                    ]
                ),
                html.Div(
                    [
                        html.Span(
                            "Selected parameters:", style={"font-weight": "bold"}
                        ),
                        wcc.Select(
                            id=self.uuid("parameters"),
                            style={"overflowX": "auto", "fontSize": "0.97rem"},
                            options=[
                                {"label": param, "value": param}
                                for param in self.parameters
                            ],
                            multi=True,
                            value=self.visual_parameters,
                            size=min(50, len(self.visual_parameters)),
                        ),
                    ]
                ),
            ],
        ) 
Example #24
Source File: utils.py    From dtale with GNU Lesser General Public License v2.1 5 votes vote down vote up
def build_input(
    label, input, className="col-auto", label_class="input-group-addon", **kwargs
):
    """
    Helper function to build a standard label/input component in dash.

    :param label: name of the input you are displaying
    :type label: str
    :param input: dash component for storing state
    :param className: style class to be applied to encapsulating div
    :type className: str
    :param kwargs: Optional keyword arguments to be applied to encapsulating div (style, title, id...)
    :type kwargs: dict
    :return: dash components for label/input
    :rtype: :dash:`dash_html_components.Div <dash-html-components/div>`
    """
    return html.Div(
        [
            html.Div(
                [html.Span(label, className=label_class), input],
                className="input-group mr-3",
            )
        ],
        className=className,
        **kwargs
    ) 
Example #25
Source File: custom_geojson.py    From dtale with GNU Lesser General Public License v2.1 5 votes vote down vote up
def build_modal(map_type, loc_mode):
    return html.Div(
        [
            html.Div(
                html.Span(
                    html.Span("GeoJSON Options", style=dict(whiteSpace="pre-line")),
                    className="input-group-addon d-block pt-1 pb-0 pointer",
                ),
                className="input-group mr-3",
                id="open-geojson-modal",
            ),
            dbc.Modal(
                [
                    dbc.ModalHeader("Custom GeoJSON Options"),
                    dbc.ModalBody(build_geojson_upload(loc_mode)),
                    dbc.ModalFooter(
                        dbc.Button(
                            "Close", id="close-geojson-modal", className="ml-auto"
                        )
                    ),
                ],
                id="geojson-modal",
                size="lg",
                centered=True,
            ),
        ],
        className="col-auto",
        style={}
        if map_type == "choropleth" and loc_mode == "geojson-id"
        else {"display": "none"},
        id="custom-geojson-input",
    ) 
Example #26
Source File: test_integration.py    From sd-material-ui with MIT License 5 votes vote down vote up
def test_raised_button(self):
        app = dash.Dash(__name__)

        app.layout = html.Div([
            html.Div(id='waitfor'),
            sd_material_ui.SDRaisedButton('test', id='raised-button'),
            html.Div(children=[
                html.Span('num clicks:'),
                html.Span(0, id='test-span-output'),
            ], id='test-output')
        ])

        @app.callback(
            output=Output(component_id='test-span-output', component_property='children'),
            inputs=[Input(component_id='raised-button', component_property='n_clicks')])
        def click_button(n_clicks: int) -> int:
            if n_clicks is not None and n_clicks > 0:
                return n_clicks

        self.startServer(app)

        waiter(self.wait_for_element_by_id)

        self.driver.find_element_by_css_selector('#raised-button button').click()
        self.assertEqual(self.driver.find_element_by_id('test-span-output').text, '1')

        self.driver.find_element_by_css_selector('#raised-button button').click()
        self.assertEqual(self.driver.find_element_by_id('test-span-output').text, '2') 
Example #27
Source File: _well_cross_section.py    From webviz-subsurface with GNU General Public License v3.0 5 votes vote down vote up
def well_options(self):
        return html.Div(
            style={"marginLeft": "20px", "marginRight": "0px", "marginBotton": "0px"},
            children=[
                html.Div(
                    children=html.Label(
                        children=[
                            html.Span("Sampling:", style={"font-weight": "bold"}),
                            dcc.Input(
                                id=self.ids("sampling"),
                                debounce=True,
                                type="number",
                                value=self.sampling,
                            ),
                        ]
                    )
                ),
                html.Div(
                    children=html.Label(
                        children=[
                            html.Span("Nextend:", style={"font-weight": "bold"}),
                            dcc.Input(
                                id=self.ids("nextend"),
                                debounce=True,
                                type="number",
                                value=self.nextend,
                            ),
                        ]
                    )
                ),
            ],
        ) 
Example #28
Source File: qb_stats.py    From qb with MIT License 5 votes vote down vote up
def display_question(question: Question):
    return html.Div([
        html.Label('ID'), html.Span(question.qnum)
    ]) 
Example #29
Source File: _inplace_volumes.py    From webviz-subsurface with GNU General Public License v3.0 4 votes vote down vote up
def plot_options_layout(self):
        """Row layout of dropdowns for plot options"""
        return wcc.FlexBox(
            children=[
                html.Div(
                    children=html.Label(
                        children=[
                            html.Span("Response:", style={"font-weight": "bold"}),
                            dcc.Dropdown(
                                id=self.ids("response"),
                                options=[
                                    {"label": volume_description(i), "value": i}
                                    for i in self.responses
                                ],
                                value=self.initial_response
                                if self.initial_response in self.responses
                                else self.responses[0],
                                clearable=False,
                            ),
                        ]
                    )
                ),
                html.Div(
                    children=html.Label(
                        children=[
                            html.Span("Plot type:", style={"font-weight": "bold"}),
                            dcc.Dropdown(
                                id=self.ids("plot-type"),
                                options=[
                                    {"label": i, "value": i} for i in self.plot_types
                                ],
                                value=self.initial_plot,
                                clearable=False,
                            ),
                        ]
                    )
                ),
                html.Div(
                    children=html.Label(
                        children=[
                            html.Span("Group by:", style={"font-weight": "bold"}),
                            dcc.Dropdown(
                                id=self.ids("group"),
                                options=[
                                    {"label": i.lower().capitalize(), "value": i}
                                    for i in self.selectors
                                ],
                                value=self.initial_group,
                                placeholder="Not grouped",
                            ),
                        ]
                    )
                ),
            ],
        ) 
Example #30
Source File: _inplace_volumes.py    From webviz-subsurface with GNU General Public License v3.0 4 votes vote down vote up
def layout(self):
        """Main layout"""
        return html.Div(
            children=[
                wcc.FlexBox(
                    id=self.ids("layout"),
                    children=[
                        html.Div(
                            style={"flex": 1},
                            children=[
                                html.Span("Filters:", style={"font-weight": "bold"}),
                                html.Div(
                                    id=self.ids("filters"),
                                    children=self.selector_dropdowns,
                                ),
                            ],
                        ),
                        html.Div(
                            style={"flex": 5},
                            children=[
                                self.plot_options_layout,
                                html.Div(
                                    style={"height": 400},
                                    children=wcc.Graph(id=self.ids("graph")),
                                ),
                                html.Div(
                                    children=[
                                        html.Div(
                                            id=self.ids("table_title"),
                                            style={"textAlign": "center"},
                                            children="",
                                        ),
                                        DataTable(
                                            id=self.ids("table"),
                                            sort_action="native",
                                            filter_action="native",
                                            page_action="native",
                                            page_size=10,
                                        ),
                                    ],
                                ),
                            ],
                        ),
                    ],
                ),
            ]
        )