code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def change_edge_color_mode(self, mode: str): """Change edge color mode of vectors on the layer model. Parameters ---------- mode : str Edge color for vectors. Must be: 'direct', 'cycle', or 'colormap' """ old_mode = self.layer.edge_color_mode with sel...
Change edge color mode of vectors on the layer model. Parameters ---------- mode : str Edge color for vectors. Must be: 'direct', 'cycle', or 'colormap'
change_edge_color_mode
python
napari/napari
src/napari/_qt/layer_controls/qt_vectors_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/qt_vectors_controls.py
BSD-3-Clause
def change_out_of_slice(self, state): """Toggle out of slice display of vectors layer. Parameters ---------- state : int Integer value of Qt.CheckState that indicates the check state of outOfSliceCheckBox """ self.layer.out_of_slice_display = ( Qt...
Toggle out of slice display of vectors layer. Parameters ---------- state : int Integer value of Qt.CheckState that indicates the check state of outOfSliceCheckBox
change_out_of_slice
python
napari/napari
src/napari/_qt/layer_controls/qt_vectors_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/qt_vectors_controls.py
BSD-3-Clause
def _update_edge_color_gui(self, mode: str): """Update the GUI element associated with edge_color. This is typically used when edge_color_mode changes Parameters ---------- mode : str The new edge_color mode the GUI needs to be updated for. Should be: 'di...
Update the GUI element associated with edge_color. This is typically used when edge_color_mode changes Parameters ---------- mode : str The new edge_color mode the GUI needs to be updated for. Should be: 'direct', 'cycle', 'colormap'
_update_edge_color_gui
python
napari/napari
src/napari/_qt/layer_controls/qt_vectors_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/qt_vectors_controls.py
BSD-3-Clause
def _get_property_values(self): """Get the current property values from the Vectors layer Returns ------- property_values : np.ndarray array of all of the union of the property names (keys) in Vectors.properties and Vectors.property_choices """ p...
Get the current property values from the Vectors layer Returns ------- property_values : np.ndarray array of all of the union of the property names (keys) in Vectors.properties and Vectors.property_choices
_get_property_values
python
napari/napari
src/napari/_qt/layer_controls/qt_vectors_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/qt_vectors_controls.py
BSD-3-Clause
def _on_vector_style_change(self): """Receive layer model vector style change event & update dropdown.""" with self.layer.events.vector_style.blocker(): vector_style = self.layer.vector_style index = self.vector_style_comboBox.findText( vector_style, Qt.MatchFixed...
Receive layer model vector style change event & update dropdown.
_on_vector_style_change
python
napari/napari
src/napari/_qt/layer_controls/qt_vectors_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/qt_vectors_controls.py
BSD-3-Clause
def _on_edge_color_mode_change(self): """Receive layer model edge color mode change event & update dropdown.""" with qt_signals_blocked(self.color_mode_comboBox): mode = self.layer._edge.color_mode index = self.color_mode_comboBox.findText( mode, Qt.MatchFixedStri...
Receive layer model edge color mode change event & update dropdown.
_on_edge_color_mode_change
python
napari/napari
src/napari/_qt/layer_controls/qt_vectors_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/qt_vectors_controls.py
BSD-3-Clause
def _on_edge_color_change(self): """Receive layer model edge color change event & update dropdown.""" if ( self.layer._edge.color_mode == ColorMode.DIRECT and len(self.layer.data) > 0 ): with qt_signals_blocked(self.edgeColorEdit): self.edgeCo...
Receive layer model edge color change event & update dropdown.
_on_edge_color_change
python
napari/napari
src/napari/_qt/layer_controls/qt_vectors_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/qt_vectors_controls.py
BSD-3-Clause
def test_base_controls_creation(qtbot, layer): """Check basic creation of QtBaseImageControls works""" qtctrl = QtBaseImageControls(layer) qtbot.addWidget(qtctrl) original_clims = tuple(layer.contrast_limits) slider_clims = qtctrl.contrastLimitsSlider.value() assert slider_clims[0] == 0 asse...
Check basic creation of QtBaseImageControls works
test_base_controls_creation
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
BSD-3-Clause
def test_changing_model_updates_view(qtbot, layer): """Changing the model attribute should update the view""" qtctrl = QtBaseImageControls(layer) qtbot.addWidget(qtctrl) new_clims = (20, 40) layer.contrast_limits = new_clims assert tuple(qtctrl.contrastLimitsSlider.value()) == new_clims
Changing the model attribute should update the view
test_changing_model_updates_view
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
BSD-3-Clause
def test_tensorstore_clim_popup(qtbot): """Regression to test, makes sure it works with tensorstore dtype""" ts = pytest.importorskip('tensorstore') layer = Image(ts.array(np.random.rand(20, 20))) qtbot.addWidget(QContrastLimitsPopup(layer))
Regression to test, makes sure it works with tensorstore dtype
test_tensorstore_clim_popup
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
BSD-3-Clause
def test_blending_opacity_slider(qtbot): """Tests whether opacity slider is disabled for minimum and opaque blending.""" layer = Image(np.random.rand(8, 8)) qtctrl = QtLayerControls(layer) qtbot.addWidget(qtctrl) assert layer.blending == 'translucent' # check that the opacity slider is present b...
Tests whether opacity slider is disabled for minimum and opaque blending.
test_blending_opacity_slider
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
BSD-3-Clause
def test_custom_colormap(qtbot, layer): """Test whether colormap button does anything.""" qtctrl = QtBaseImageControls(layer) # check widget popup assert isinstance(qtctrl.colorbarLabel, QPushButton), ( 'Colorbar button not found' ) qtbot.mouseRelease(qtctrl.colorbarLabel, Qt.MouseButto...
Test whether colormap button does anything.
test_custom_colormap
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_base_layer_.py
BSD-3-Clause
def test_depiction_combobox_changes(qtbot): """Changing the model attribute should update the view.""" layer = Image(np.random.rand(10, 15, 20)) qtctrl = QtImageControls(layer) qtctrl.ndisplay = 3 qtbot.addWidget(qtctrl) combo_box = qtctrl.depictionComboBox opts = {combo_box.itemText(i) for ...
Changing the model attribute should update the view.
test_depiction_combobox_changes
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_layer.py
BSD-3-Clause
def test_plane_controls_show_hide_on_depiction_change(qtbot): """Changing depiction mode should show/hide plane controls in 3D.""" layer = Image(np.random.rand(10, 15, 20)) qtctrl = QtImageControls(layer) qtbot.addWidget(qtctrl) qtctrl.ndisplay = 3 layer.depiction = 'volume' assert qtctrl.p...
Changing depiction mode should show/hide plane controls in 3D.
test_plane_controls_show_hide_on_depiction_change
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_layer.py
BSD-3-Clause
def test_plane_controls_show_hide_on_ndisplay_change(qtbot): """Changing ndisplay should show/hide plane controls if depicting a plane.""" layer = Image(np.random.rand(10, 15, 20)) layer.depiction = 'plane' qtctrl = QtImageControls(layer) qtbot.addWidget(qtctrl) assert qtctrl.ndisplay == 2 ...
Changing ndisplay should show/hide plane controls if depicting a plane.
test_plane_controls_show_hide_on_ndisplay_change
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_layer.py
BSD-3-Clause
def test_plane_slider_value_change(qtbot): """Changing the model should update the view.""" layer = Image(np.random.rand(10, 15, 20)) qtctrl = QtImageControls(layer) qtbot.addWidget(qtctrl) layer.plane.thickness *= 2 assert qtctrl.planeThicknessSlider.value() == layer.plane.thickness
Changing the model should update the view.
test_plane_slider_value_change
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_image_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_image_layer.py
BSD-3-Clause
def test_changing_layer_color_mode_updates_combo_box(make_labels_controls): """Updating layer color mode changes the combo box selection""" layer, qtctrl = make_labels_controls(colormap=_COLOR) assert qtctrl.colorModeComboBox.currentText() == 'direct' layer.colormap = layer._random_colormap assert...
Updating layer color mode changes the combo box selection
test_changing_layer_color_mode_updates_combo_box
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_changing_layer_show_selected_label_updates_check_box( make_labels_controls, ): """See https://github.com/napari/napari/issues/5371""" layer, qtctrl = make_labels_controls() assert not qtctrl.selectedColorCheckbox.isChecked() assert not layer.show_selected_label layer.show_selected_labe...
See https://github.com/napari/napari/issues/5371
test_changing_layer_show_selected_label_updates_check_box
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_changing_colormap_updates_colorbox(make_labels_controls): """Test that changing the colormap on a layer will update color swatch in the combo box""" layer, qtctrl = make_labels_controls(colormap=_COLOR) color_box = qtctrl.colorBox layer.selected_label = 1 # For a paint event, which does n...
Test that changing the colormap on a layer will update color swatch in the combo box
test_changing_colormap_updates_colorbox
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_selected_color_checkbox(make_labels_controls): """Tests that the 'selected color' checkbox sets the 'show_selected_label' property properly.""" layer, qtctrl = make_labels_controls() qtctrl.selectedColorCheckbox.setChecked(True) assert layer.show_selected_label qtctrl.selectedColorCheckbox....
Tests that the 'selected color' checkbox sets the 'show_selected_label' property properly.
test_selected_color_checkbox
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_contiguous_labels_checkbox(make_labels_controls): """Tests that the 'contiguous' checkbox sets the 'contiguous' property properly.""" layer, qtctrl = make_labels_controls() qtctrl.contigCheckBox.setChecked(True) assert layer.contiguous qtctrl.contigCheckBox.setChecked(False) assert not ...
Tests that the 'contiguous' checkbox sets the 'contiguous' property properly.
test_contiguous_labels_checkbox
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_preserve_labels_checkbox(make_labels_controls): """Tests that the 'preserve labels' checkbox sets the 'preserve_labels' property properly.""" layer, qtctrl = make_labels_controls() qtctrl.preserveLabelsCheckBox.setChecked(True) assert layer.preserve_labels qtctrl.preserveLabelsCheckBox.setC...
Tests that the 'preserve labels' checkbox sets the 'preserve_labels' property properly.
test_preserve_labels_checkbox
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_change_label_selector_range(make_labels_controls): """Changing the label layer dtype should update label selector range.""" layer, qtctrl = make_labels_controls() assert layer.data.dtype == np.uint8 assert qtctrl.selectionSpinBox.minimum() == 0 assert qtctrl.selectionSpinBox.maximum() == 25...
Changing the label layer dtype should update label selector range.
test_change_label_selector_range
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_change_iso_gradient_mode(make_labels_controls): """Changing the iso gradient mode should update the layer and vice versa.""" layer, qtctrl = make_labels_controls() qtctrl.ndisplay = 3 assert layer.rendering == LabelsRendering.ISO_CATEGORICAL assert layer.iso_gradient_mode == IsoCategoricalG...
Changing the iso gradient mode should update the layer and vice versa.
test_change_iso_gradient_mode
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_iso_gradient_mode_hidden_for_2d(make_labels_controls): """Test that the iso gradient mode control is hidden with 2D view.""" layer, qtctrl = make_labels_controls() assert qtctrl.isoGradientComboBox.isHidden() layer.data = np.random.randint(5, size=(10, 15), dtype=np.uint8) assert qtctrl.iso...
Test that the iso gradient mode control is hidden with 2D view.
test_iso_gradient_mode_hidden_for_2d
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_iso_gradient_mode_with_rendering(make_labels_controls): """Test the iso gradeint mode control is enabled for iso_categorical rendering.""" layer, qtctrl = make_labels_controls() qtctrl.ndisplay = 3 assert layer.rendering == LabelsRendering.ISO_CATEGORICAL assert ( qtctrl.isoGradient...
Test the iso gradeint mode control is enabled for iso_categorical rendering.
test_iso_gradient_mode_with_rendering
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py
BSD-3-Clause
def test_set_3d_display_with_points(qtbot, ndim, editable_after): """Interactivity only works for 2D points layers rendered in 2D and not in 3D. Verify that layer.editable is set appropriately upon switching to 3D rendering mode. See: https://github.com/napari/napari/pull/4184 """ viewer = View...
Interactivity only works for 2D points layers rendered in 2D and not in 3D. Verify that layer.editable is set appropriately upon switching to 3D rendering mode. See: https://github.com/napari/napari/pull/4184
test_set_3d_display_with_points
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_layer_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_layer_controls.py
BSD-3-Clause
def test_set_3d_display_with_shapes(qtbot): """Interactivity only works for shapes layers rendered in 2D and not in 3D. Verify that layer.editable is set appropriately upon switching to 3D rendering mode. See: https://github.com/napari/napari/pull/4184 """ viewer = ViewerModel() container =...
Interactivity only works for shapes layers rendered in 2D and not in 3D. Verify that layer.editable is set appropriately upon switching to 3D rendering mode. See: https://github.com/napari/napari/pull/4184
test_set_3d_display_with_shapes
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_layer_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_layer_controls.py
BSD-3-Clause
def test_set_3d_display_with_labels(qtbot): """Some modes only work for labels layers rendered in 2D and not in 3D. Verify that the related mode buttons are disabled upon switching to 3D rendering mode while the layer is still editable. """ viewer = ViewerModel() container = QtLayerControlsConta...
Some modes only work for labels layers rendered in 2D and not in 3D. Verify that the related mode buttons are disabled upon switching to 3D rendering mode while the layer is still editable.
test_set_3d_display_with_labels
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_layer_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_layer_controls.py
BSD-3-Clause
def test_set_3d_display_and_layer_visibility(qtbot, add_layer_with_data): """Some modes only work for layers rendered in 2D and not in 3D. Verify that the related mode buttons are disabled upon switching to 3D rendering mode and the disable state is kept even when changing layer visibility. For the...
Some modes only work for layers rendered in 2D and not in 3D. Verify that the related mode buttons are disabled upon switching to 3D rendering mode and the disable state is kept even when changing layer visibility. For the labels layer the specific polygon mode button should be disabled in 3D regar...
test_set_3d_display_and_layer_visibility
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_layer_controls.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_layer_controls.py
BSD-3-Clause
def test_size_slider_represents_current_size(qtbot): """Changing the current_size attribute should update the slider""" layer = Points(np.random.rand(10, 2)) qtctrl = QtPointsControls(layer) qtbot.addWidget(qtctrl) slider = qtctrl.sizeSlider slider.setValue(10) # Initial value assert sl...
Changing the current_size attribute should update the slider
test_size_slider_represents_current_size
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_points_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_points_layer.py
BSD-3-Clause
def test_shape_controls_face_color(qtbot): """Check updating of face color updates QtShapesControls.""" layer = Shapes(_SHAPES) qtctrl = QtShapesControls(layer) qtbot.addWidget(qtctrl) target_color = transform_color(layer.current_face_color)[0] np.testing.assert_almost_equal(qtctrl.faceColorEdit...
Check updating of face color updates QtShapesControls.
test_shape_controls_face_color
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_shapes_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_shapes_layer.py
BSD-3-Clause
def test_shape_controls_edge_color(qtbot): """Check updating of edge color updates QtShapesControls.""" layer = Shapes(_SHAPES) qtctrl = QtShapesControls(layer) qtbot.addWidget(qtctrl) target_color = transform_color(layer.current_edge_color)[0] np.testing.assert_almost_equal(qtctrl.edgeColorEdit...
Check updating of edge color updates QtShapesControls.
test_shape_controls_edge_color
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_shapes_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_shapes_layer.py
BSD-3-Clause
def test_color_by_same_after_properties_change( null_data, properties, color_by, qtbot ): """See https://github.com/napari/napari/issues/5330""" layer = Tracks(null_data, properties=properties) layer.color_by = color_by controls = QtTracksControls(layer) qtbot.addWidget(controls) assert cont...
See https://github.com/napari/napari/issues/5330
test_color_by_same_after_properties_change
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_tracks_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_tracks_layer.py
BSD-3-Clause
def test_update_max_tail_length(null_data, properties, qtbot): """Check updating of the tail length slider beyond current maximum.""" layer = Tracks(null_data, properties=properties) controls = QtTracksControls(layer) qtbot.addWidget(controls) # verify the max_length argument is initialized correct...
Check updating of the tail length slider beyond current maximum.
test_update_max_tail_length
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_tracks_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_tracks_layer.py
BSD-3-Clause
def test_update_max_head_length(null_data, properties, qtbot): """Check updating of the head length slider beyond current maximum.""" layer = Tracks(null_data, properties=properties) controls = QtTracksControls(layer) qtbot.addWidget(controls) # verify the max_length argument is initialized correct...
Check updating of the head length slider beyond current maximum.
test_update_max_head_length
python
napari/napari
src/napari/_qt/layer_controls/_tests/test_qt_tracks_layer.py
https://github.com/napari/napari/blob/master/src/napari/_qt/layer_controls/_tests/test_qt_tracks_layer.py
BSD-3-Clause
def notify(self, receiver, event): """Trace events while we handle them.""" timer_name = _get_event_label(receiver, event) # Time the event while we handle it. with perf.perf_timer(timer_name, 'qt_event'): return QApplication.notify(self, receiver, event)
Trace events while we handle them.
notify
python
napari/napari
src/napari/_qt/perf/qt_event_tracing.py
https://github.com/napari/napari/blob/master/src/napari/_qt/perf/qt_event_tracing.py
BSD-3-Clause
def __init__(self) -> None: """Create mapping for all known event types.""" self.string_name = {} for name in vars(QEvent): attribute = getattr(QEvent, name) if type(attribute) is QEvent.Type: self.string_name[attribute] = name
Create mapping for all known event types.
__init__
python
napari/napari
src/napari/_qt/perf/qt_event_tracing.py
https://github.com/napari/napari/blob/master/src/napari/_qt/perf/qt_event_tracing.py
BSD-3-Clause
def as_string(self, event: QEvent.Type) -> str: """Return the string name for this event. event : QEvent.Type Return string for this event type. """ try: return self.string_name[event] except KeyError: return trans._('UnknownEvent:{event}', ev...
Return the string name for this event. event : QEvent.Type Return string for this event type.
as_string
python
napari/napari
src/napari/_qt/perf/qt_event_tracing.py
https://github.com/napari/napari/blob/master/src/napari/_qt/perf/qt_event_tracing.py
BSD-3-Clause
def _get_event_label(receiver: QWidget, event: QEvent) -> str: """Return a label for this event. Parameters ---------- receiver : QWidget The receiver of the event. event : QEvent The event name. Returns ------- str Label to display for the event. Notes ...
Return a label for this event. Parameters ---------- receiver : QWidget The receiver of the event. event : QEvent The event name. Returns ------- str Label to display for the event. Notes ----- If no object we return <event_name>. If there's an obje...
_get_event_label
python
napari/napari
src/napari/_qt/perf/qt_event_tracing.py
https://github.com/napari/napari/blob/master/src/napari/_qt/perf/qt_event_tracing.py
BSD-3-Clause
def append(self, name: str, time_ms: float) -> None: """Add one line of text for this timer. Parameters ---------- name : str Timer name. time_ms : float Duration of the timer in milliseconds. """ self.moveCursor(QTextCursor.MoveOperation....
Add one line of text for this timer. Parameters ---------- name : str Timer name. time_ms : float Duration of the timer in milliseconds.
append
python
napari/napari
src/napari/_qt/perf/qt_performance.py
https://github.com/napari/napari/blob/master/src/napari/_qt/perf/qt_performance.py
BSD-3-Clause
def _get_timer_info(self): """Get the information from the timers that we want to display.""" average = None long_events = [] # We don't update any GUI/widgets while iterating over the timers. # Updating widgets can create immediate Qt Events which would modify the # tim...
Get the information from the timers that we want to display.
_get_timer_info
python
napari/napari
src/napari/_qt/perf/qt_performance.py
https://github.com/napari/napari/blob/master/src/napari/_qt/perf/qt_performance.py
BSD-3-Clause
def update(self): """Update our label and progress bar and log any new slow events.""" # Update our timer label. elapsed = time.time() - self.start_time self.timer_label.setText( trans._('Uptime: {elapsed:.2f}', elapsed=elapsed) ) average, long_events = self....
Update our label and progress bar and log any new slow events.
update
python
napari/napari
src/napari/_qt/perf/qt_performance.py
https://github.com/napari/napari/blob/master/src/napari/_qt/perf/qt_performance.py
BSD-3-Clause
def test_trace_on_start(tmp_path: Path, perf_config, perfmon_script): """Make sure napari can write a perfmon trace file.""" env = os.environ.copy() env.update({'NAPARI_PERFMON': str(perf_config.path), 'NAPARI_CONFIG': ''}) subprocess.run([sys.executable, *perfmon_script], env=env, check=True) # ...
Make sure napari can write a perfmon trace file.
test_trace_on_start
python
napari/napari
src/napari/_qt/perf/_tests/test_perf.py
https://github.com/napari/napari/blob/master/src/napari/_qt/perf/_tests/test_perf.py
BSD-3-Clause
def colored( self, color: str | None = None, opacity: float = 1.0, theme: str | None = None, theme_key: str = 'icon', ) -> 'QColoredSVGIcon': """Return a new colorized QIcon instance. Parameters ---------- color : str, optional A v...
Return a new colorized QIcon instance. Parameters ---------- color : str, optional A valid CSS color string, used to colorize the SVG. If provided, will take precedence over ``theme``, by default None. opacity : float, optional Fill opacity for the i...
colored
python
napari/napari
src/napari/_qt/qt_resources/_svg.py
https://github.com/napari/napari/blob/master/src/napari/_qt/qt_resources/_svg.py
BSD-3-Clause
def from_resources( icon_name: str, ) -> 'QColoredSVGIcon': """Get an icon from napari SVG resources. Parameters ---------- icon_name : str The name of the icon svg to load (just the stem). Must be in the napari icons folder. Returns ...
Get an icon from napari SVG resources. Parameters ---------- icon_name : str The name of the icon svg to load (just the stem). Must be in the napari icons folder. Returns ------- QColoredSVGIcon A colorizeable QIcon
from_resources
python
napari/napari
src/napari/_qt/qt_resources/_svg.py
https://github.com/napari/napari/blob/master/src/napari/_qt/qt_resources/_svg.py
BSD-3-Clause
def pixmap(self, size, mode, state): """Return the icon as a pixmap with requested size, mode, and state.""" img = QImage(size, QImage.Format_ARGB32) img.fill(Qt.transparent) pixmap = QPixmap.fromImage(img, Qt.NoFormatConversion) painter = QPainter(pixmap) self.paint(pain...
Return the icon as a pixmap with requested size, mode, and state.
pixmap
python
napari/napari
src/napari/_qt/qt_resources/_svg.py
https://github.com/napari/napari/blob/master/src/napari/_qt/qt_resources/_svg.py
BSD-3-Clause
def get_stylesheet( theme_id: str | None = None, extra: list[str] | None = None, extra_variables: dict[str, str] | None = None, ) -> str: """Combine all qss files into single, possibly pre-themed, style string. Parameters ---------- theme_id : str, optional Theme to apply to the sty...
Combine all qss files into single, possibly pre-themed, style string. Parameters ---------- theme_id : str, optional Theme to apply to the stylesheet. If no theme is provided, the returned stylesheet will still have ``{{ template_variables }}`` that need to be replaced using the :fu...
get_stylesheet
python
napari/napari
src/napari/_qt/qt_resources/__init__.py
https://github.com/napari/napari/blob/master/src/napari/_qt/qt_resources/__init__.py
BSD-3-Clause
def get_current_stylesheet(extra: list[str] | None = None) -> str: """ Return the current stylesheet base on settings. This is wrapper around :py:func:`get_stylesheet` that takes the current theme base on settings. Parameters ---------- extra : list of str, optional Additional paths to ...
Return the current stylesheet base on settings. This is wrapper around :py:func:`get_stylesheet` that takes the current theme base on settings. Parameters ---------- extra : list of str, optional Additional paths to QSS files to include in stylesheet, by default None Returns -----...
get_current_stylesheet
python
napari/napari
src/napari/_qt/qt_resources/__init__.py
https://github.com/napari/napari/blob/master/src/napari/_qt/qt_resources/__init__.py
BSD-3-Clause
def test_colored_svg(qtbot): """Test that we can create a colored icon with certain color.""" icon = QColoredSVGIcon.from_resources('new_points') assert isinstance(icon, QIcon) assert isinstance(icon.colored('#0934e2', opacity=0.4), QColoredSVGIcon) assert icon.pixmap(250, 250)
Test that we can create a colored icon with certain color.
test_colored_svg
python
napari/napari
src/napari/_qt/qt_resources/_tests/test_svg.py
https://github.com/napari/napari/blob/master/src/napari/_qt/qt_resources/_tests/test_svg.py
BSD-3-Clause
def test_colored_svg_from_theme(qtbot): """Test that we can create a colored icon using a theme name.""" icon = QColoredSVGIcon.from_resources('new_points') assert isinstance(icon, QIcon) assert isinstance(icon.colored(theme='light'), QColoredSVGIcon) assert icon.pixmap(250, 250)
Test that we can create a colored icon using a theme name.
test_colored_svg_from_theme
python
napari/napari
src/napari/_qt/qt_resources/_tests/test_svg.py
https://github.com/napari/napari/blob/master/src/napari/_qt/qt_resources/_tests/test_svg.py
BSD-3-Clause
def start( self, priority: QThread.Priority = QThread.Priority.InheritPriority ) -> None: """Start the status checker thread. Make sure to set the _terminate attribute to False prior to start. """ if not self._allow_start: return self._terminate = False ...
Start the status checker thread. Make sure to set the _terminate attribute to False prior to start.
start
python
napari/napari
src/napari/_qt/threads/status_checker.py
https://github.com/napari/napari/blob/master/src/napari/_qt/threads/status_checker.py
BSD-3-Clause
def _on_line_edit_edited(self): """When the user hits enter or loses focus on the LineEdit widget.""" text = self.line_edit.text() rgb_match = rgba_regex.match(text) if rgb_match: text = [float(x) for x in rgb_match.groups() if x] self.color_swatch.setColor(text)
When the user hits enter or loses focus on the LineEdit widget.
_on_line_edit_edited
python
napari/napari
src/napari/_qt/widgets/qt_color_swatch.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_color_swatch.py
BSD-3-Clause
def _update_swatch_style(self, color: np.ndarray) -> None: """Convert the current color to rgba() string and update appearance.""" rgba = f'rgba({",".join(str(int(x * 255)) for x in self._color)})' self.setStyleSheet('#colorSwatch {background-color: ' + rgba + ';}')
Convert the current color to rgba() string and update appearance.
_update_swatch_style
python
napari/napari
src/napari/_qt/widgets/qt_color_swatch.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_color_swatch.py
BSD-3-Clause
def mouseReleaseEvent(self, event: QMouseEvent): """Show QColorPopup picker when the user clicks on the swatch.""" if event.button() == Qt.MouseButton.LeftButton: initial = QColor(*(255 * self._color).astype('int')) popup = QColorPopup(self, initial) popup.colorSelect...
Show QColorPopup picker when the user clicks on the swatch.
mouseReleaseEvent
python
napari/napari
src/napari/_qt/widgets/qt_color_swatch.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_color_swatch.py
BSD-3-Clause
def setColor(self, color: AnyColorType) -> None: """Set the color of the swatch. Parameters ---------- color : ColorType Can be any ColorType recognized by our utils.colormaps.standardize_color.transform_color function. """ if isinstance(color, QC...
Set the color of the swatch. Parameters ---------- color : ColorType Can be any ColorType recognized by our utils.colormaps.standardize_color.transform_color function.
setColor
python
napari/napari
src/napari/_qt/widgets/qt_color_swatch.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_color_swatch.py
BSD-3-Clause
def setText(self, color: ColorType): """Set the text of the lineEdit using any ColorType. Colors will be converted to standard SVG spec names if possible, or shown as #RGBA hex if not. Parameters ---------- color : ColorType Can be any ColorType recognized b...
Set the text of the lineEdit using any ColorType. Colors will be converted to standard SVG spec names if possible, or shown as #RGBA hex if not. Parameters ---------- color : ColorType Can be any ColorType recognized by our utils.colormaps.standardize_co...
setText
python
napari/napari
src/napari/_qt/widgets/qt_color_swatch.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_color_swatch.py
BSD-3-Clause
def keyPressEvent(self, event: QKeyEvent): """Accept current color on enter, cancel on escape. Parameters ---------- event : QKeyEvent The keypress event that triggered this method. """ if event.key() in (Qt.Key.Key_Return, Qt.Key.Key_Enter): retu...
Accept current color on enter, cancel on escape. Parameters ---------- event : QKeyEvent The keypress event that triggered this method.
keyPressEvent
python
napari/napari
src/napari/_qt/widgets/qt_color_swatch.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_color_swatch.py
BSD-3-Clause
def update_context(self, parent: _QtMainWindow) -> None: """Update the context of the palette.""" context: dict[str, Any] = {} context.update(get_context(parent)) context.update(get_context(parent._qt_viewer.viewer.layers)) self._list._app_model_context = context return
Update the context of the palette.
update_context
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def set_text_colors(self, input_text: str, color: str) -> None: """Set label text color based on the input text.""" if input_text == '': return text = self.command_text() words = input_text.split(' ') pattern = re.compile('|'.join(words), re.IGNORECASE) outpu...
Set label text color based on the input text.
set_text_colors
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def move_selection(self, dx: int) -> None: """Move selection by dx, dx can be negative or positive.""" self._selected_index += dx self._selected_index = max(0, self._selected_index) self._selected_index = min( self._current_max_index - 1, self._selected_index ) ...
Move selection by dx, dx can be negative or positive.
move_selection
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def update_selection(self) -> None: """Update the widget selection state based on the selected index.""" index = self.model().index(self._selected_index - self._index_offset) if model := self.selectionModel(): model.setCurrentIndex( index, QtCore.QItemSelectionModel.S...
Update the widget selection state based on the selected index.
update_selection
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def iter_command(self) -> Iterator[CommandRule]: """Iterate over all the commands registered to this command list widget.""" for i in range(self.model().rowCount()): if not self.isRowHidden(i): command = self.command_at(i) if command is not None: ...
Iterate over all the commands registered to this command list widget.
iter_command
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def can_execute(self) -> bool: """Return true if the command can be executed.""" index = self._selected_index command = self.command_at(index) if command is None: return False return _enabled(command, self._app_model_context)
Return true if the command can be executed.
can_execute
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def update_for_text(self, input_text: str) -> None: """Update the list to match the input text.""" self._selected_index = 0 max_matches = self.model()._max_matches row = 0 for row, action in enumerate(self.iter_top_hits(input_text)): self.setRowHidden(row, False) ...
Update the list to match the input text.
update_for_text
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def iter_top_hits(self, input_text: str) -> Iterator[CommandRule]: """Iterate over the top hits for the input text""" commands: list[tuple[float, CommandRule]] = [] for command in self.all_commands: score = _match_score(command, input_text) if score > 0.0: ...
Iterate over the top hits for the input text
iter_top_hits
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def _match_score(action: CommandRule, input_text: str) -> float: """Return a match score (between 0 and 1) for the input text.""" name = _format_action_name(action).lower() if all(word in name for word in input_text.lower().split(' ')): return 1.0 return 0.0
Return a match score (between 0 and 1) for the input text.
_match_score
python
napari/napari
src/napari/_qt/widgets/qt_command_palette.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_command_palette.py
BSD-3-Clause
def set_data(self, data: list[dict], headers: list[str] | None = None): """Set the data in the table, given a list of dicts. Parameters ---------- data : List[dict] A list of dicts where each dict in the list is a row, and each key in the dict is a header, by def...
Set the data in the table, given a list of dicts. Parameters ---------- data : List[dict] A list of dicts where each dict in the list is a row, and each key in the dict is a header, by default None. (call set_data later to add data) headers : list of...
set_data
python
napari/napari
src/napari/_qt/widgets/qt_dict_table.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dict_table.py
BSD-3-Clause
def _go_to_links(self, row, col): """if a cell is clicked and it contains an email or url, go to link.""" import webbrowser item = self.item(row, col) text = item.text().strip() if email_pattern.match(text): webbrowser.open(f'mailto:{text}', new=1) return...
if a cell is clicked and it contains an email or url, go to link.
_go_to_links
python
napari/napari
src/napari/_qt/widgets/qt_dict_table.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dict_table.py
BSD-3-Clause
def sizeHint(self): """Return (width, height) of the table""" width = sum(map(self.columnWidth, range(self.columnCount()))) + 25 height = self.rowHeight(0) * (self.rowCount() + 1) return QSize(width, height)
Return (width, height) of the table
sizeHint
python
napari/napari
src/napari/_qt/widgets/qt_dict_table.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dict_table.py
BSD-3-Clause
def _on_last_used_changed(self): """Sets the style of the last used slider.""" for i, widget in enumerate(self.slider_widgets): sld = widget.slider sld.setProperty('last_used', i == self.dims.last_used) sld.style().unpolish(sld) sld.style().polish(sld)
Sets the style of the last used slider.
_on_last_used_changed
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def _update_nsliders(self): """Updates the number of sliders based on the number of dimensions.""" self._trim_sliders(0) self._create_sliders(self.dims.ndim) self._update_display() for i in range(self.dims.ndim): self._update_range() if self._displayed_sli...
Updates the number of sliders based on the number of dimensions.
_update_nsliders
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def _resize_axis_labels(self): """When any of the labels get updated, this method updates all label widths to a minimum size. This allows the full label to be visible at all times, with minimal space, without setting stretch on the layout. """ displayed_labels = [ ...
When any of the labels get updated, this method updates all label widths to a minimum size. This allows the full label to be visible at all times, with minimal space, without setting stretch on the layout.
_resize_axis_labels
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def _resize_slice_labels(self): """When the size of any dimension changes, we want to resize all of the slice labels to width of the longest label, to keep all the sliders right aligned. The width is determined by the number of digits in the largest dimensions, plus a little padding. ...
When the size of any dimension changes, we want to resize all of the slice labels to width of the longest label, to keep all the sliders right aligned. The width is determined by the number of digits in the largest dimensions, plus a little padding.
_resize_slice_labels
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def _create_sliders(self, number_of_sliders: int): """Creates sliders to match new number of dimensions. Parameters ---------- number_of_sliders : int New number of sliders. """ # add extra sliders so that number_of_sliders are present # add to the be...
Creates sliders to match new number of dimensions. Parameters ---------- number_of_sliders : int New number of sliders.
_create_sliders
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def _trim_sliders(self, number_of_sliders): """Trims number of dimensions to a lower number. Parameters ---------- number_of_sliders : int New number of sliders. """ # remove extra sliders so that only number_of_sliders are left # remove from the begi...
Trims number of dimensions to a lower number. Parameters ---------- number_of_sliders : int New number of sliders.
_trim_sliders
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def _remove_slider_widget(self, index): """Remove slider_widget at index, including all sub-widgets. Parameters ---------- index : int Index of slider to remove """ # remove particular slider slider_widget = self.slider_widgets.pop(index) self...
Remove slider_widget at index, including all sub-widgets. Parameters ---------- index : int Index of slider to remove
_remove_slider_widget
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def play( self, axis: int = 0, fps: float | None = None, loop_mode: str | None = None, frame_range: tuple[int, int] | None = None, ): """Animate (play) axis. Parameters ---------- axis : int Index of axis to play fps : floa...
Animate (play) axis. Parameters ---------- axis : int Index of axis to play fps : float Frames per second for playback. Negative values will play in reverse. fps == 0 will stop the animation. The view is not guaranteed to keep up with th...
play
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def is_playing(self): """Return True if any axis is currently animated.""" try: return not self._animation_thread._waiter.is_set() except RuntimeError as e: # pragma: no cover if ( 'wrapped C/C++ object of type' not in e.args[0] and 'Inter...
Return True if any axis is currently animated.
is_playing
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def _set_frame(self, axis, frame): """Safely tries to set `axis` to the requested `point`. This function is debounced: if the previous frame has not yet drawn to the canvas, it will simply do nothing. If the timer plays faster than the canvas can draw, this will drop the intermediate f...
Safely tries to set `axis` to the requested `point`. This function is debounced: if the previous frame has not yet drawn to the canvas, it will simply do nothing. If the timer plays faster than the canvas can draw, this will drop the intermediate frames, keeping the effective frame rat...
_set_frame
python
napari/napari
src/napari/_qt/widgets/qt_dims.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims.py
BSD-3-Clause
def _set_slice_from_label(self): """Update the dims point based on the curslice_label.""" # On teardown some tests fail on OSX with an `IndexError` try: max_allowed = self.dims.nsteps[self.axis] - 1 except IndexError: return val = int(self.curslice_label....
Update the dims point based on the curslice_label.
_set_slice_from_label
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def _create_axis_label_widget(self): """Create the axis label widget which accompanies its slider.""" label = QElidingLineEdit(self) label.setObjectName('axis_label') # needed for _update_label fm = label.fontMetrics() label.setEllipsesWidth(int(fm.averageCharWidth() * 3)) ...
Create the axis label widget which accompanies its slider.
_create_axis_label_widget
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def _create_range_slider_widget(self): """Creates a range slider widget for a given axis.""" # Set the maximum values of the range slider to be one step less than # the range of the layer as otherwise the slider can move beyond the # shape of the layer as the endpoint is included ...
Creates a range slider widget for a given axis.
_create_range_slider_widget
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def _create_play_button_widget(self): """Creates the actual play button, which has the modal popup.""" self.play_button = QtPlayButton( self.qt_dims, self.axis, fps=self._fps, mode=self._loop_mode ) self.play_button.setToolTip( trans._('Right click on button for p...
Creates the actual play button, which has the modal popup.
_create_play_button_widget
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def fps(self, value): """Frames per second for animation. Parameters ---------- value : float Frames per second for animation. """ if self._fps == value: return self._fps = value self.play_button.fpsspin.setValue(abs(value)) ...
Frames per second for animation. Parameters ---------- value : float Frames per second for animation.
fps
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def loop_mode(self, value): """Loop mode for animation. Parameters ---------- value : napari._qt._constants.LoopMode Loop mode for animation. Available options for the loop mode string enumeration are: - LoopMode.ONCE Animation will st...
Loop mode for animation. Parameters ---------- value : napari._qt._constants.LoopMode Loop mode for animation. Available options for the loop mode string enumeration are: - LoopMode.ONCE Animation will stop once movie reaches the max frame ...
loop_mode
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def frame_range(self, value): """Frame range for animation, as (minimum_frame, maximum_frame). Parameters ---------- value : tuple(int, int) Frame range as tuple/list with range (minimum_frame, maximum_frame) """ if not isinstance(value, tuple | list | type(N...
Frame range for animation, as (minimum_frame, maximum_frame). Parameters ---------- value : tuple(int, int) Frame range as tuple/list with range (minimum_frame, maximum_frame)
frame_range
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def _update_play_settings(self, fps, loop_mode, frame_range): """Update settings for animation. Parameters ---------- fps : float Frames per second to play the animation. loop_mode : napari._qt._constants.LoopMode Loop mode for animation. Avai...
Update settings for animation. Parameters ---------- fps : float Frames per second to play the animation. loop_mode : napari._qt._constants.LoopMode Loop mode for animation. Available options for the loop mode string enumeration are: - Loo...
_update_play_settings
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def textFromValue(self, value): """This removes the decimal places if the float is an integer. Parameters ---------- value : float The value of this custom double spin box. """ if value.is_integer(): value = int(value) return str(value)
This removes the decimal places if the float is an integer. Parameters ---------- value : float The value of this custom double spin box.
textFromValue
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def keyPressEvent(self, event): """Handle key press event for the dimension slider spinbox. Parameters ---------- event : qtpy.QtCore.QKeyEvent Event from the Qt context. """ # this is here to intercept Return/Enter keys when editing the FPS # SpinBox...
Handle key press event for the dimension slider spinbox. Parameters ---------- event : qtpy.QtCore.QKeyEvent Event from the Qt context.
keyPressEvent
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def mouseReleaseEvent(self, event): """Show popup for right-click, toggle animation for right click. Parameters ---------- event : qtpy.QtCore.QMouseEvent Event from the qt context. """ # using this instead of self.customContextMenuRequested.connect and ...
Show popup for right-click, toggle animation for right click. Parameters ---------- event : qtpy.QtCore.QMouseEvent Event from the qt context.
mouseReleaseEvent
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def set_fps(self, fps): """Set the frames per second value for the animation. Parameters ---------- fps : float Frames per second for the animation. """ if fps == 0: return self.finish() self.step = 1 if fps > 0 else -1 # negative fps pla...
Set the frames per second value for the animation. Parameters ---------- fps : float Frames per second for the animation.
set_fps
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def set_frame_range(self, frame_range): """Frame range for animation, as (minimum_frame, maximum_frame). Parameters ---------- frame_range : tuple(int, int) Frame range as tuple/list with range (minimum_frame, maximum_frame) """ self.dimsrange = (0, self.dims...
Frame range for animation, as (minimum_frame, maximum_frame). Parameters ---------- frame_range : tuple(int, int) Frame range as tuple/list with range (minimum_frame, maximum_frame)
set_frame_range
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def advance(self): """Advance the current frame in the animation. Takes dims scale into account and restricts the animation to the requested frame_range, if entered. """ self.current += self.step * self.dimsrange[2] if self.current < self.min_point: if ( ...
Advance the current frame in the animation. Takes dims scale into account and restricts the animation to the requested frame_range, if entered.
advance
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def _on_axis_changed(self): """Update the current frame if the axis has changed.""" # slot for external events to update the current frame if self.dims is not None: self.current = self.dims.current_step[self.axis]
Update the current frame if the axis has changed.
_on_axis_changed
python
napari/napari
src/napari/_qt/widgets/qt_dims_slider.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_slider.py
BSD-3-Clause
def set_dims_order(dims: Dims, order: tuple[int, ...]): """Set dimension order of Dims object to order. Parameters ---------- dims : napari.components.dims.Dims Dims object. order : tuple of int New dimension order. """ if type(order[0]) is AxisModel: order = [a.axis...
Set dimension order of Dims object to order. Parameters ---------- dims : napari.components.dims.Dims Dims object. order : tuple of int New dimension order.
set_dims_order
python
napari/napari
src/napari/_qt/widgets/qt_dims_sorter.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_dims_sorter.py
BSD-3-Clause
def _set_up_table(self): """Add table columns and headers, define styling""" self._fn_pattern_col = 0 self._reader_col = 1 header_strs = [trans._('Filename Pattern'), trans._('Reader Plugin')] self._table.setColumnCount(2) self._table.setColumnWidth(self._fn_pattern_col...
Add table columns and headers, define styling
_set_up_table
python
napari/napari
src/napari/_qt/widgets/qt_extension2reader.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_extension2reader.py
BSD-3-Clause
def _populate_table(self): """Add row for each extension to reader mapping in settings""" fnpattern2reader = get_settings().plugins.extension2reader if len(fnpattern2reader) > 0: for fn_pattern, plugin_name in fnpattern2reader.items(): self._add_new_row(fn_pattern, p...
Add row for each extension to reader mapping in settings
_populate_table
python
napari/napari
src/napari/_qt/widgets/qt_extension2reader.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_extension2reader.py
BSD-3-Clause
def _make_new_preference_row(self): """Make row for user to add a new filename pattern assignment""" edit_row_widget = QWidget() edit_row_widget.setLayout(QGridLayout()) edit_row_widget.layout().setContentsMargins(0, 0, 0, 0) self._fn_pattern_edit = QLineEdit() self._fn_...
Make row for user to add a new filename pattern assignment
_make_new_preference_row
python
napari/napari
src/napari/_qt/widgets/qt_extension2reader.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_extension2reader.py
BSD-3-Clause
def _add_reader_choice(self, i, plugin_name, display_name): """Add dropdown item for plugin_name with reader pattern tooltip""" reader_patterns = get_filename_patterns_for_reader(plugin_name) # TODO: no reader_patterns means directory reader, # we don't support preference association yet...
Add dropdown item for plugin_name with reader pattern tooltip
_add_reader_choice
python
napari/napari
src/napari/_qt/widgets/qt_extension2reader.py
https://github.com/napari/napari/blob/master/src/napari/_qt/widgets/qt_extension2reader.py
BSD-3-Clause