Panel#

The cdl.core.gui.panel package provides the panel objects for signals and images.

Three types of panels are available:

Signal and Image Panels are called Data Panels and are used to display and handle signals and images in the main window of DataLab.

Data Panels rely on the cdl.core.gui.panel.base.ObjectProp class (managing the object properties) and a set of modules to handle the GUI features:

The Macro Panel is used to display and run macros. It relies on the cdl.core.gui.macroeditor module to handle the macro edition and execution.

Base features#

cdl.core.gui.panel.base.is_plot_item_serializable(item: ShapeTypes) bool[source]#

Return True if plot item is serializable

class cdl.core.gui.panel.base.ObjectProp(panel: BaseDataPanel, paramclass: SignalObj | ImageObj)[source]#

Object handling panel properties

add_button(button)[source]#

Add additional button on bottom of properties panel

set_param_label(param: SignalObj | ImageObj)[source]#

Set computing parameters label

update_properties_from(param: SignalObj | ImageObj | None = None)[source]#

Update properties from signal/image dataset

class cdl.core.gui.panel.base.AbstractPanelMeta(name, bases, namespace, /, **kwargs)[source]#

Mixed metaclass to avoid conflicts

class cdl.core.gui.panel.base.AbstractPanel(parent)[source]#

Object defining DataLab panel interface, based on a vertical QSplitter widget

A panel handle an object list (objects are signals, images, macros, …). Each object must implement cdl.core.gui.ObjItf interface

get_serializable_name(obj: ObjItf) str[source]#

Return serializable name of object

serialize_object_to_hdf5(obj: ObjItf, writer: NativeH5Writer) None[source]#

Serialize object to HDF5 file

deserialize_object_from_hdf5(reader: NativeH5Reader, name: str) ObjItf[source]#

Deserialize object from a HDF5 file

abstract serialize_to_hdf5(writer: NativeH5Writer) None[source]#

Serialize whole panel to a HDF5 file

abstract deserialize_from_hdf5(reader: NativeH5Reader) None[source]#

Deserialize whole panel from a HDF5 file

abstract create_object() ObjItf[source]#

Create and return object

abstract add_object(obj: ObjItf) None[source]#

Add object to panel

abstract remove_all_objects()[source]#

Remove all objects

class cdl.core.gui.panel.base.ResultData(results: list[ResultShape | ResultProperties] = None, xlabels: list[str] = None, ylabels: list[str] = None)[source]#

Result data associated to a shapetype

cdl.core.gui.panel.base.create_resultdata_dict(objs: list[SignalObj | ImageObj]) dict[str, ResultData][source]#

Return result data dictionary

Parameters:

objs – List of objects

Returns:

keys are result categories, values are ResultData

Return type:

Result data dictionary

class cdl.core.gui.panel.base.BaseDataPanel(parent: QWidget)[source]#

Object handling the item list, the selected item properties and plot

closeEvent(event)[source]#

Reimplement QMainWindow method

plot_item_parameters_changed(item: CurveItem | MaskedImageItem | LabelItem) None[source]#

Plot items changed: update metadata of all objects from plot items

plot_item_moved(item: LabelItem, x0: float, y0: float, x1: float, y1: float) None[source]#

Plot item moved: update metadata of all objects from plot items

Parameters:
  • item – Plot item

  • x0 – new x0 coordinate

  • y0 – new y0 coordinate

  • x1 – new x1 coordinate

  • y1 – new y1 coordinate

serialize_object_to_hdf5(obj: SignalObj | ImageObj, writer: NativeH5Writer) None[source]#

Serialize object to HDF5 file

serialize_to_hdf5(writer: NativeH5Writer) None[source]#

Serialize whole panel to a HDF5 file

deserialize_from_hdf5(reader: NativeH5Reader) None[source]#

Deserialize whole panel from a HDF5 file

create_object() SignalObj | ImageObj[source]#

Create object (signal or image)

Returns:

SignalObj or ImageObj object

add_object(obj: SignalObj | ImageObj, group_id: str | None = None, set_current: bool = True) None[source]#

Add object

Parameters:
  • obj – SignalObj or ImageObj object

  • group_id – group id

  • set_current – if True, set the added object as current

remove_all_objects() None[source]#

Remove all objects

setup_panel() None[source]#

Setup panel

get_category_actions(category: ActionCategory) list[QAction][source]#

Return actions for category

get_context_menu() QMenu[source]#

Update and return context menu

add_group(title: str) ObjectGroup[source]#

Add group

duplicate_object() None[source]#

