Skip to content

ndv.views.bases #

Abstract base classes for views and viewable objects.

Classes:

  • ArrayCanvas

    ABC for canvases that show array data.

  • ArrayView

    ABC for ND Array viewers widget.

  • CanvasElement

    Protocol defining an interactive element on the Canvas.

  • HistogramCanvas

    A histogram-based view for LookUp Table (LUT) adjustment.

  • LUTView

    Manages LUT properties (contrast, colormap, etc...) in a view object.

  • Mouseable

    Mixin class for objects that can be interacted with using the mouse.

  • NDVApp

    Base class for application wrappers.

  • RectangularROIHandle

    An axis-aligned rectanglular ROI.

  • Viewable

    ABC representing anything that can be viewed on screen.

ArrayCanvas #

ArrayCanvas(viewer_model: ArrayViewerModel | None = ...)

Bases: GraphicsCanvas

ABC for canvases that show array data.

Methods:

  • canvas_to_world

    Map XY canvas position (pixels) to XYZ coordinate in world space.

  • close

    Close the view/widget.

  • frontend_widget

    Return the native object backing the viewable objects.

  • set_range

    Sets the bounds of the camera.

  • set_scales

    Set per-visible-axis scale factors for rendering.

  • set_visible

    Sets the visibility of the view/widget itself.

  • zoom

    Zoom in (or out) at the given center (world coordinates).

Source code in src/ndv/views/bases/_graphics/_canvas.py
56
57
@abstractmethod
def __init__(self, viewer_model: ArrayViewerModel | None = ...) -> None: ...

canvas_to_world abstractmethod #

canvas_to_world(
    pos_xy: tuple[float, float],
) -> tuple[float, float, float]

Map XY canvas position (pixels) to XYZ coordinate in world space.

Source code in src/ndv/views/bases/_graphics/_canvas.py
40
41
42
43
44
@abstractmethod
def canvas_to_world(
    self, pos_xy: tuple[float, float]
) -> tuple[float, float, float]:
    """Map XY canvas position (pixels) to XYZ coordinate in world space."""

close abstractmethod #

close() -> None

Close the view/widget.

Source code in src/ndv/views/bases/_view_base.py
19
20
21
@abstractmethod
def close(self) -> None:
    """Close the view/widget."""

frontend_widget abstractmethod #

frontend_widget() -> Any

Return the native object backing the viewable objects.

Source code in src/ndv/views/bases/_view_base.py
11
12
13
@abstractmethod
def frontend_widget(self) -> Any:
    """Return the native object backing the viewable objects."""

set_range abstractmethod #

set_range(
    x: tuple[float, float] | None = None,
    y: tuple[float, float] | None = None,
    z: tuple[float, float] | None = None,
    margin: float = ...,
) -> None

Sets the bounds of the camera.

Source code in src/ndv/views/bases/_graphics/_canvas.py
26
27
28
29
30
31
32
33
34
35
@abstractmethod
def set_range(
    self,
    x: tuple[float, float] | None = None,
    y: tuple[float, float] | None = None,
    z: tuple[float, float] | None = None,
    margin: float = ...,
) -> None:
    """Sets the bounds of the camera."""
    ...

set_scales #

set_scales(scales: tuple[float, ...]) -> None

Set per-visible-axis scale factors for rendering.

Source code in src/ndv/views/bases/_graphics/_canvas.py
68
69
def set_scales(self, scales: tuple[float, ...]) -> None:
    """Set per-visible-axis scale factors for rendering."""

set_visible abstractmethod #

set_visible(visible: bool) -> None

Sets the visibility of the view/widget itself.

Source code in src/ndv/views/bases/_view_base.py
15
16
17
@abstractmethod
def set_visible(self, visible: bool) -> None:
    """Sets the visibility of the view/widget itself."""

zoom #

zoom(
    factor: float | tuple, center: tuple[float, float]
) -> None

Zoom in (or out) at the given center (world coordinates).

