Skip to content

flimari.core.widgets

AutoDoubleSpinBox #

Bases: QWidget

A labelled double spin box that can remember a value. It has a Reset button that reverts the current value to the remembered value.

Color hints for state:

  • Default (theme dependent): no value cached
  • Green: cached value in use
  • Blue: value overridden by user

__init__(parent=None) #

Parameters:

Name Type Description Default
parent Optional[QWidget]

-

None

set_range(minimum, maximum) #

Parameters:

Name Type Description Default
minimum float

-

required
maximum float

-

required

set_decimals(decimals) #

Set the number of decimals.

Parameters:

Name Type Description Default
decimals int

-

required

set_step(step) #

Set the step size.

Parameters:

Name Type Description Default
step float

-

required

set_suffix(suffix) #

Set the suffix/unit.

Parameters:

Name Type Description Default
suffix str

-

required

value() #

Returns:

Type Description
float

The current value.

set_value(value, as_default=False) #

Set the value and update the cache.

Parameters:

Name Type Description Default
value float

-

required
as_default bool

If True, initialize using value.

False

reset_to_cached() #

Reset to the cached value (if available).

ColorButton #

Bases: QPushButton

A button for picking color. Shows a preview of the current color.

When pressed, the napari color picker window will open.

__init__(*args, color='#ff0000', **kwargs) #

Parameters:

Name Type Description Default
*args

Arguments for QPushButton.

()
color str

Initial color.

'#ff0000'
**kwargs

Additional arguments.

{}

set_color(color) #

Parameters:

Name Type Description Default
color

Color in hex string format.

required

get_color() #

Returns:

Type Description
str

Current color in hex string format.

Indicator #

Bases: QFrame

An indicator light widget with named states.

Signals:

  • stateChanged(str): Emitted when the state changes.

__init__(diameter=12, *, states=None, off_color='#bdc3c7', parent=None) #

Parameters:

Name Type Description Default
diameter int

Size of the indicator.

12
states dict[str, str] | None

State name to color hex string mappings. Default to { "ok": "#2ecc71", "warn": "#f1c40f", "bad": "#e74c3c" }

None
off_color str

Color for when the indicator is off.

'#bdc3c7'
parent

-

None

set_off() #

Turn off the indicator.

set_state(name) #

Parameters:

Name Type Description Default
name str

-

required

state() #

Returns:

Type Description
str

Current state.

MPLGraph #

Bases: QWidget

A widget acting as container for a matplotlib figure canvas.

Signals:

  • canvasClicked(float, float): Emitted when the canvas is clicked at position (x,y).

__init__(dpi=120, fig_pixels=480, parent=None) #

Parameters:

Name Type Description Default
dpi int

-

120
fig_pixels int

-

480
parent QWidget | None

-

None

get_ax() #

Returns:

Type Description
Axes

Figure axes.

draw_idle() #

Schedule canvas changes to be rendered.

clear() #

Clear the axes and redraw.

ThemedButton #

Bases: QPushButton

A QPushButton with napari built-in icons that follows viewer theme change.

See https://github.com/napari/napari/tree/main/src/napari/resources/icons for available icons.

__init__(*args, icon, viewer, **kwargs) #

Parameters:

Name Type Description Default
*args

Arguments for QPushButton.

()
icon str

Name of the napari icon.

required
viewer Viewer

Main viewer.

required
**kwargs

Additional arguments.

{}