Duplication signal/image object

copy_metadata() None[source]#

Copy object metadata

paste_metadata() None[source]#

Paste metadata to selected object(s)

remove_object(force: bool = False) None[source]#

Remove signal/image object

Parameters:

force – if True, remove object without confirmation. Defaults to False.

delete_all_objects() None[source]#

Confirm before removing all objects

delete_metadata(refresh_plot: bool = True, keep_roi: bool | None = None) None[source]#

Delete metadata of selected objects

Parameters:
  • refresh_plot – Refresh plot. Defaults to True.

  • keep_roi – Keep regions of interest, if any. Defaults to None (ask user).

add_annotations_from_items(items: list, refresh_plot: bool = True) None[source]#

Add object annotations (annotation plot items).

Parameters:
  • items – annotation plot items

  • refresh_plot – refresh plot. Defaults to True.

update_metadata_view_settings() None[source]#

Update metadata view settings

copy_titles_to_clipboard() None[source]#

Copy object titles to clipboard (for reproducibility)

new_group() None[source]#

Create a new group

rename_group() None[source]#

Rename a group

abstract get_newparam_from_current(newparam: NewSignalParam | NewImageParam | None = None) NewSignalParam | NewImageParam | None[source]#

Get new object parameters from the current object.

Parameters:

newparam – new object parameters. If None, create a new one.

Returns:

New object parameters

abstract new_object(newparam: NewSignalParam | NewImageParam | None = None, addparam: gds.DataSet | None = None, edit: bool = True, add_to_panel: bool = True) SignalObj | ImageObj | None[source]#

Create a new object (signal/image).

Parameters:
  • newparam – new object parameters

  • addparam – additional parameters

  • edit – Open a dialog box to edit parameters (default: True)

  • add_to_panel – Add object to panel (default: True)

Returns:

New object

set_current_object_title(title: str) None[source]#

Set current object title

load_from_files(filenames: list[str] | None = None) list[SignalObj | ImageObj][source]#

Open objects from file (signals/images), add them to DataLab and return them.

Parameters:

filenames – File names

Returns:

list of new objects

save_to_files(filenames: list[str] | str | None = None) None[source]#

Save selected objects to files (signal/image).

Parameters:

filenames – File names

handle_dropped_files(filenames: list[str] | None = None) None[source]#

Handle dropped files

Parameters:

filenames – File names

Returns:

None

exec_import_wizard() None[source]#

Execute import wizard

import_metadata_from_file(filename: str | None = None) None[source]#

Import metadata from file (JSON).

Parameters:

filename – File name

export_metadata_from_file(filename: str | None = None) None[source]#

Export metadata to file (JSON).

Parameters:

filename – File name

selection_changed(update_items: bool = False) None[source]#

Object selection changed: update object properties, refresh plot and update object view.

Parameters:

update_items – Update plot items (default: False)

properties_changed() None[source]#

The properties ‘Apply’ button was clicked: update object properties, refresh plot and update object view.

open_separate_view(oids: list[str] | None = None, edit_annotations: bool = False) PlotDialog | None[source]#

Open separate view for visualizing selected objects

Parameters:
  • oids – Object IDs (default: None)

  • edit_annotations – Edit annotations (default: False)

Returns:

Instance of PlotDialog

manual_refresh() None[source]#

Manual refresh

create_new_dialog(oids: list[str], edit: bool = False, toolbar: bool = True, title: str | None = None, tools: list[GuiTool] | None = None, name: str | None = None, options: dict | None = None) PlotDialog | None[source]#

Create new pop-up signal/image plot dialog.

Parameters:
  • oids – Object IDs

  • edit – Edit mode

  • toolbar – Show toolbar

  • title – Dialog title

  • tools – list of tools to add to the toolbar

  • name – Dialog name

  • options – Plot options

Returns:

QDialog instance

create_new_dialog_for_selection(title: str, name: str, options: dict[str, any] = None, toolbar: bool = False, tools: list[GuiTool] = None) tuple[PlotDialog | None, SignalObj | ImageObj][source]#

Create new pop-up dialog for the currently selected signal/image.

Parameters:
  • title – Dialog title

  • name – Dialog name

  • options – Plot options

  • toolbar – Show toolbar

  • tools – list of tools to add to the toolbar

Returns:

QDialog instance, selected object

get_roi_dialog(extract: bool, singleobj: bool, add_roi: bool = False) tuple[ROIDataParam, bool] | None[source]#

Get ROI data (array) from specific dialog box.

Parameters:
  • extract – Extract ROI from data

  • singleobj – Single object

  • add_roi – Add ROI immediately after opening the dialog (default: False)

Returns:

ROI data

get_object_with_dialog(title: str, parent: QW.QWidget | None = None) SignalObj | ImageObj | None[source]#

Get object with dialog box.

Parameters:
  • title – Dialog title

  • parent – Parent widget

Returns:

Object (signal or image, or None if dialog was canceled)

add_objprop_buttons() None[source]#

Insert additional buttons in object properties panel

show_results() None[source]#

Show results

plot_results() None[source]#

Plot results

delete_results() None[source]#

Delete results

add_label_with_title(title: str | None = None) None[source]#

Add a label with object title on the associated plot

Parameters:

title – Label title. Defaults to None. If None, the title is the object title.

Signal panel#

class cdl.core.gui.panel.signal.SignalPanel(parent: QW.QWidget, dockableplotwidget: DockablePlotWidget, panel_toolbar: QW.QToolBar)[source]#

Object handling the item list, the selected item properties and plot, specialized for Signal objects

PARAMCLASS#

Signal object

uuid#

Default: None.

Type:

guidata.dataset.dataitems.StringItem

xydata#

Default: None.

Type:

guidata.dataset.dataitems.FloatArrayItem

metadata#

Default: {}.

Type:

guidata.dataset.dataitems.DictItem

title#

Signal title. Default: ‘Untitled’.

Type:

guidata.dataset.dataitems.StringItem

xlabel#

Title. Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

xunit#

Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

ylabel#

Title. Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

yunit#

Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

autoscale#

Default: True.

Type:

guidata.dataset.dataitems.BoolItem

xscalelog#

Default: False.

Type:

guidata.dataset.dataitems.BoolItem

xscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

xscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

yscalelog#

Default: False.

Type:

guidata.dataset.dataitems.BoolItem

yscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

yscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

alias of SignalObj

classmethod PARAMCLASS.create(uuid: str, xydata: numpy.ndarray, metadata: dict, title: str, xlabel: str, xunit: str, ylabel: str, yunit: str, autoscale: bool, xscalelog: bool, xscalemin: float, xscalemax: float, yscalelog: bool, yscalemin: float, yscalemax: float) cdl.core.model.signal.SignalObj#

Returns a new instance of SignalObj with the fields set to the given values.

Parameters:
  • uuid (str) – Default: None.

  • xydata (numpy.ndarray) – Default: None.

  • metadata (dict) – Default: {}.

  • title (str) – Signal title. Default: ‘Untitled’.

  • xlabel (str) – Title. Default: ‘’.

  • xunit (str) – Default: ‘’.

  • ylabel (str) – Title. Default: ‘’.

  • yunit (str) – Default: ‘’.

  • autoscale (bool) – Default: True.

  • xscalelog (bool) – Default: False.

  • xscalemin (float) – Lower bound. Default: None.

  • xscalemax (float) – Upper bound. Default: None.

  • yscalelog (bool) – Default: False.

  • yscalemin (float) – Lower bound. Default: None.

  • yscalemax (float) – Upper bound. Default: None.

Returns:

New instance of SignalObj.

IO_REGISTRY#

alias of SignalIORegistry

ROIDIALOGCLASS#

alias of SignalROIEditor

get_newparam_from_current(newparam: NewSignalParam | None = None, title: str | None = None) NewSignalParam | None[source]#

Get new object parameters from the current object.

Parameters:
  • newparam (guidata.dataset.DataSet) – new object parameters. If None, create a new one.

  • title – new object title. If None, use the current object title, or the default title.

Returns:

New object parameters

new_object(newparam: NewSignalParam | None = None, addparam: gds.DataSet | None = None, edit: bool = True, add_to_panel: bool = True) SignalObj | None[source]#

Create a new object (signal).

Parameters:
Returns:

New object

toggle_anti_aliasing(state: bool) None[source]#

Toggle anti-aliasing on/off

Parameters:

state – state of the anti-aliasing

reset_curve_styles() None[source]#

Reset curve styles

Image panel#

class cdl.core.gui.panel.image.ImagePanel(parent: QW.QWidget, dockableplotwidget: DockablePlotWidget, panel_toolbar: QW.QToolBar)[source]#

Object handling the item list, the selected item properties and plot, specialized for Image objects

PARAMCLASS#

Image object

uuid#

Default: None.

Type:

guidata.dataset.dataitems.StringItem

data#

Default: None.

Type:

guidata.dataset.dataitems.FloatArrayItem