Source code in src/ndv/views/bases/_graphics/_canvas.py
37
38
def zoom(self, factor: float | tuple, center: tuple[float, float]) -> None:
    """Zoom in (or out) at the given center (world coordinates)."""

ArrayView #

ArrayView(
    canvas_widget: Any,
    viewer_model: ArrayViewerModel,
    **kwargs: Any,
)

Bases: Viewable

ABC for ND Array viewers widget.

Currently, this is the "main" widget that contains the array display and all the controls for interacting with the array, including sliders, LUTs, and histograms.

Methods:

  • close

    Close the view/widget.

  • frontend_widget

    Return the native object backing the viewable objects.

  • set_visible

    Sets the visibility of the view/widget itself.

Source code in src/ndv/views/bases/_array_view.py
37
38
39
40
41
42
43
@abstractmethod
def __init__(
    self,
    canvas_widget: Any,
    viewer_model: ArrayViewerModel,
    **kwargs: Any,
) -> None: ...

close abstractmethod #

close() -> None

Close the view/widget.

Source code in src/ndv/views/bases/_view_base.py
19
20
21
@abstractmethod
def close(self) -> None:
    """Close the view/widget."""

frontend_widget abstractmethod #

frontend_widget() -> Any

Return the native object backing the viewable objects.

Source code in src/ndv/views/bases/_view_base.py
11
12
13
@abstractmethod
def frontend_widget(self) -> Any:
    """Return the native object backing the viewable objects."""

set_visible abstractmethod #

set_visible(visible: bool) -> None

Sets the visibility of the view/widget itself.

Source code in src/ndv/views/bases/_view_base.py
15
16
17
@abstractmethod
def set_visible(self, visible: bool) -> None:
    """Sets the visibility of the view/widget itself."""

CanvasElement #

Bases: Mouseable

Protocol defining an interactive element on the Canvas.

Methods:

  • can_select

    Defines whether the element can be selected.

  • remove

    Removes the element from the canvas.

  • selected

    Returns element selection status.

  • set_selected

    Sets element selection status.

  • set_visible

    Sets element visibility.

  • visible

    Defines whether the element is visible on the canvas.

can_select abstractmethod #

can_select() -> bool

Defines whether the element can be selected.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
33
34
35
@abstractmethod
def can_select(self) -> bool:
    """Defines whether the element can be selected."""

remove #

remove() -> None

Removes the element from the canvas.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
45
46
def remove(self) -> None:
    """Removes the element from the canvas."""

selected abstractmethod #

selected() -> bool

Returns element selection status.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
37
38
39
@abstractmethod
def selected(self) -> bool:
    """Returns element selection status."""

set_selected abstractmethod #

set_selected(selected: bool) -> None

Sets element selection status.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
41
42
43
@abstractmethod
def set_selected(self, selected: bool) -> None:
    """Sets element selection status."""

set_visible abstractmethod #

set_visible(visible: bool) -> None

Sets element visibility.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
29
30
31
@abstractmethod
def set_visible(self, visible: bool) -> None:
    """Sets element visibility."""

visible abstractmethod #

visible() -> bool

Defines whether the element is visible on the canvas.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
25
26
27
@abstractmethod
def visible(self) -> bool:
    """Defines whether the element is visible on the canvas."""

HistogramCanvas #

Bases: GraphicsCanvas, LUTView

A histogram-based view for LookUp Table (LUT) adjustment.

Methods:

  • canvas_to_world

    Map XY canvas position (pixels) to XYZ coordinate in world space.

  • close

    Close the view/widget.

  • frontend_widget

    Return the native object backing the viewable objects.

  • highlight

    Highlights a domain value on the histogram.

  • set_channel_name

    Set the name of the channel to name.

  • set_channel_visible

    Check or uncheck the visibility indicator of the LUT.

  • set_clim_bounds

    Defines the minimum and maximum possible values for the clims.

  • set_clim_policy

    Set the clim policy to policy.

  • set_clims

    Set the (low, high) contrast limits to clims.

  • set_colormap

    Set the colormap to cmap.

  • set_data

    Sets the histogram data.

  • set_fallback_name

    Set the data-derived or default fallback name for this channel.

  • set_gamma

    Set the gamma value of the LUT.

  • set_log_base

    Sets the axis scale of the range.

  • set_range

    Sets the bounds of the camera.

  • set_vertical

    If True, orient axes vertically (x-axis on left).

  • set_visible

    Sets the visibility of the view/widget itself.

  • synchronize

    Aligns the view against the backing model.

  • zoom

    Zoom in (or out) at the given center (world coordinates).

