Python dash_html_components.Button() Examples

The following are 27 code examples of dash_html_components.Button(). 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: dash-asynchronous.py    From dash-recipes with MIT License 7 votes vote down vote up
def layout():
    return html.Div([
        html.Button('Run Process', id='button'),
        dcc.Interval(id='interval', interval=500),
        html.Div(id='lock'),
        html.Div(id='output'),
    ]) 
Example #2
Source File: main.py    From deep_architect with MIT License 6 votes vote down vote up
def __init__(self, parent_name, local_name):
        Component.__init__(self, parent_name, local_name)
        self.log_selector = LogSelectorDropdown(self.full_name, 'log_selector')
        self.dimension_controls = Scatter2DDimensionControls(
            self.full_name, 'dimension_controls')
        # self.filter_selector = FilterSelectorDropdown(self.full_name, 'filter_selector')
        self.delete_button = Button(self.full_name, 'delete_button',
                                    'Delete Row')
        self.notes = Notes(self.full_name, 'notes')
        self._register(
            full_column([
                self.notes.get_layout(),
                # horizontal_separator(),
                self.log_selector.get_layout(),
                # horizontal_separator(),
                self.dimension_controls.get_layout(),
                # horizontal_separator(),
                # self.filter_selector.get_layout(),
            ])) 
Example #3
Source File: dash-callback-factory.py    From dash-recipes with MIT License 6 votes vote down vote up
def divs_list():
    return [html.Div([
        dcc.Markdown(
            '',
            id='model-{}-markdown'.format(id)
        ),
        html.P(
            '',
            id='model-{}-p'.format(id)
        ),
        html.Button(
            'Delete',
            id='model-{}-delete-button'.format(id),
            style={'width': '49%'}
        ),
        html.Button(
            'Start/Stop',
            id='model-{}-toggle-button'.format(id),
            style={'marginLeft': '2%', 'width': '49%'}
        ),

        html.Hr()
    ], id='model-k2-{}'.format(id)) for id in IDS] 
Example #4
Source File: surface_selector.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def _make_buttons(self, prev_id, next_id):
        return html.Div(
            style=self.set_grid_layout("1fr 1fr"),
            children=[
                html.Button(
                    style={
                        "fontSize": "2rem",
                        "paddingLeft": "5px",
                        "paddingRight": "5px",
                    },
                    id=prev_id,
                    children="⬅",
                ),
                html.Button(
                    style={
                        "fontSize": "2rem",
                        "paddingLeft": "5px",
                        "paddingRight": "5px",
                    },
                    id=next_id,
                    children="➡",
                ),
            ],
        ) 
Example #5
Source File: _parameter_distribution.py    From webviz-subsurface with GNU General Public License v3.0 6 votes vote down vote up
def make_buttons(self, prev_id, next_id):
        return html.Div(
            style=self.set_grid_layout("1fr 1fr"),
            children=[
                html.Button(
                    id=prev_id,
                    style={
                        "fontSize": "2rem",
                        "paddingLeft": "5px",
                        "paddingRight": "5px",
                    },
                    children="⬅",
                ),
                html.Button(
                    id=next_id,
                    style={
                        "fontSize": "2rem",
                        "paddingLeft": "5px",
                        "paddingRight": "5px",
                    },
                    children="➡",
                ),
            ],
        ) 
Example #6
Source File: layout.py    From japonicus with MIT License 5 votes vote down vote up
def getHeader(app):
    # this is a mess;
    inlineBlock = {"display": "inline-block"}
    headerWidgets = [
        html.Button("Refresh", id='refresh-button'),
        html.Div(
            [
                html.Div("Last refresh @ ", style=inlineBlock.update({"float": "left"})),
                html.Div(datetime.datetime.now(),
                         id='last-refresh', className="showTime",
                         style=inlineBlock.update({"float": "left"})),

                html.Div("%s Start time" % app.startTime,
                         id='start-time', className="showTime",
                         style=inlineBlock.update({"float": "right"})),
                html.Br(),
                html.Center([
                    html.Div(app.epochInfo, id="current-epoch")
                    ])
            ], className="showTime")
    ]

    pageMenu = [
        html.A(html.Button("Evolution Statistics"), href="/"),
        html.A(html.Button("Evaluation Breaks"), href="/evalbreak"),
        html.A(html.Button("View Results"), href="/results")
        # html.Button("View Settings", className="unimplemented"),
        # html.Button("Inspect Population", className="unimplemented")
    ]



    # html.Link(rel='stylesheet', href='/static/promoterz_style.css'),
    header = html.Div(
        [
            html.H2(
                app.webpageTitle,
                style={'padding-top': '20', 'text-align': 'center'},
            ),
            html.Div(headerWidgets),
            html.Div(pageMenu),
        ],
        style=allStyle)

    return header 
