Non-interactive arguments in ipywidgets

Hi All,

@k-dominik @guiwitz

Do you know how to add a non-interactive argument to a function like below:

This works

@widgets.interact_manual(x=(0, 100))
def blur(x = 5):
    blurred = skimage.filters.gaussian(image, sigma=(x, x))
    plt.imshow(blurred)

This throws an error

@widgets.interact_manual(x=(0, 100))
def blur(image, x = 5):
    blurred = skimage.filters.gaussian(image, sigma=(x, x))
    plt.imshow(blurred)

ValueError: cannot find widget or abbreviation for argument: 'image’

I am sure there was a way to ignore the image parameter for ipywidgets, but I am googling the wrong keywords and thus cannot find it.

Hi @Christian_Tischer,

the usual thing to do is to use the ipywidgets fixed function, for example like this:

@widgets.interact_manual(x=(0, 100))
def blur(image = widgets.fixed(image), x = 5):
    blurred = skimage.filters.gaussian(image, sigma=(x, x))
    plt.imshow(blurred)

Like this, the image arguments is not turned into a widget. I hope that solves your problem!

3 Likes