canvas_to_world abstractmethod #

canvas_to_world(
    pos_xy: tuple[float, float],
) -> tuple[float, float, float]

Map XY canvas position (pixels) to XYZ coordinate in world space.

Source code in src/ndv/views/bases/_graphics/_canvas.py
40
41
42
43
44
@abstractmethod
def canvas_to_world(
    self, pos_xy: tuple[float, float]
) -> tuple[float, float, float]:
    """Map XY canvas position (pixels) to XYZ coordinate in world space."""

close abstractmethod #

close() -> None

Close the view/widget.

Source code in src/ndv/views/bases/_view_base.py
19
20
21
@abstractmethod
def close(self) -> None:
    """Close the view/widget."""

frontend_widget abstractmethod #

frontend_widget() -> Any

Return the native object backing the viewable objects.

Source code in src/ndv/views/bases/_view_base.py
11
12
13
@abstractmethod
def frontend_widget(self) -> Any:
    """Return the native object backing the viewable objects."""

highlight #

highlight(value: float | None) -> None

Highlights a domain value on the histogram.

Source code in src/ndv/views/bases/_graphics/_canvas.py
 99
100
def highlight(self, value: float | None) -> None:
    """Highlights a domain value on the histogram."""

set_channel_name abstractmethod #

set_channel_name(name: str) -> None

Set the name of the channel to name.

Source code in src/ndv/views/bases/_lut_view.py
20
21
22
@abstractmethod
def set_channel_name(self, name: str) -> None:
    """Set the name of the channel to `name`."""

set_channel_visible abstractmethod #

set_channel_visible(visible: bool) -> None

Check or uncheck the visibility indicator of the LUT.

Usually corresponds to a checkbox.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
73
74
75
76
77
78
79
80
@abstractmethod
def set_channel_visible(self, visible: bool) -> None:
    """Check or uncheck the visibility indicator of the LUT.

    Usually corresponds to a checkbox.

    Note that this method must not modify the backing LUTModel.
    """

set_clim_bounds #

set_clim_bounds(
    bounds: tuple[float | None, float | None] = (
        None,
        None,
    ),
) -> None

Defines the minimum and maximum possible values for the clims.

Source code in src/ndv/views/bases/_lut_view.py
67
68
69
70
71
def set_clim_bounds(
    self,
    bounds: tuple[float | None, float | None] = (None, None),
) -> None:
    """Defines the minimum and maximum possible values for the clims."""

set_clim_policy abstractmethod #

set_clim_policy(policy: ClimPolicy) -> None

Set the clim policy to policy.

Usually corresponds to an "autoscale" checkbox.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
40
41
42
43
44
45
46
47
@abstractmethod
def set_clim_policy(self, policy: ClimPolicy) -> None:
    """Set the clim policy to `policy`.

    Usually corresponds to an "autoscale" checkbox.

    Note that this method must not modify the backing LUTModel.
    """

set_clims abstractmethod #

set_clims(clims: tuple[float, float]) -> None

Set the (low, high) contrast limits to clims.

Usually this will be a range slider or two text boxes.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
58
59
60
61
62
63
64
65
@abstractmethod
def set_clims(self, clims: tuple[float, float]) -> None:
    """Set the (low, high) contrast limits to `clims`.

    Usually this will be a range slider or two text boxes.

    Note that this method must not modify the backing LUTModel.
    """

set_colormap abstractmethod #

set_colormap(cmap: Colormap) -> None

Set the colormap to cmap.

