Python Plotly - Add customised button to ModeBar

In Javascript plotly one can add customised buttons to Plotly’s ModeBar. See for example this pen. The same seems to be possible in R.

How does one do this in Python?
A minimal example of how I would expect this to work is


import plotly.graph_objects as go
import plotly.io as pio
pio.renderers.default = "browser"

fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3],
                         y=[1, 3, 1]))

fig.show(config=dict({'displaylogo': True,
                      'scrollZoom': True,
                      # 'modeBarButtonsToAdd': [
                      #     dict(name="my_button",
                      #          icon=dict(path='download-button.svg',
                      #                    transform='scale(0.5)'),
                      #          click="() => { alert('new button!'); }"
                      #          )
                      #                         ]
                      }))

However uncommenting the commented lines results in an empty figure. Am I doing something wrong here or is there a completely different approach?

Hi @lucamingarelli

unfortunately I do not think that is possible in python, but maybe I am missing something: