Widgets Module¶
The widgets module contains PyQt6-based GUI components for the VISTA application.
Overview¶
The widgets module provides the graphical user interface components for VISTA, including:
Core application widgets (viewers, panels, controls)
Algorithm configuration dialogs
Data management interfaces
Visualization tools
This module follows PyQt6 conventions and extends Qt widgets with VISTA-specific functionality.
Module Structure¶
The widgets module is organized into several submodules:
core- Core application widgetsalgorithms- Algorithm configuration dialogsutils- Widget utilities and helpers
Core Widgets¶
Core widgets provide the main application interface:
Data Manager: Central widget for managing imagery, detections, and tracks
Imagery Panel: Display and control imagery data
Playback Controls: Frame navigation and playback
Settings Dialog: Application configuration
Algorithm Widgets¶
Algorithm widgets provide user interfaces for configuring and running algorithms:
Detector Widgets: Configuration for detection algorithms
Tracker Widgets: Configuration for tracking algorithms
Treatment Widgets: Configuration for image treatments
Background Removal Widgets: Configuration for background subtraction
Module Reference¶
Core Widgets¶
Data manager panel - coordinating panel for managing imagery, tracks, detections, and AOIs
- class vista.widgets.core.data.data_manager.DataManagerPanel(*args, **kwargs)[source]¶
Bases:
QWidgetMain panel for managing all data types
- __init__(viewer)[source]¶
Initialize the data manager panel.
- Parameters:
viewer (ImageryViewer) – ImageryViewer instance
- on_track_selected_in_viewer(track)[source]¶
Handle track selection from viewer click. Forwards to tracks panel or detections panel depending on state.
- Parameters:
track (Track) – Track object that was clicked
Imagery panel for data manager
- class vista.widgets.core.data.imagery_panel.ImageryPanel(*args, **kwargs)[source]¶
Bases:
QWidgetPanel for managing imagery
PlaybackControls widget for controlling imagery playback
- class vista.widgets.core.playback_controls.PlaybackControls(*args, **kwargs)[source]¶
Bases:
QWidgetWidget for playback controls
- set_frame_range(min_frame, max_frame)[source]¶
Set the range of frame numbers without changing current frame
Algorithm Dialogs¶
Detector Dialogs¶
Base classes for detector widgets to reduce code duplication
- class vista.widgets.algorithms.detectors.base_detector_widget.BaseDetectorProcessingThread(*args, **kwargs)[source]¶
Bases:
QThreadBase worker thread for running detector algorithms in background
- __init__(imagery, algorithm_class, algorithm_params, aoi=None, start_frame=0, end_frame=None, detector_name=None, default_color='r', default_marker='o', default_marker_size=12)[source]¶
Initialize the processing thread.
- Parameters:
imagery (Imagery) – Imagery object to process
algorithm_class (type) – Detector algorithm class to instantiate (e.g., SimpleThreshold)
algorithm_params (dict) – Dictionary of parameters to pass to algorithm constructor
aoi (AOI, optional) – AOI object to process subset of imagery, by default None
start_frame (int, optional) – Starting frame index, by default 0
end_frame (int, optional) – Ending frame index exclusive, by default None for all frames
detector_name (str, optional) – Name for the detector, by default None (auto-generated)
default_color (str, optional) – Default color for detections, by default ‘r’
default_marker (str, optional) – Default marker for detections, by default ‘o’
default_marker_size (int, optional) – Default marker size, by default 12
- class vista.widgets.algorithms.detectors.base_detector_widget.BaseDetectorWidget(*args, **kwargs)[source]¶
Bases:
QDialogBase configuration widget for detector algorithms
- __init__(parent=None, imagery=None, aois=None, algorithm_class=None, settings_name='BaseDetector', window_title='Detector', description='', default_color='r', default_marker='o', default_marker_size=12)[source]¶
Initialize the base detector configuration widget.
- Parameters:
parent (QWidget, optional) – Parent widget, by default None
imagery (Imagery, optional) – Imagery object to process, by default None
aois (list of AOI, optional) – List of AOI objects to choose from, by default None
algorithm_class (type, optional) – Detector algorithm class (e.g., SimpleThreshold), by default None
settings_name (str, optional) – Name for QSettings storage, by default “BaseDetector”
window_title (str, optional) – Window title, by default “Detector”
description (str, optional) – HTML description text for the detector, by default “”
default_color (str, optional) – Default color for detections, by default ‘r’
default_marker (str, optional) – Default marker for detections, by default ‘o’
default_marker_size (int, optional) – Default marker size, by default 12
- add_algorithm_parameters(layout)[source]¶
Add algorithm-specific parameters to the layout. Override this method in subclasses to add custom parameters.
- Parameters:
layout (QVBoxLayout) – QVBoxLayout to add parameters to
- load_settings()[source]¶
Load previously saved settings. Override this method in subclasses to load custom parameters.
- save_settings()[source]¶
Save current settings for next time. Override this method in subclasses to save custom parameters.
- build_algorithm_params()[source]¶
Build parameter dictionary for the algorithm. Override this method in subclasses to add custom parameters.
- Returns:
Dictionary of algorithm parameters
- Return type:
- validate_parameters()[source]¶
Validate algorithm parameters before running. Override this method in subclasses for custom validation.
- set_parameters_enabled(enabled)[source]¶
Enable or disable parameter widgets. Override to handle custom parameter widgets.
- Parameters:
enabled (bool) – True to enable, False to disable
- on_processing_complete(detector)[source]¶
Handle successful completion of processing.
- Parameters:
detector (Detector) – The resulting Detector object containing all detections
Tracker Dialogs¶
Base classes for tracker dialogs to reduce code duplication
- class vista.widgets.algorithms.trackers.base_tracker_dialog.BaseTrackingWorker(*args, **kwargs)[source]¶
Bases:
QThreadBase worker thread for running trackers in background
- class vista.widgets.algorithms.trackers.base_tracker_dialog.BaseTrackingDialog(*args, **kwargs)[source]¶
Bases:
QDialogBase dialog for configuring tracker parameters
- __init__(viewer, parent=None, algorithm_function=None, settings_name='BaseTracker', window_title='Tracker', description='', default_track_color='b', default_track_marker='s', default_track_line_width=2, default_track_marker_size=10)[source]¶
Initialize the base tracking dialog.
- Parameters:
viewer (object) – VISTA viewer object
parent (QWidget, optional) – Parent widget, by default None
algorithm_function (callable, optional) – Function to call for tracking (e.g., run_simple_tracker), by default None
settings_name (str, optional) – Name for QSettings storage, by default “BaseTracker”
window_title (str, optional) – Window title, by default “Tracker”
description (str, optional) – HTML description text for the tracker, by default “”
default_track_color (str, optional) – Default color for created tracks, by default ‘b’
default_track_marker (str, optional) – Default marker for created tracks, by default ‘s’
default_track_line_width (int, optional) – Default line width for created tracks, by default 2
default_track_marker_size (int, optional) – Default marker size for created tracks, by default 10
- add_algorithm_parameters(main_layout)[source]¶
Add algorithm-specific parameters to the form layout. Override this method in subclasses to add custom parameters.
- Parameters:
main_layout (QVBoxLayout) – The main QVBoxLayout - use this if you need to add custom group boxes. For simple parameters, add to self.params_layout (QFormLayout).
- load_settings()[source]¶
Load previously saved settings. Override this method in subclasses to load custom parameters.
- save_settings()[source]¶
Save current settings for next time. Override this method in subclasses to save custom parameters.
Treatment Dialogs¶
Base classes for treatment widgets to reduce code duplication
- class vista.widgets.algorithms.treatments.base_treatment_widget.BaseTreatmentThread(*args, **kwargs)[source]¶
Bases:
QThreadBase worker thread for running treatment algorithms
- __init__(imagery, aoi=None)[source]¶
Initialize the processing thread.
- Parameters:
imagery (Imagery) – Imagery object to process
aoi (AOI, optional) – AOI object to process subset of imagery, by default None
- process_frame(frame_data, frame_index, frame_number)[source]¶
Process a single frame. Override this method in subclasses.
- class vista.widgets.algorithms.treatments.base_treatment_widget.BaseTreatmentWidget(*args, **kwargs)[source]¶
Bases:
QDialogBase configuration widget for treatment algorithms
- __init__(parent=None, imagery=None, aois=None, window_title='Treatment', description='')[source]¶
Initialize the base treatment configuration widget.
- Parameters:
parent (QWidget, optional) – Parent widget, by default None
imagery (Imagery, optional) – Imagery object to process, by default None
aois (list of AOI, optional) – List of AOI objects to choose from, by default None
window_title (str, optional) – Window title, by default “Treatment”
description (str, optional) – Description text for the treatment, by default “”
- add_treatment_ui(layout)[source]¶
Add treatment-specific UI elements. Override this method in subclasses if needed.
- Parameters:
layout (QVBoxLayout) – QVBoxLayout to add elements to
- create_processing_thread(imagery, aoi)[source]¶
Create the processing thread for this treatment. Must be implemented by subclasses.
- Parameters:
imagery (Imagery) – Imagery object to process
aoi (AOI, optional) – AOI object
- Returns:
BaseTreatmentThread instance
- Return type:
- validate_sensor_requirements()[source]¶
Validate that the sensor has required data for this treatment. Override in subclasses to check for specific sensor properties.
- set_treatment_ui_enabled(enabled)[source]¶
Enable or disable treatment-specific UI elements. Override in subclasses if there are custom UI elements.
- Parameters:
enabled (bool) – True to enable, False to disable
Extending Widgets¶
To create custom algorithm widgets, inherit from the appropriate base class:
from vista.widgets.algorithms.detectors.base_detector_widget import BaseDetectorWidget
class MyDetectorWidget(BaseDetectorWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setup_ui()
def setup_ui(self):
# Add custom UI elements
pass
def get_parameters(self):
# Return algorithm parameters
return {
'threshold': self.threshold_spinbox.value(),
'min_area': self.area_spinbox.value()
}
See Extending VISTA for more details on extending VISTA widgets.