Usually corresponds to a dropdown menu.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
49
50
51
52
53
54
55
56
@abstractmethod
def set_colormap(self, cmap: cmap.Colormap) -> None:
    """Set the colormap to `cmap`.

    Usually corresponds to a dropdown menu.

    Note that this method must not modify the backing LUTModel.
    """

set_data #

set_data(values: ndarray, bin_edges: ndarray) -> None

Sets the histogram data.

Properties

values : np.ndarray The histogram values. bin_edges : np.ndarray The bin edges of the histogram.

Source code in src/ndv/views/bases/_graphics/_canvas.py
88
89
90
91
92
93
94
95
96
97
def set_data(self, values: np.ndarray, bin_edges: np.ndarray) -> None:
    """Sets the histogram data.

    Properties
    ----------
    values : np.ndarray
        The histogram values.
    bin_edges : np.ndarray
        The bin edges of the histogram.
    """

set_fallback_name #

set_fallback_name(name: str) -> None

Set the data-derived or default fallback name for this channel.

The display name resolves as: lut.name if set, else fallback_name.

Source code in src/ndv/views/bases/_lut_view.py
24
25
26
27
28
29
30
def set_fallback_name(self, name: str) -> None:
    """Set the data-derived or default fallback name for this channel.

    The display name resolves as: `lut.name` if set, else `fallback_name`.
    """
    self._fallback_name = name
    self._refresh_display_name()

set_gamma #

set_gamma(gamma: float) -> None

Set the gamma value of the LUT.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
82
83
84
85
86
87
def set_gamma(self, gamma: float) -> None:
    """Set the gamma value of the LUT.

    Note that this method must not modify the backing LUTModel.
    """
    return None

set_log_base #

set_log_base(base: float | None) -> None

Sets the axis scale of the range.

Properties

enabled : bool If true, the range will be displayed with a logarithmic (base 10) scale. If false, the range will be displayed with a linear scale.

Source code in src/ndv/views/bases/_graphics/_canvas.py
78
79
80
81
82
83
84
85
86
def set_log_base(self, base: float | None) -> None:
    """Sets the axis scale of the range.

    Properties
    ----------
    enabled : bool
        If true, the range will be displayed with a logarithmic (base 10)
        scale. If false, the range will be displayed with a linear scale.
    """

set_range abstractmethod #

set_range(
    x: tuple[float, float] | None = None,
    y: tuple[float, float] | None = None,
    z: tuple[float, float] | None = None,
    margin: float = ...,
) -> None

Sets the bounds of the camera.

Source code in src/ndv/views/bases/_graphics/_canvas.py
26
27
28
29
30
31
32
33
34
35
@abstractmethod
def set_range(
    self,
    x: tuple[float, float] | None = None,
    y: tuple[float, float] | None = None,
    z: tuple[float, float] | None = None,
    margin: float = ...,
) -> None:
    """Sets the bounds of the camera."""
    ...

set_vertical #

set_vertical(vertical: bool) -> None

If True, orient axes vertically (x-axis on left).

Source code in src/ndv/views/bases/_graphics/_canvas.py
75
76
def set_vertical(self, vertical: bool) -> None:
    """If True, orient axes vertically (x-axis on left)."""

set_visible abstractmethod #

set_visible(visible: bool) -> None

Sets the visibility of the view/widget itself.

Source code in src/ndv/views/bases/_view_base.py
15
16
17
@abstractmethod
def set_visible(self, visible: bool) -> None:
    """Sets the visibility of the view/widget itself."""

synchronize #

synchronize() -> None

Aligns the view against the backing model.

Source code in src/ndv/views/bases/_lut_view.py
116
117
118
119
120
121
122
123
124
def synchronize(self) -> None:
    """Aligns the view against the backing model."""
    if model := self._model:
        self.set_clim_policy(model.clims)
        self.set_clim_bounds(model.clim_bounds)
        self.set_colormap(model.cmap)
        self.set_gamma(model.gamma)
        self.set_channel_visible(model.visible)
    self._refresh_display_name()

