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(parent, …)

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(parent, flags, …)

skimage.viewer.widgets.core

skimage.viewer.widgets.history

BaseWidget

class skimage.viewer.widgets.BaseWidget(parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags())[source]

Bases: PyQt5.QtWidgets.QWidget

__init__(self, name, ptype=None, callback=None)[source]

Initialize self. See help(type(self)) for accurate signature.

plugin = 'Widget is not attached to a Plugin.'
property val

Button

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

Bases: skimage.viewer.widgets.core.BaseWidget

Button which calls callback upon click.

Parameters
namestr

Name of button.

callbackcallable f()

Function to call when button is clicked.

__init__(self, name, callback)[source]

Initialize self. See help(type(self)) for accurate signature.

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
namestr

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

callbackcallable 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__(self, name, value=False, alignment='center', ptype='kwarg', callback=None)[source]

Initialize self. See help(type(self)) for accurate signature.

property 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
namestr

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.

callbackcallable 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__(self, name, items, ptype='kwarg', callback=None)[source]

Initialize self. See help(type(self)) for accurate signature.

property index
property 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__(self, button_width=80)[source]

Initialize self. See help(type(self)) for accurate signature.

close_plugin(self)[source]
update_original_image(self)[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__(self, name='Save to:', default_format='png')[source]

Initialize self. See help(type(self)) for accurate signature.

save_to_file(self, filename=None)[source]
save_to_stack(self)[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
namestr

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, highfloat

Range of slider values.

valuefloat

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.

callbackcallable 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__(self, 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]

Initialize self. See help(type(self)) for accurate signature.

property val

Text

class skimage.viewer.widgets.Text(parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags())[source]

Bases: skimage.viewer.widgets.core.BaseWidget

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

Initialize self. See help(type(self)) for accurate signature.

property text