Main window#

The cdl.core.gui.main module provides the main window of the DataLab (CDL) project.

class cdl.core.gui.main.CDLMainWindow(console=None, hide_on_close=False)#

DataLab main window

Parameters:
  • console – enable internal console

  • hide_on_close – True to hide window on close

static get_instance(console=None, hide_on_close=False)#

Return singleton instance

static xmlrpc_server_started(port)#

XML-RPC server has started, writing comm port in configuration file

get_group_titles_with_object_infos() tuple[list[str], list[list[str]], list[list[str]]]#

Return groups titles and lists of inner objects uuids and titles.

Returns:

groups titles, lists of inner objects uuids and titles

Return type:

Tuple

get_object_titles(panel: str | None = None) list[str]#

Get object (signal/image) list for current panel. Objects are sorted by group number and object index in group.

Parameters:

panel – panel name (valid values: β€œsignal”, β€œimage”, β€œmacro”). If None, current data panel is used (i.e. signal or image panel).

Returns:

List of object titles

Raises:

ValueError – if panel is unknown

get_object(nb_id_title: int | str | None = None, panel: str | None = None) SignalObj | ImageObj#

Get object (signal/image) from index.

Parameters:
  • nb_id_title – Object number, or object id, or object title. Defaults to None (current object).

  • panel – Panel name. Defaults to None (current panel).

Returns:

Object

Raises:
  • KeyError – if object not found

  • TypeError – if index_id_title type is invalid

get_object_uuids(panel: str | None = None) list[str]#

Get object (signal/image) uuid list for current panel. Objects are sorted by group number and object index in group.

Parameters:

panel (str | None) – panel name (valid values: β€œsignal”, β€œimage”). If None, current panel is used.

Returns:

list of object uuids

Return type:

list[str]

Raises:

ValueError – if panel is unknown

get_sel_object_uuids(include_groups: bool = False) list[str]#

Return selected objects uuids.

Parameters:

include_groups – If True, also return objects from selected groups.

Returns:

List of selected objects uuids.

select_objects(selection: list[int | str], panel: str | None = None) None#

Select objects in current panel.

Parameters:
  • selection – List of object numbers (1 to N) or uuids to select

  • panel – panel name (valid values: β€œsignal”, β€œimage”). If None, current panel is used. Defaults to None.

select_groups(selection: list[int | str] | None = None, panel: str | None = None) None#

Select groups in current panel.

Parameters:
  • selection – List of group numbers (1 to N), or list of group uuids, or None to select all groups. Defaults to None.

  • panel (str | None) – panel name (valid values: β€œsignal”, β€œimage”). If None, current panel is used. Defaults to None.

delete_metadata(refresh_plot: bool = True, keep_roi: bool = False) None#

Delete metadata of selected objects

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

  • keep_roi – Keep ROI. Defaults to False.

get_object_shapes(nb_id_title: int | str | None = None, panel: str | None = None) list#

Get plot item shapes associated to object (signal/image).

Parameters:
  • nb_id_title – Object number, or object id, or object title. Defaults to None (current object).

  • panel – Panel name. Defaults to None (current panel).

Returns:

List of plot item shapes

add_annotations_from_items(items: list, refresh_plot: bool = True, panel: str | None = None) None#

Add object annotations (annotation plot items).

Parameters:
  • items (list) – annotation plot items

  • refresh_plot (bool | None) – refresh plot. Defaults to True.

  • panel (str | None) – panel name (valid values: β€œsignal”, β€œimage”). If None, current panel is used.

add_label_with_title(title: str | None = None, panel: str | None = None) None#

Add a label with object title on the associated plot

Parameters:
  • title (str | None) – Label title. Defaults to None. If None, the title is the object title.

  • panel (str | None) – panel name (valid values: β€œsignal”, β€œimage”). If None, current panel is used.

run_macro(number_or_title: int | str | None = None) None#

Run 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#

Stop macro.

Parameters:

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

import_macro_from_file(filename: str) None#

Import macro from file

Parameters:

filename – Filename.

property panels: tuple[AbstractPanel, ...]#

Return the tuple of implemented panels (signal, image)

Returns:

tuple of panels

Return type:

tuple[SignalPanel, ImagePanel, MacroPanel]

confirm_memory_state() bool#

Check memory warning state and eventually show a warning dialog

Returns:

True if memory state is ok

Return type:

bool

check_stable_release() None#

Check if this is a stable release

check_for_previous_crash() None#

Check for previous crash

execute_post_show_actions() None#

Execute post-show actions

take_screenshot(name: str) None#

Take main window screenshot

take_menu_screenshots() None#

Take menu screenshots

setup(console: bool = False) None#