zoom #

zoom(
    factor: float | tuple, center: tuple[float, float]
) -> None

Zoom in (or out) at the given center (world coordinates).

Source code in src/ndv/views/bases/_graphics/_canvas.py
37
38
def zoom(self, factor: float | tuple, center: tuple[float, float]) -> None:
    """Zoom in (or out) at the given center (world coordinates)."""

LUTView #

Bases: Viewable

Manages LUT properties (contrast, colormap, etc...) in a view object.

Methods:

close abstractmethod #

close() -> None

Close the view/widget.

Source code in src/ndv/views/bases/_view_base.py
19
20
21
@abstractmethod
def close(self) -> None:
    """Close the view/widget."""

frontend_widget abstractmethod #

frontend_widget() -> Any

Return the native object backing the viewable objects.

Source code in src/ndv/views/bases/_view_base.py
11
12
13
@abstractmethod
def frontend_widget(self) -> Any:
    """Return the native object backing the viewable objects."""

set_channel_name abstractmethod #

set_channel_name(name: str) -> None

Set the name of the channel to name.

Source code in src/ndv/views/bases/_lut_view.py
20
21
22
@abstractmethod
def set_channel_name(self, name: str) -> None:
    """Set the name of the channel to `name`."""

set_channel_visible abstractmethod #

set_channel_visible(visible: bool) -> None

Check or uncheck the visibility indicator of the LUT.

Usually corresponds to a checkbox.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
73
74
75
76
77
78
79
80
@abstractmethod
def set_channel_visible(self, visible: bool) -> None:
    """Check or uncheck the visibility indicator of the LUT.

    Usually corresponds to a checkbox.

    Note that this method must not modify the backing LUTModel.
    """

set_clim_bounds #

set_clim_bounds(
    bounds: tuple[float | None, float | None] = (
        None,
        None,
    ),
) -> None

Defines the minimum and maximum possible values for the clims.

Source code in src/ndv/views/bases/_lut_view.py
67
68
69
70
71
def set_clim_bounds(
    self,
    bounds: tuple[float | None, float | None] = (None, None),
) -> None:
    """Defines the minimum and maximum possible values for the clims."""

set_clim_policy abstractmethod #

set_clim_policy(policy: ClimPolicy) -> None

Set the clim policy to policy.

Usually corresponds to an "autoscale" checkbox.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
40
41
42
43
44
45
46
47
@abstractmethod
def set_clim_policy(self, policy: ClimPolicy) -> None:
    """Set the clim policy to `policy`.

    Usually corresponds to an "autoscale" checkbox.

    Note that this method must not modify the backing LUTModel.
    """

set_clims abstractmethod #

set_clims(clims: tuple[float, float]) -> None

Set the (low, high) contrast limits to clims.

Usually this will be a range slider or two text boxes.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
58
59
60
61
62
63
64
65
@abstractmethod
def set_clims(self, clims: tuple[float, float]) -> None:
    """Set the (low, high) contrast limits to `clims`.

    Usually this will be a range slider or two text boxes.

    Note that this method must not modify the backing LUTModel.
    """

set_colormap abstractmethod #

set_colormap(cmap: Colormap) -> None

Set the colormap to cmap.

Usually corresponds to a dropdown menu.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
49
50
51
52
53
54
55
56
@abstractmethod
def set_colormap(self, cmap: cmap.Colormap) -> None:
    """Set the colormap to `cmap`.

    Usually corresponds to a dropdown menu.

    Note that this method must not modify the backing LUTModel.
    """

set_fallback_name #

set_fallback_name(name: str) -> None

Set the data-derived or default fallback name for this channel.

The display name resolves as: lut.name if set, else fallback_name.

Source code in src/ndv/views/bases/_lut_view.py
24
25
26
27
28
29
30
def set_fallback_name(self, name: str) -> None:
    """Set the data-derived or default fallback name for this channel.

    The display name resolves as: `lut.name` if set, else `fallback_name`.
    """
    self._fallback_name = name
    self._refresh_display_name()