Example #7
Source File: main.py    From deep_architect with MIT License 5 votes vote down vote up
def __init__(self, parent_name, local_name, buttom_text):
        Component.__init__(self, parent_name, local_name)
        self._register(html.Button(id=self.full_name, children=buttom_text))
        # n_clicks if the property that should be used for on click events. 
Example #8
Source File: app.py    From lantern with Apache License 2.0 5 votes vote down vote up
def make_text(value):
    if value is None:
        value = 0

    return TEXTS[value]


# Button controls 
Example #9
Source File: sharing_state_filesystem_sessions.py    From dash-docs with MIT License 5 votes vote down vote up
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())
    ]) 
Example #10
Source File: sharing_state_filesystem_sessions.py    From dash-docs with MIT License 5 votes vote down vote up
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())
    ]) 
Example #11
Source File: sharing_state_filesystem_sessions.py    From dash-docs with MIT License 5 votes vote down vote up
def serve_layout():
    session_id = str(uuid.uuid4())

    return html.Div([
        html.Div(session_id, id='session-id', style={'display': 'none'}),
        html.Button('Get data', id='get-data-button'),
        html.Div(id='output-1'),
        html.Div(id='output-2')
    ]) 
Example #12
Source File: last_clicked_button.py    From dash-docs with MIT License 5 votes vote down vote up
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)
    ]) 
Example #13
Source File: basic-state.py    From dash-docs with MIT License 5 votes vote down vote up
def update_output(n_clicks, input1, input2):
    return u'''
        The Button has been pressed {} times,
        Input 1 is "{}",
        and Input 2 is "{}"
    '''.format(n_clicks, input1, input2) 
Example #14
Source File: common_features.py    From dash-bio with MIT License 5 votes vote down vote up
def nested_component_layout(
        component
):
    return [
        dcc.Input(id='prop-name'),
        dcc.Input(id='prop-value'),
        html.Div(id='pass-fail-div'),
        html.Button('Submit', id='submit-prop-button'),
        dcc.Graph(
            id='test-graph',
            figure=component
        )
    ] 
Example #15
Source File: common_features.py    From dash-bio with MIT License 5 votes vote down vote up
def simple_app_layout(
        component
):
    return [
        dcc.Input(id='prop-name'),
        dcc.Input(id='prop-value'),
        html.Div(id='pass-fail-div'),
        html.Button('Submit', id='submit-prop-button'),
        component
    ] 
Example #16
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 #17
Source File: _well_cross_section.py    From webviz-subsurface with GNU General Public License v3.0 5 votes vote down vote up
def layout(self):
        return html.Div(
            children=[
                html.Div(
                    style=self.set_grid_layout("1fr 1fr 1fr 1fr 1fr"),
                    children=[
                        self.well_layout,
                        self.well_options,
                        self.seismic_layout,
                        self.viz_options_layout,
                        html.Button(id=self.ids("show_map"), children="Show map",),
                    ],
                ),
                html.Div(
                    id=self.ids("viz_wrapper"),
                    style={"position": "relative"},
                    children=[
                        html.Div(
                            id=self.ids("map_wrapper"),
                            style={
                                "position": "absolute",
                                "width": "30%",
                                "height": "40%",
                                "right": 0,
                                "zIndex": 10000,
                                "visibility": "hidden",
                            },
                            children=LayeredMap(
                                height=400, id=self.ids("map"), layers=[]
                            ),
                        ),
                        wcc.Graph(id=self.ids("graph")),
                    ],
                ),
            ],
        ) 
Example #18
Source File: _example_plugin.py    From webviz-config with MIT License 5 votes vote down vote up
def set_callbacks(self, app: Dash) -> None:
        @app.callback(
            Output(self.uuid("output-state"), "children"),
            [Input(self.uuid("submit-button"), "n_clicks")],
        )
        def _update_output(n_clicks: int) -> str:
            return f"Button has been pressed {n_clicks} times." 