metadata#

Default: {}.

Type:

guidata.dataset.dataitems.DictItem

x0#

X0. Default: 0.0.

Type:

guidata.dataset.dataitems.FloatItem

y0#

Y0. Default: 0.0.

Type:

guidata.dataset.dataitems.FloatItem

dx#

Δx. Float, non zero. Default: 1.0.

Type:

guidata.dataset.dataitems.FloatItem

dy#

Δy. Float, non zero. Default: 1.0.

Type:

guidata.dataset.dataitems.FloatItem

title#

Image title. Default: ‘Untitled’.

Type:

guidata.dataset.dataitems.StringItem

xlabel#

Title. Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

xunit#

Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

ylabel#

Title. Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

yunit#

Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

zlabel#

Title. Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

zunit#

Default: ‘’.

Type:

guidata.dataset.dataitems.StringItem

autoscale#

Default: True.

Type:

guidata.dataset.dataitems.BoolItem

xscalelog#

Default: False.

Type:

guidata.dataset.dataitems.BoolItem

xscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

xscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

yscalelog#

Default: False.

Type:

guidata.dataset.dataitems.BoolItem

yscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

yscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

zscalemin#

Lower bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

zscalemax#

Upper bound. Default: None.

Type:

guidata.dataset.dataitems.FloatItem

alias of ImageObj

classmethod PARAMCLASS.create(uuid: str, data: numpy.ndarray, metadata: dict, x0: float, y0: float, dx: float, dy: float, title: str, xlabel: str, xunit: str, ylabel: str, yunit: str, zlabel: str, zunit: str, autoscale: bool, xscalelog: bool, xscalemin: float, xscalemax: float, yscalelog: bool, yscalemin: float, yscalemax: float, zscalemin: float, zscalemax: float) cdl.core.model.image.ImageObj#

Returns a new instance of ImageObj with the fields set to the given values.

Parameters:
  • uuid (str) – Default: None.

  • data (numpy.ndarray) – Default: None.

  • metadata (dict) – Default: {}.

  • x0 (float) – X0. Default: 0.0.

  • y0 (float) – Y0. Default: 0.0.

  • dx (float) – Δx. Float, non zero. Default: 1.0.

  • dy (float) – Δy. Float, non zero. Default: 1.0.

  • title (str) – Image title. Default: ‘Untitled’.

  • xlabel (str) – Title. Default: ‘’.

  • xunit (str) – Default: ‘’.

  • ylabel (str) – Title. Default: ‘’.

  • yunit (str) – Default: ‘’.

  • zlabel (str) – Title. Default: ‘’.

  • zunit (str) – Default: ‘’.

  • autoscale (bool) – Default: True.

  • xscalelog (bool) – Default: False.

  • xscalemin (float) – Lower bound. Default: None.

  • xscalemax (float) – Upper bound. Default: None.

  • yscalelog (bool) – Default: False.

  • yscalemin (float) – Lower bound. Default: None.

  • yscalemax (float) – Upper bound. Default: None.

  • zscalemin (float) – Lower bound. Default: None.

  • zscalemax (float) – Upper bound. Default: None.

Returns:

New instance of ImageObj.

IO_REGISTRY#

alias of ImageIORegistry

ROIDIALOGCLASS#

alias of ImageROIEditor

properties_changed() None[source]#

The properties ‘Apply’ button was clicked: updating signal

plot_lut_changed(plot: BasePlot) None[source]#

The LUT of the plot has changed: updating image objects accordingly

Parameters:

plot – Plot object

get_newparam_from_current(newparam: NewImageParam | None = None, title: str | None = None) NewImageParam | None[source]#

Get new object parameters from the current object.

Parameters:
  • newparam (guidata.dataset.DataSet) – new object parameters. If None, create a new one.

  • title – new object title. If None, use the current object title, or the default title.

Returns:

New object parameters

new_object(newparam: NewImageParam | None = None, addparam: gds.DataSet | None = None, edit: bool = True, add_to_panel: bool = True) ImageObj | None[source]#

Create a new object (image).

Parameters:
  • newparam (Daguidata.dataset.datatypes.DataSettaSet) – new object parameters

  • addparam (guidata.dataset.DataSet) – additional parameters

  • edit (bool) – Open a dialog box to edit parameters (default: True)

  • add_to_panel (bool) – Add the object to the panel (default: True)

Returns:

New object

delete_metadata(refresh_plot: bool = True, keep_roi: bool | None = None) None[source]#

Delete metadata of selected objects

