roudan
roudan

Reputation: 4208

how to change html.Img() style in callback?

I am using html.Img(src='image.png',style={'height':'300px', 'width':'100%') to add image.

I'd like to change image size in callback for different images, one thing I can think of is to change style of image to change image size in callback. I don't know how to change style of Img component in callback. Thanks for help.

here is the code in callback

define html.Img() component first

    html_img_well = html.Img(id = 'html-img', src = '',
                                style={'height':'300px', 'width':'100%'}) 

in cabllback


@app.callback(
    [
        Output("html-img", 'src'),
    ],

def change_dts_sql_plot():

image_well='assets/'+wellname+'_image.PNG'

return seismic_image_well

Upvotes: 1

Views: 2214

Answers (1)

coralvanda
coralvanda

Reputation: 6596

You should be able to do this:

Output("html-img", 'style'),

and then use a callback, the same one even if you wanted (multiple outputs) to change the style. You could also put the Img component inside a div, and then update the div's children property with a new html.Img each time, allowing you to set all the properties.

Upvotes: 2

Related Questions