Setup main window

Parameters:

console – True to setup console

set_process_isolation_enabled(state: bool) None#

Enable/disable process isolation

Parameters:

state (bool) – True to enable process isolation

get_current_panel() str#

Return current panel name

Returns:

panel name (valid values: β€œsignal”, β€œimage”, β€œmacro”)

Return type:

str

set_current_panel(panel: str) None#

Switch to panel.

Parameters:

panel (str) – panel name (valid values: β€œsignal”, β€œimage”, β€œmacro”)

Raises:

ValueError – unknown panel

calc(name: str, param: DataSet | None = None) None#

Call compute function name in current panel’s processor

Parameters:
Raises:

ValueError – unknown function

has_objects() bool#

Return True if sig/ima panels have any object

set_modified(state: bool = True) None#

Set mainwindow modified state

repopulate_panel_trees() None#

Repopulate all panel trees

toggle_show_titles(state: bool) None#

Toggle show annotations option

Parameters:

state – state

toggle_auto_refresh(state: bool) None#

Toggle auto refresh option

Parameters:

state – state

toggle_show_first_only(state: bool) None#

Toggle show first only option

Parameters:

state – state

reset_all() None#

Reset all application data

save_to_h5_file(filename=None) None#

Save to a DataLab HDF5 file

Parameters:

filename (str) – HDF5 filename. If None, a file dialog is opened.

Raises:

IOError – if filename is invalid or file cannot be saved.

open_h5_files(h5files: list[str] | None = None, import_all: bool | None = None, reset_all: bool | None = None) None#

Open a DataLab HDF5 file or import from any other HDF5 file.

Parameters:
  • h5files – HDF5 filenames (optionally with dataset name, separated by β€œ:”)

  • import_all (bool) – Import all datasets from HDF5 files

  • reset_all (bool) – Reset all application data before importing

Returns:

None

browse_h5_files(filenames: list[str], reset_all: bool) None#

Browse HDF5 files

Parameters:
  • filenames (list) – HDF5 filenames

  • reset_all (bool) – Reset all application data before importing

Returns:

None

import_h5_file(filename: str, reset_all: bool | None = None) None#

Import HDF5 file into DataLab

Parameters:
  • filename (str) – HDF5 filename (optionally with dataset name,

  • " (separated by) – β€œ)

  • reset_all (bool) – Delete all DataLab signals/images before importing data

Returns:

None

add_object(obj: SignalObj | ImageObj) None#

Add object - signal or image

Parameters:

obj (SignalObj or ImageObj) – object to add (signal or image)

load_from_files(filenames: list[str]) None#

Open objects from files in current panel (signals/images)

Parameters:

filenames – list of filenames

get_version() str#

Return DataLab public version.

Returns:

DataLab version

Return type:

str

close_application() None#

Close DataLab application

raise_window() None#

Raise DataLab window

add_signal(title: str, xdata: ndarray, ydata: ndarray, xunit: str | None = None, yunit: str | None = None, xlabel: str | None = None, ylabel: str | None = None) bool#

Add signal data to DataLab.

Parameters:
  • title (str) – Signal title

  • xdata (numpy.ndarray) – X data

  • ydata (numpy.ndarray) – Y data

  • xunit (str | None) – X unit. Defaults to None.

  • yunit (str | None) – Y unit. Defaults to None.

  • xlabel (str | None) – X label. Defaults to None.

  • ylabel (str | None) – Y label. Defaults to None.

Returns:

True if signal was added successfully, False otherwise

Return type:

bool

Raises:
add_image(title: str, data: ndarray, xunit: str | None = None, yunit: str | None = None, zunit: str | None = None, xlabel: str | None = None, ylabel: str | None = None, zlabel: str | None = None) bool#

Add image data to DataLab.

Parameters:
  • title (str) – Image title

  • data (numpy.ndarray) – Image data

  • xunit (str | None) – X unit. Defaults to None.

  • yunit (str | None) – Y unit. Defaults to None.

  • zunit (str | None) – Z unit. Defaults to None.

  • xlabel (str | None) – X label. Defaults to None.

  • ylabel (str | None) – Y label. Defaults to None.

  • zlabel (str | None) – Z label. Defaults to None.

Returns:

True if image was added successfully, False otherwise

Return type:

bool

Raises:

ValueError – Invalid data dtype

play_demo() None#

Play demo

show_tour() None#

Show tour

static test_segfault_error() None#

Generate errors (both fault and traceback)

show() None#

Reimplement QMainWindow method

close_properly() bool#

Close properly

Returns:

True if closed properly, False otherwise

Return type:

bool

closeEvent(event: QCloseEvent) None#

Reimplement QMainWindow method