Parameters:
  • refresh_plot – Refresh plot. Defaults to True.

  • keep_roi – Keep regions of interest, if any. Defaults to None (ask user).

toggle_show_contrast(state: bool) None[source]#

Toggle show contrast option

Macro panel#

class cdl.core.gui.panel.macro.MacroTabs(parent=None)[source]#

Macro tabwidget

Parameters:

parent (QWidget) – Parent widget

clear() None[source]#

Override Qt method

contextMenuEvent(event)[source]#

Override Qt method

add_tab(macro: Macro) int[source]#

Add tab

Parameters:

macro – Macro object

Returns:

Number of the tab (starting at 1)

Return type:

int

remove_tab(number: int) None[source]#

Remove tab

Parameters:

number – Number of the tab (starting at 1)

get_widget(number: int) CodeEditor[source]#

Return macro editor widget at number

Parameters:

number – Number of the tab (starting at 1)

Returns:

Macro editor widget

set_current_number(number: int) None[source]#

Set current tab number

Parameters:

number – Number of the tab (starting at 1)

get_current_number() int[source]#

Return current tab number

Returns:

Number of the tab (starting at 1)

Return type:

int

set_tab_title(number: int, name: str) None[source]#

Set tab title

Parameters:
  • number – Number of the tab (starting at 1)

  • name – Macro name

class cdl.core.gui.panel.macro.MacroPanel(parent: QWidget | None = None)[source]#

Macro Panel widget

Parameters:

parent (QWidget) – Parent widget

get_serializable_name(obj: Macro) str[source]#

Return serializable name of object

serialize_to_hdf5(writer: NativeH5Writer) None[source]#

Serialize whole panel to a HDF5 file

Parameters:

writer – HDF5 writer

deserialize_from_hdf5(reader: NativeH5Reader) None[source]#

Deserialize whole panel from a HDF5 file

Parameters:

reader – HDF5 reader

create_object() Macro[source]#

Create object.

Returns:

Macro object

add_object(obj: Macro) None[source]#

Add object.

Parameters:

obj – Macro object

remove_all_objects() None[source]#

Remove all objects

setup_actions() None[source]#

Setup macro menu actions

get_macro(number_or_title: int | str | None = None) Macro | None[source]#

Return macro at number (if number is None, return current macro)

Parameters:

number – Number of the macro (starting at 1) or title of the macro. Defaults to None (current macro).

Returns:

Macro object or None (if not found)

get_number_from_title(title: str) int | None[source]#

Return macro number from title

Parameters:

title – Title of the macro

Returns:

Number of the macro (starting at 1) or None (if not found)

get_number_from_macro(macro: Macro) int | None[source]#

Return macro number from macro object

Parameters:

macro – Macro object

Returns:

Number of the macro (starting at 1) or None (if not found)

get_macro_titles() list[str][source]#

Return list of macro titles

macro_contents_changed() None[source]#

One of the macro contents has changed

run_macro(number_or_title: int | str | None = None) None[source]#

Run current macro

Parameters:

number – Number of the macro (starting at 1). Defaults to None (run current macro, or does nothing if there is no macro).

stop_macro(number_or_title: int | str | None = None) None[source]#

Stop current macro

Parameters:

number – Number of the macro (starting at 1). Defaults to None (run current macro, or does nothing if there is no macro).

macro_state_changed(orig_macro: Macro, state: bool) None[source]#

Macro state has changed (True: started, False: stopped)

Parameters:
  • orig_macro – Macro object

  • state – State of the macro

add_macro() Macro[source]#

Add macro, optionally with name

Returns:

Macro object

macro_name_changed(name: str) None[source]#

Macro name has been changed

Parameters:

name – New name of the macro

rename_macro(number: int | None = None, title: str | None = None) None[source]#

Rename macro

Parameters:
  • number – Number of the macro (starting at 1). Defaults to None.

  • title – Title of the macro. Defaults to None.

export_macro_to_file(number_or_title: int | str | None = None, filename: str | None = None) None[source]#

Export macro to file

Parameters:
  • number_or_title – Number of the macro (starting at 1) or title of the macro. Defaults to None.

  • filename – Filename. Defaults to None.

Raises:

ValueError – If title is not found

import_macro_from_file(filename: str | None = None) int[source]#

Import macro from file

Parameters:

filename – Filename. Defaults to None.

Returns:

Number of the macro (starting at 1)

remove_macro(number_or_title: int | str | None = None) None[source]#

Remove macro

Parameters:

number_or_title – Number of the macro (starting at 1) or title of the macro. Defaults to None.