Module: viewer.widgets

Widgets for interacting with ImageViewer.

These widgets should be added to a Plugin subclass using its add_widget method or calling:

plugin += Widget(...)

on a Plugin instance. The Plugin will delegate action based on the widget’s parameter type specified by its ptype attribute, which can be:

'arg' : positional argument passed to Plugin's `filter_image` method.
'kwarg' : keyword argument passed to Plugin's `filter_image` method.
'plugin' : attribute of Plugin. You'll probably need to add a class
    property of the same name that updates the display.
skimage.viewer.widgets.BaseWidget(name[, ...])
skimage.viewer.widgets.Button(name, callback) Button which calls callback upon click.
skimage.viewer.widgets.CheckBox(name[, ...]) CheckBox widget
skimage.viewer.widgets.ComboBox(name, items) ComboBox widget for selecting among a list of choices.
skimage.viewer.widgets.OKCancelButtons([...]) Buttons that close the parent plugin.
skimage.viewer.widgets.SaveButtons([name, ...]) Buttons to save image to io.stack or to a file.
skimage.viewer.widgets.Slider(name[, low, ...]) Slider widget for adjusting numeric parameters.
skimage.viewer.widgets.Text([name, text])

BaseWidget

class skimage.viewer.widgets.BaseWidget(name, ptype=None, callback=None)[source]

Bases: object

__init__(name, ptype=None, callback=None)[source]
plugin = 'Widget is not attached to a Plugin.'
val

Button

class skimage.viewer.widgets.Button(name, callback)[source]

Bases: skimage.viewer.widgets.core.BaseWidget

Button which calls callback upon click.

Parameters:

name : str

Name of button.

callback : callable f()

Function to call when button is clicked.

__init__(name, callback)[source]

CheckBox

class skimage.viewer.widgets.CheckBox(name, value=False, alignment='center', ptype='kwarg', callback=None)[source]

Bases: skimage.viewer.widgets.core.BaseWidget

CheckBox widget

Parameters:

name : str

Name of CheckBox parameter. If this parameter is passed as a keyword argument, it must match the name of that keyword argument (spaces are replaced with underscores). In addition, this name is displayed as the name of the CheckBox.

value: {False, True}, optional

Initial state of the CheckBox.

alignment: {‘center’,’left’,’right’}, optional

Checkbox alignment

ptype : {‘arg’ | ‘kwarg’ | ‘plugin’}, optional

Parameter type

callback : callable f(widget_name, value), optional

Callback function called in response to checkbox changes. Note: This function is typically set (overridden) when the widget is added to a plugin.

__init__(name, value=False, alignment='center', ptype='kwarg', callback=None)[source]
val

ComboBox

class skimage.viewer.widgets.ComboBox(name, items, ptype='kwarg', callback=None)[source]

Bases: skimage.viewer.widgets.core.BaseWidget

ComboBox widget for selecting among a list of choices.

Parameters:

name : str

Name of ComboBox parameter. If this parameter is passed as a keyword argument, it must match the name of that keyword argument (spaces are replaced with underscores). In addition, this name is displayed as the name of the ComboBox.

items: list of str

Allowed parameter values.

ptype : {‘arg’ | ‘kwarg’ | ‘plugin’}, optional

Parameter type.

callback : callable f(widget_name, value), optional

Callback function called in response to combobox changes. Note: This function is typically set (overridden) when the widget is added to a plugin.

__init__(name, items, ptype='kwarg', callback=None)[source]
index
val

OKCancelButtons

class skimage.viewer.widgets.OKCancelButtons(button_width=80)[source]

Bases: skimage.viewer.widgets.core.BaseWidget

Buttons that close the parent plugin.

OK will replace the original image with the current (filtered) image. Cancel will just close the plugin.

__init__(button_width=80)[source]
close_plugin()[source]
update_original_image()[source]

SaveButtons

class skimage.viewer.widgets.SaveButtons(name='Save to:', default_format='png')[source]

Bases: skimage.viewer.widgets.core.BaseWidget

Buttons to save image to io.stack or to a file.

__init__(name='Save to:', default_format='png')[source]
save_to_file(filename=None)[source]
save_to_stack()[source]

Slider

class skimage.viewer.widgets.Slider(name, low=0.0, high=1.0, value=None, value_type='float', ptype='kwarg', callback=None, max_edit_width=60, orientation='horizontal', update_on='release')[source]

Bases: skimage.viewer.widgets.core.BaseWidget

Slider widget for adjusting numeric parameters.

Parameters:

name : str

Name of slider parameter. If this parameter is passed as a keyword argument, it must match the name of that keyword argument (spaces are replaced with underscores). In addition, this name is displayed as the name of the slider.

low, high : float

Range of slider values.

value : float

Default slider value. If None, use midpoint between low and high.

value_type : {‘float’ | ‘int’}, optional

Numeric type of slider value.

ptype : {‘kwarg’ | ‘arg’ | ‘plugin’}, optional

Parameter type.

callback : callable f(widget_name, value), optional

Callback function called in response to slider changes. Note: This function is typically set (overridden) when the widget is added to a plugin.

orientation : {‘horizontal’ | ‘vertical’}, optional

Slider orientation.

update_on : {‘release’ | ‘move’}, optional

Control when callback function is called: on slider move or release.

__init__(name, low=0.0, high=1.0, value=None, value_type='float', ptype='kwarg', callback=None, max_edit_width=60, orientation='horizontal', update_on='release')[source]
val

Text

class skimage.viewer.widgets.Text(name=None, text='')[source]

Bases: skimage.viewer.widgets.core.BaseWidget

__init__(name=None, text='')[source]
text