set_gamma #

set_gamma(gamma: float) -> None

Set the gamma value of the LUT.

Note that this method must not modify the backing LUTModel.

Source code in src/ndv/views/bases/_lut_view.py
82
83
84
85
86
87
def set_gamma(self, gamma: float) -> None:
    """Set the gamma value of the LUT.

    Note that this method must not modify the backing LUTModel.
    """
    return None

set_visible abstractmethod #

set_visible(visible: bool) -> None

Sets the visibility of the view/widget itself.

Source code in src/ndv/views/bases/_view_base.py
15
16
17
@abstractmethod
def set_visible(self, visible: bool) -> None:
    """Sets the visibility of the view/widget itself."""

synchronize #

synchronize() -> None

Aligns the view against the backing model.

Source code in src/ndv/views/bases/_lut_view.py
116
117
118
119
120
121
122
123
124
def synchronize(self) -> None:
    """Aligns the view against the backing model."""
    if model := self._model:
        self.set_clim_policy(model.clims)
        self.set_clim_bounds(model.clim_bounds)
        self.set_colormap(model.cmap)
        self.set_gamma(model.gamma)
        self.set_channel_visible(model.visible)
    self._refresh_display_name()

Mouseable #

Mixin class for objects that can be interacted with using the mouse.

The signals here are to be emitted by the view object that inherits this class; usually by intercepting native mouse events with filter_mouse_events.

The methods allow the object to handle its own mouse events before emitting the signals. If the method returns True, the event is considered handled and should not be passed to the next receiver in the chain.

NDVApp #

Base class for application wrappers.

Methods:

  • call_in_main_thread

    Call func in the main gui thread.

  • call_later

    Call func after msec milliseconds.

  • create_app

    Create the application instance, if not already created.

  • filter_key_events

    Install key event filter on widget, emitting receiver.keyPressed.

  • filter_mouse_events

    Install mouse event filter on canvas, redirecting events to receiver.

  • get_executor

    Return an executor for running tasks in the background.

  • process_events

    Process events for the application.

  • run

    Run the application.

call_in_main_thread #

call_in_main_thread(
    func: Callable[P, T], *args: args, **kwargs: kwargs
) -> Future[T]

Call func in the main gui thread.

Source code in src/ndv/views/bases/_app.py
59
60
61
62
63
64
65
def call_in_main_thread(
    self, func: Callable[P, T], *args: P.args, **kwargs: P.kwargs
) -> Future[T]:
    """Call `func` in the main gui thread."""
    future: Future[T] = Future()
    future.set_result(func(*args, **kwargs))
    return future

call_later #

call_later(msec: int, func: Callable[[], None]) -> None

Call func after msec milliseconds.

Source code in src/ndv/views/bases/_app.py
104
105
106
107
108
def call_later(self, msec: int, func: Callable[[], None]) -> None:
    """Call `func` after `msec` milliseconds."""
    # generic implementation using python threading

    Timer(msec / 1000, func).start()

create_app #

create_app() -> Any

Create the application instance, if not already created.

Source code in src/ndv/views/bases/_app.py
38
39
40
def create_app(self) -> Any:
    """Create the application instance, if not already created."""
    raise NotImplementedError

filter_key_events #

filter_key_events(
    widget: Any, receiver: ArrayView
) -> Callable[[], None]

Install key event filter on widget, emitting receiver.keyPressed.

Source code in src/ndv/views/bases/_app.py
55
56
57
def filter_key_events(self, widget: Any, receiver: ArrayView) -> Callable[[], None]:
    """Install key event filter on `widget`, emitting `receiver.keyPressed`."""
    raise NotImplementedError

filter_mouse_events #

filter_mouse_events(
    canvas: Any, receiver: Mouseable
) -> Callable[[], None]

Install mouse event filter on canvas, redirecting events to receiver.

