sigimax.widgets — Reusable Qt Widgets#
SigimaX widgets#
Reusable Qt widgets for SigimaX-derived applications.
Convenience imports#
The most commonly used widgets are re-exported here for easy access:
from sigimax.widgets import H5Browser, Wizard, LogViewerWindow
Specialized scientific dialogs (fit, peak detection, baseline, etc.) remain accessible via their submodule:
from sigimax.widgets.fitdialog import gaussian_fit
from sigimax.widgets.signalpeak import SignalPeakDetectionDialog
Submodules#
Docks |
|
Connection dialog |
|
Module providing a file dialog widget based on Qt's QFileDialog.getOpenFileNames but supporting multiple file preselection (Qt original dialog only supports single file selection). |
|
Module providing a file viewer widget |
|
Curve fitting dialog widgets |
|
SigimaX HDF5 browser module |
|
Image background selection dialog. |
|
Module providing a log viewer widget, a log viewer window and SigimaX's log viewer |
|
Object dialog |
|
Signal base line selection dialog. |
|
Signal horizontal or vertical cursor selection dialog. |
|
GUI dialog for analyzing signals and calculating full width at Y. |
|
Signal peak detection feature |
|
Splash screen |
|
SigimaX main window status bar widgets |
|
Module providing a warning/error message box |
|
SigimaX Wizard Widget |
Submodules#
Docks#
The sigimax.widgets.plotdock module provides the dockable plot widgets
for the SigimaX main window.
Plot widget#
Dockable plot widget#
- class sigimax.widgets.plotdock.DockablePlotWidget(parent: QWidget, plot_type: PlotType)[source]#
Docked plotting widget
- Parameters:
parent – Parent widget
plot_type – Plot type
- PLOTWIDGET_CLASS#
Plot widget class instantiated by this dock: override in subclasses to provide an application-specific one.
alias of
SigimaXPlotWidget
Splash screen#
The sigimax.widgets.splashscreen module provides a configurable splash
screen for SigimaX-derived applications.
Derived applications can customize the splash screen by providing a
SplashScreenConfig instance, or by subclassing
SigimaXSplashScreen for advanced rendering.
Basic usage:
from sigimax.widgets.splashscreen import SplashScreenConfig, SigimaXSplashScreen
config = SplashScreenConfig(
image_path="path/to/splash.png",
app_name="MyApp",
app_version="1.0.0",
tagline="Scientific Data Processing",
)
splash = SigimaXSplashScreen(config)
splash.show()
splash.show_message("Loading modules...")
# ... heavy initialization ...
splash.finish(main_window)
Factory from global configuration:
splash = SigimaXSplashScreen.from_conf()
if splash is not None:
splash.show()
# ...
splash.finish(main_window)
- class sigimax.widgets.splashscreen.SplashScreenConfig(image_path: str | None = None, app_name: str = '', app_version: str = '', tagline: str = '', show_progress: bool = True, text_color: QColor = <factory>, text_alignment: AlignmentFlag = <factory>)[source]#
Configuration for a splash screen.
All fields are optional except image_path. When image_path is empty or
None, no splash screen is shown.- Parameters:
image_path – Absolute or relative path to the splash image (PNG, SVG, or any format supported by
QPixmap), or name of an image registered in guidata’s image paths. A@2xhigh-resolution variant of the image (e.g.splash@2x.pngnext tosplash.png) is used on high-DPI displays, if available. If empty orNone, the splash screen is disabled.app_name – Application name overlaid on the splash image.
app_version – Application version overlaid on the splash image.
tagline – Optional subtitle displayed below the version.
show_progress – If
True, progress messages are displayed at the bottom of the splash screen viaSigimaXSplashScreen.show_message().text_color – Color used for overlay text (default: white).
text_alignment – Qt alignment flags for overlay text (default: bottom-left).
- classmethod from_conf() SplashScreenConfig[source]#
Build a
SplashScreenConfigfrom the globalsigimax.config.CONFoptions.- Returns:
Configuration instance populated from global options.
- class sigimax.widgets.splashscreen.SigimaXSplashScreen(config: SplashScreenConfig | None = None)[source]#
Configurable splash screen for SigimaX-derived applications.
Creates a
QSplashScreenfrom aSplashScreenConfig. If the configuration specifies an application name/version, they are painted as overlay text on top of the splash image.- Parameters:
config – Splash screen configuration. If
None, a default configuration is built fromsigimax.config.CONF.
- show_message(message: str) None[source]#
Display a progress message on the splash screen.
The message is shown only if
SplashScreenConfig.show_progressisTrue.- Parameters:
message – The progress message to display.
- classmethod from_conf() SigimaXSplashScreen | None[source]#
Factory: build a splash screen from the global configuration.
- Returns:
A
SigimaXSplashScreeninstance, orNoneif the configuration does not specify a splash image.
SigimaX HDF5 browser module
- class sigimax.widgets.h5browser.H5Browser(parent: QWidget | None = None)[source]#
HDF5 Browser Widget
- Parameters:
parent – Parent widget
- open_file(fname: str) None[source]#
Open HDF5 file, and select its default NeXus
NXdatagroup, if any- Parameters:
fname – HDF5 file name
- class sigimax.widgets.h5browser.H5BrowserDialog(parent: QWidget | None = None, size: tuple[int, int] = (1150, 700))[source]#
HDF5 Browser Dialog
- Parameters:
parent – Parent widget
size – Dialog size
- accept() None[source]#
Accept changes, once confirmed if many frames of multidimensional datasets are to be imported (the frames are counted, and only created once confirmed)
- done(result: int) None[source]#
Close dialog, once the preview being read is done: the selected nodes are then read by the caller, and the files closed
- class sigimax.widgets.h5browser.H5TreeWidget(parent: QWidget)[source]#
HDF5 Browser Tree Widget
- Parameters:
parent – Parent widget
- add_root(fname: str) QTreeWidgetItem | None[source]#
Add HDF5 root (new file)
- Parameters:
fname – HDF5 file name
- Returns:
Item of the default NeXus
NXdatagroup of the file (@defaultattributes), expanded, or None
- find_node_item(rootitem: QTreeWidgetItem, node_id: str) QTreeWidgetItem | None[source]#
Return the item of a node of a file, by node id
- Parameters:
rootitem – root item of the file
node_id – node id
- set_item_importable(item: QTreeWidgetItem, state: bool) None[source]#
Make the item of a multidimensional node checkable and checked, once the import of its frames is enabled, or neither of them
- Parameters:
item – tree item
state – True if the frames of the node are to be imported
- get_node(item: QW.QTreeWidgetItem) BaseNode[source]#
Get HDF5 dataset associated to item
- Parameters:
item – Tree item
- Returns:
HDF5 node
- get_nodes(only_checked_items: bool = True, expand: bool = True) list[BaseNode][source]#
Get all nodes associated to checked items
Multidimensional nodes are replaced by the nodes of the frames of their view (see
sigimax.h5.views.expand_views()), unlessexpandis False.- Parameters:
only_checked_items – If True, only checked items are returned
expand – If True, multidimensional nodes are replaced by the nodes of their frames
- Returns:
List of HDF5 nodes
- select_all(state: bool) None[source]#
Select all items
- Parameters:
state – If True, all items are selected
- toggle_all(state: bool) None[source]#
Toggle all item state from ‘unchecked’ to ‘checked’ (or vice-versa)
- Parameters:
state – If True, all items are checked
- update_item(item: QTreeWidgetItem) None[source]#
Update the item of a node from its current state: texts, tooltip, icon and check box (e.g. once problems were found when reading its data, which make it no longer supported)
- Parameters:
item – tree item
- expand_all_children(item: QTreeWidgetItem) None[source]#
Expand all children (recursively)
- Parameters:
item – Tree item
- add_root_to_tree(importer: H5Importer) None[source]#
Add root to tree
- Parameters:
importer – HDF5 importer
- toggle_show_only_checkable_items(state: bool) None[source]#
Show only checkable items
- Parameters:
state – If True, only checkable items are shown
Module providing a log viewer widget, a log viewer window and SigimaX’s log viewer
- class sigimax.widgets.logviewer.LogViewerWindow(fnames: list[str], parent: QWidget | None = None)[source]#
Log viewer window
- sigimax.widgets.logviewer.get_log_prompt_message() str | None[source]#
Return prompt message for log files, i.e. a message informing the user whether log files were generated during last session or current session.
- sigimax.widgets.logviewer.exec_sigimax_logviewer_dialog(parent: QWidget | None = None) None[source]#
View SigimaX logs
SigimaX main window status bar widgets
- class sigimax.widgets.status.BaseStatus(delay: int | None = None, parent: QWidget | None = None)[source]#
Base status widget.
- Parameters:
delay (int | None) – update interval (s). If None, widget will not be updated.
parent (QWidget) – parent widget
- class sigimax.widgets.status.ConsoleStatus(parent: QWidget | None = None)[source]#
Console status widget.
Shows a message if an error or warning has been logged to the console. Shows a button to show the console, only if the console is hidden.
- Parameters:
parent (QWidget) – parent widget
- on_click(event: QMouseEvent) None[source]#
Handle mouse click event on label.
- Parameters:
event – mouse event
- class sigimax.widgets.status.MemoryStatus(threshold: int = 500, delay: int = 2, parent: QWidget | None = None)[source]#
Memory status widget.
- Parameters:
- set_demo_mode(state: bool) None[source]#
Set demo mode state (used when taking screenshots). The demo mode allows to take screenshots which always look the same. (this will set memory usage to a constant value). If demo mode is set to False, memory usage will be set to actual value.
- Parameters:
state (bool) – demo mode state
Curve fitting dialog widgets
- sigimax.widgets.fitdialog.guifit(x, y, fitfunc, fitparams, fitargs=None, fitkwargs=None, wintitle=None, title=None, xlabel=None, ylabel=None, param_cols=1, auto_fit=True, winsize=None, winpos=None, parent=None, name=None, formula=None)[source]#
GUI-based curve fitting tool
The optional
formula(Qt rich text) is displayed below the fit parameters, so that the user knows which model is fitted.
- sigimax.widgets.fitdialog.create_formula_label(formula: str, parent: QWidget | None = None) QLabel[source]#
Create a selectable rich-text label showing a fit model formula.
- Parameters:
formula – Model formula, as Qt rich text (see
sigima.tools.signal.fitting.FitComputer.FORMULA).parent – Parent widget.
- Returns:
Formula label.
- sigimax.widgets.fitdialog.linear_fit(x: ndarray, y: ndarray, parent=None, name=None)[source]#
Compute linear fit using polynomialfit.
Returns (yfit, params, fit_params), where yfit is the fitted curve, params are the fitting parameters and fit_params is the canonical metadata dictionary
- sigimax.widgets.fitdialog.polynomial_fit(x, y, degree, parent=None, name=None, fit_type='polynomial')[source]#
Compute polynomial fit
Returns (yfit, params, fit_params), where yfit is the fitted curve, params are the fitting parameters and fit_params is the canonical metadata dictionary
- sigimax.widgets.fitdialog.gaussian_fit(x, y, parent=None, name=None)[source]#
Compute Gaussian fit
Returns (yfit, params), where yfit is the fitted curve and params are the fitting parameters
- sigimax.widgets.fitdialog.lorentzian_fit(x, y, parent=None, name=None)[source]#
Compute Lorentzian fit
Returns (yfit, params), where yfit is the fitted curve and params are the fitting parameters
- sigimax.widgets.fitdialog.voigt_fit(x, y, parent=None, name=None)[source]#
Compute Voigt fit
Returns (yfit, params), where yfit is the fitted curve and params are the fitting parameters
- sigimax.widgets.fitdialog.multigaussian_fit(x, y, peak_indices, parent=None, name=None)[source]#
Compute Multi-Gaussian fit
Returns (yfit, params), where yfit is the fitted curve and params are the fitting parameters
- sigimax.widgets.fitdialog.multilorentzian_fit(x: ndarray, y: ndarray, peak_indices, parent=None, name=None)[source]#
Compute Multi-Lorentzian fit
Returns (yfit, params), where yfit is the fitted curve and params are the fitting parameters
- sigimax.widgets.fitdialog.exponential_fit(x: ndarray, y: ndarray, parent=None, name=None)[source]#
Compute exponential fit
Returns (yfit, params, fit_params), where yfit is the fitted curve, params are the fitting parameters and fit_params is the canonical metadata dictionary
- sigimax.widgets.fitdialog.sinusoidal_fit(x: ndarray, y: ndarray, parent=None, name=None)[source]#
Compute sinusoidal fit
Returns (yfit, params, fit_params), where yfit is the fitted curve, params are the fitting parameters and fit_params is the canonical metadata dictionary
- sigimax.widgets.fitdialog.cdf_fit(x: ndarray, y: ndarray, parent=None, name=None)[source]#
Compute Cumulative Distribution Function (CDF) fit
Returns (yfit, params, fit_params), where yfit is the fitted curve, params are the fitting parameters and fit_params is the canonical metadata dictionary
- sigimax.widgets.fitdialog.planckian_fit(x: ndarray, y: ndarray, parent=None, name=None)[source]#
Compute Planckian (blackbody radiation) fit
Returns (yfit, params, fit_params), where yfit is the fitted curve, params are the fitting parameters and fit_params is the canonical metadata dictionary
- sigimax.widgets.fitdialog.twohalfgaussian_fit(x: ndarray, y: ndarray, parent=None, name=None)[source]#
Compute two half-Gaussian fit for asymmetric peaks
Returns (yfit, params, fit_params), where yfit is the fitted curve, params are the fitting parameters and fit_params is the canonical metadata dictionary
- sigimax.widgets.fitdialog.piecewiseexponential_fit(x: ndarray, y: ndarray, parent=None, name=None)[source]#
Compute piecewise exponential fit (raise-decay)
Returns (yfit, params, fit_params), where yfit is the fitted curve, params are the fitting parameters and fit_params is the canonical metadata dictionary
Signal peak detection feature
- class sigimax.widgets.signalpeak.SignalPeakDetectionDialog(signal: SignalObj, parent: QWidget | None = None)[source]#
Signal Peak detection dialog
- Parameters:
signal – signal object
parent – parent widget. Defaults to None.
Signal base line selection dialog.
- class sigimax.widgets.signalbaseline.SignalBaselineDialog(signal: SignalObj, parent: QWidget | None = None)[source]#
Signal baseline selection dialog.
- Parameters:
signal – signal object
parent – parent widget. Defaults to None.
Signal horizontal or vertical cursor selection dialog.
- class sigimax.widgets.signalcursor.SignalCursorDialog(signal: SignalObj, cursor_orientation: Literal['horizontal', 'vertical'], parent: QWidget | None = None)[source]#
Signal horizontal or vertical cursor selection dialog.
- Parameters:
signal – signal object
parent – parent widget. Defaults to None.
GUI dialog for analyzing signals and calculating full width at Y.
- class sigimax.widgets.signaldeltax.SignalDeltaXDialog(signal: SignalObj, parent: QWidget | None = None)[source]#
Signal Delta X dialog.
- Parameters:
signal – signal object
parent – parent widget. Defaults to None.
Image background selection dialog.
- class sigimax.widgets.imagebackground.ImageBackgroundDialog(image: ImageObj, parent: QWidget | None = None, options: PlotOptions | dict[str, Any] | None = None)[source]#
Image background selection dialog.
- Parameters:
image – image object
parent – parent widget. Defaults to None.
options – plot options. Defaults to None.
SigimaX Wizard Widget#
The SigimaX Wizard is a widget that guides the user through a series of steps to complete a task. It is implemented as a series of pages, each of which is a separate widget.
The Wizard class is the main widget that contains the pages. The WizardPage class is the base class for the pages.
This module is strongly inspired from Qt’s QWizard and QWizardPage classes.
Note
The only motivation for reimplementing the wizard widget is to support complete styling with QPalette and QStyle (e.g. guidata’s dark mode is not supported on Windows).
- class sigimax.widgets.wizard.Wizard(parent: QWidget | None = None)[source]#
Wizard base class
- cleanup() None[source]#
Release page resources before the dialog is destroyed.
Pages that embed native-heavy widgets (e.g. a PlotPy plot) may expose a
cleanupmethod to tear those resources down deterministically. This avoids a Qt/PlotPy native teardown race (access violation) when several wizards are created and destroyed in sequence.
- add_page(page: WizardPage, last_page: bool = False) None[source]#
Add a page to the wizard
- class sigimax.widgets.wizard.WizardPage(parent: QWidget | None = None)[source]#
Wizard page base class
We create our own wizard page class instead of using QWizardPage because the latter does not support complete styling with QPalette and QStyle (e.g. guidata’s dark mode is not supported on Windows).
This class reimplements the QWizardPage features.
Module providing a warning/error message box
- class sigimax.widgets.warningerror.WarningErrorMessageBox(parent: QWidget | None, category: str, context: str = None, message: str = None, tip: str = None)[source]#
Warning/Error message box
- Parameters:
- sigimax.widgets.warningerror.show_warning_error(parent: QWidget | None, category: str, context: str = None, message: str = None, tip: str = None) None[source]#
Show error message
Module providing a file dialog widget based on Qt’s QFileDialog.getOpenFileNames but supporting multiple file preselection (Qt original dialog only supports single file selection).
- sigimax.widgets.filedialog.get_open_file_names(parent: QWidget | None = None, caption: str = '', basedir: str | list[str] = '', filters: str = '', selectedfilter: str = '', options: Options = None) tuple[list[str], str][source]#
Wrapper around QtGui.QFileDialog.getOpenFileNames static method Returns a tuple (filenames, selectedfilter) – when dialog box is canceled, returns a tuple (empty list, empty string)
- Parameters:
parent – Parent widget for the dialog.
caption – Dialog title.
basedir – Initial directory to open the dialog in, or preselected files (single string or list of strings).
filters – File filters for the dialog.
selectedfilter – Default filter to be selected.
options – Additional options for the dialog.
- Returns:
A tuple containing a list of selected filenames and the selected filter.
Module providing a file viewer widget
Connection dialog#
This module provides a dialog box showing the progress of a connection to a
DataLab-derived application server, to be used together with
sigima.client.SimpleRemoteProxy (or any remote proxy exposing a
similarly blocking connect method).
- class sigimax.widgets.connection.ConnectionDialog(connect_callback: Callable, parent: QWidget = None, icon: QIcon | None = None, banner: QPixmap | None = None)[source]#
Connection dialog, showing the progress of a connection attempt.
The connect callback runs in a background thread. When the dialog is closed before the callback returns (e.g. cancelled while connecting), the dialog no longer waits for it: the callback keeps running in the background until it returns, and its result is ignored.
- Parameters:
connect_callback – Callback function to connect to the remote server
parent – Parent widget. Defaults to None.
icon – Window icon. Defaults to None (no icon override).
banner – Optional banner pixmap displayed above the progress bar.
Object dialog#
This module provides a dialog box to select an object (signal or image) from
a remote DataLab-derived application, using
sigima.client.SimpleRemoteProxy (or any proxy exposing the same
get_group_titles_with_object_info/get_current_panel/
set_current_panel methods).
- class sigimax.widgets.objectdialog.GetObjectDialog(parent: QW.QWidget, proxy: SimpleRemoteProxy, panel: str | None = None, title: str | None = None)[source]#
Get object dialog box
- Parameters:
parent – Parent widget
proxy – Remote proxy
panel – Panel to retrieve objects from (‘signal’, ‘image’ or None for both)
title – Dialog title