Example #19
Source File: _example_plugin.py    From webviz-config with MIT License 5 votes vote down vote up
def layout(self) -> html.Div:
        return html.Div(
            [
                html.H1(self.title),
                html.Button(
                    id=self.uuid("submit-button"), n_clicks=0, children="Submit"
                ),
                html.Div(id=self.uuid("output-state")),
            ]
        ) 
Example #20
Source File: dash-click.py    From dash-recipes with MIT License 5 votes vote down vote up
def clicks(n_clicks):
    return 'Button has been clicked {} times'.format(n_clicks) 
Example #21
Source File: dash-which-button.py    From dash-recipes with MIT License 5 votes vote down vote up
def update_output(b1_timestamp, b2_timestamp):
    if b1_timestamp > b2_timestamp:
        return '''
            Button 1 Was Clicked
            (Button 1 timestamp: {}. Button 2 timestamp: {}.)
        '''.format(b1_timestamp, b2_timestamp)
    else:
        return '''
            Button 2 Was Clicked
            (Button 1 timestamp: {}. Button 2 timestamp: {}.)
        '''.format(b1_timestamp, b2_timestamp) 
Example #22
Source File: dash-cache-signal-session.py    From dash-recipes with MIT License 5 votes vote down vote up
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())
    ]) 
Example #23
Source File: dash-cache-signal-session.py    From dash-recipes with MIT License 5 votes vote down vote up
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())
    ]) 
Example #24
Source File: dash-cache-signal-session.py    From dash-recipes with MIT License 5 votes vote down vote up
def serve_layout():
    session_id = str(uuid.uuid4())

    return html.Div(style={'marginLeft': 80}, children=[
        html.Div(session_id, id='session-id', style={'display': 'none'}),
        html.Button('Get data', id='button'),
        html.Div(id='output-1'),
        html.Div(id='output-2')
    ]) 
Example #25
Source File: main.py    From deep_architect with MIT License 5 votes vote down vote up
def __init__(self, parent_name, local_name):
        Component.__init__(self, parent_name, local_name)
        # self.add_row_dropdown = Dropdown(self.full_name, 'add_row_dropdown',
        #     'Select row type.')
        self.add_row_button = Button(self.full_name, 'add_button', 'Add Row')
        # self.copy_row_dropdown = Dropdown(self.full_name, )
        self._register(
            full_column([
                # Text(self.full_name, 'title', 'Row').get_layout(),
                self.add_row_button.get_layout()
            ])) 
Example #26
Source File: dash_mess.py    From socialsentiment with MIT License 4 votes vote down vote up
def update_recent_trending(sentiment_term):
    try:
        query = """
                SELECT
                        value
                FROM
                        misc
                WHERE
                        key = 'trending'
        """

        c = conn.cursor()

        result = c.execute(query).fetchone()

        related_terms = pickle.loads(result[0])



##        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('Recently Trending Terms: ', 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') 
Example #27
Source File: _well_cross_section_fmu.py    From webviz-subsurface with GNU General Public License v3.0 4 votes vote down vote up
def layout(self):
        return wcc.FlexBox(
            children=[
                html.Div(
                    style={"flex": 1},
                    children=[
                        self.well_layout,
                        self.surface_names_layout,
                        self.seismic_layout,
                        self.ensemble_layout,
                        self.marginal_log_layout,
                        self.intersection_option,
                    ],
                ),
                html.Div(
                    id=self.ids("viz_wrapper"),
                    style={"position": "relative", "flex": 8},
                    children=[
                        html.Div(wcc.Graph(id=self.ids("graph"))),
                        html.Div(
                            id=self.ids("map_wrapper"),
                            style={
                                "position": "absolute",
                                "width": "30%",
                                "height": "40%",
                                "right": 100,
                                "top": 350,
                                "zIndex": 10000,
                                "visibility": "hidden",
                            },
                            children=[
                                self.map_layout,
                                LayeredMap(height=400, id=self.ids("map"), layers=[]),
                            ],
                        ),
                        html.Button(
                            style={"float": "right"},
                            id=self.ids("show_map"),
                            children="Show map",
                        ),
                        dcc.Store(id=self.ids("fencespec"), data=[]),
                    ],
                ),
            ],
        )