Source code in src/ndv/views/bases/_app.py
49
50
51
52
53
def filter_mouse_events(
    self, canvas: Any, receiver: Mouseable
) -> Callable[[], None]:
    """Install mouse event filter on `canvas`, redirecting events to `receiver`."""
    raise NotImplementedError

get_executor #

get_executor() -> Executor

Return an executor for running tasks in the background.

Source code in src/ndv/views/bases/_app.py
67
68
69
def get_executor(self) -> Executor:
    """Return an executor for running tasks in the background."""
    return _thread_pool_executor()

process_events #

process_events() -> None

Process events for the application.

Source code in src/ndv/views/bases/_app.py
100
101
102
def process_events(self) -> None:
    """Process events for the application."""
    pass

run #

run() -> None

Run the application.

Source code in src/ndv/views/bases/_app.py
45
46
47
def run(self) -> None:
    """Run the application."""
    pass

RectangularROIHandle #

Bases: CanvasElement

An axis-aligned rectanglular ROI.

Methods:

can_select abstractmethod #

can_select() -> bool

Defines whether the element can be selected.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
33
34
35
@abstractmethod
def can_select(self) -> bool:
    """Defines whether the element can be selected."""

remove #

remove() -> None

Removes the element from the canvas.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
45
46
def remove(self) -> None:
    """Removes the element from the canvas."""

selected abstractmethod #

selected() -> bool

Returns element selection status.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
37
38
39
@abstractmethod
def selected(self) -> bool:
    """Returns element selection status."""

set_border #

set_border(color: Color) -> None

Sets the border color.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
104
105
def set_border(self, color: _cmap.Color) -> None:
    """Sets the border color."""

set_bounding_box #

set_bounding_box(
    minimum: tuple[float, float],
    maximum: tuple[float, float],
) -> None

Sets the bounding box.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
96
97
98
99
def set_bounding_box(
    self, minimum: tuple[float, float], maximum: tuple[float, float]
) -> None:
    """Sets the bounding box."""

set_fill #

set_fill(color: Color) -> None

Sets the fill color.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
101
102
def set_fill(self, color: _cmap.Color) -> None:
    """Sets the fill color."""

set_handles #

set_handles(color: Color) -> None

Sets the handle face color.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
107
108
def set_handles(self, color: _cmap.Color) -> None:
    """Sets the handle face color."""

set_selected abstractmethod #

set_selected(selected: bool) -> None

Sets element selection status.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
41
42
43
@abstractmethod
def set_selected(self, selected: bool) -> None:
    """Sets element selection status."""

set_visible abstractmethod #

set_visible(visible: bool) -> None

Sets element visibility.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
29
30
31
@abstractmethod
def set_visible(self, visible: bool) -> None:
    """Sets element visibility."""

visible abstractmethod #

visible() -> bool

Defines whether the element is visible on the canvas.

Source code in src/ndv/views/bases/_graphics/_canvas_elements.py
25
26
27
@abstractmethod
def visible(self) -> bool:
    """Defines whether the element is visible on the canvas."""

Viewable #

Bases: ABC

ABC representing anything that can be viewed on screen.

For example, a widget, a window, a frame, canvas, etc.

Methods:

  • close

    Close the view/widget.

  • frontend_widget

    Return the native object backing the viewable objects.

  • set_visible

    Sets the visibility of the view/widget itself.

close abstractmethod #

close() -> None

Close the view/widget.

Source code in src/ndv/views/bases/_view_base.py
19
20
21
@abstractmethod
def close(self) -> None:
    """Close the view/widget."""

frontend_widget abstractmethod #

frontend_widget() -> Any

Return the native object backing the viewable objects.

Source code in src/ndv/views/bases/_view_base.py
11
12
13
@abstractmethod
def frontend_widget(self) -> Any:
    """Return the native object backing the viewable objects."""

set_visible abstractmethod #

set_visible(visible: bool) -> None

Sets the visibility of the view/widget itself.

Source code in src/ndv/views/bases/_view_base.py
15
16
17
@abstractmethod
def set_visible(self, visible: bool) -> None:
    """Sets the visibility of the view/widget itself."""