modeBarButtonsToAdd requires 'button name'

Hi there,

I was just recreating the steps from this tutorial Interactive annotations and shape drawing in plotly figures and Dash apps | Interactive image processing with scikit-image and Dash where I am interested in making annotations to images. I also had a look at Images in Python to achieve this. Since I am relatively new to Dash, I was just following along and playing with the content.

In the second example, the line:

fig.show(config={'modeBarButtonsToAdd': ['drawline', 'drawrect', 'eraseshape']})

is responsible for opening a new tab in my browser, allowing me to annotate the image with the tools ‘drawline’, ‘drawrect’ and ‘eraseshape’. This is nice, but I need more “stuff” around the figure, so the fig.show() won’t help me further. Thus I added the figure to the layout. However, if I pass these buttons to the dcc.Graph() function (like in the first link that I provided):

dcc.Graph(
                id='annotation_plane',
                figure=fig,
                config={'modeBarButtonsToAdd': ['drawline', 'drawrect', 'eraseshape']})

I get an error from dash, stating:

:no_entry: must provide button ‘name’ in button config

How could I add a name to the button? Where would I do this? I was already trying to provide a dict of buttons and their names
config={'modeBarButtonsToAdd': {'drawline' : 'draw_ln', 'drawrect': 'draw_rect', 'eraseshape': 'erase_shp'}}resulting in the error, that a list is required, not a dict. Also, there is no parameter 'ButtonNames' in the list of possible parameters.

How can I get this to work? Dash is just too good, but without this, I can’t really use it…

Thanks for your help and best regards,
Martin

Could you try upgrading Dash?

Hi @martin.poellot, welcome to the forum! As @chriddyp says, I think the first thing to try is to upgrade your version of Dash (old versions of Dash use old versions of the plotly.js Javascript library, even if you have installed a recent version of the Python library plotly.py).

Thank you for your fast reply! Actually, since I just started using Dash, I am using the latest version 1.16.1 for dash and plotly version 4.10.0.

I noticed, however, that PyCharm was downloading v1.14 for dash and the venv (which I use) had 1.16, so the error is completely on my side!

Thanks for your help and sorry for bothering you with such a stupid oversight by my side.

Best regards,
Martin