dash , i would like some image instead of simple button in python, nothing image is added

Viewed 27

#simple code test button properties to add images on button i would like some image instead of simple button in python, nothing image is added#

from dash import Dash, dcc, html, Input, Output, State
app = Dash(__name__)
app.layout = html.Div([
    html.Div(dcc.Input(id='input-on-submit', type='text')),
    html.Button(children=[html.Img(r'/home/Documents/web/b.jpeg')], id='submit-val', n_clicks=0),
    html.Div(id='container-button-basic',
             children='Enter a value and press submit')
])


@app.callback(
    Output('container-button-basic', 'children'),
    Input('submit-val', 'n_clicks'),
    State('input-on-submit', 'value')
)
def update_output(n_clicks, value):
    return 'The input value was "{}" and the button has been clicked {} times'.format(
        value,
        n_clicks
    ) 
if __name__ == '__main__':
    app.run_server(debug=True)
1 Answers

Try using pygame or tkinter if you can, trying to import an image, this makes it a lot easier.

    img = pygame.image.load(img path)
    pygame.transform.scale(img, (height, width))
Related