GUI

GUI entry for XRayLabTool.

This package provides a lightweight Qt-based desktop interface for running single-material and multi-material X-ray optical property calculations and plotting results using PyQtGraph.

Main Window

class xraylabtool.gui.main_window.Toast(parent)[source]

Bases: QLabel

Lightweight, non-blocking toast overlay.

Parameters:

parent (QWidget)

__init__(parent)[source]
Parameters:

parent (QWidget)

Return type:

None

show_toast(message, kind='info', duration_ms=None)[source]
Return type:

None

Parameters:
  • message (str)

  • kind (str)

  • duration_ms (int | None)

staticMetaObject = PySide6.QtCore.QMetaObject("Toast" inherits "QLabel": )
class xraylabtool.gui.main_window.MainWindow(theme_manager=None)[source]

Bases: QMainWindow

Parameters:

theme_manager (Any | None)

__init__(theme_manager=None)[source]
Parameters:

theme_manager (Any | None)

Return type:

None

threadpool: QThreadPool | None
resizeEvent(event)[source]
Return type:

None

Parameters:

event (Any)

staticMetaObject = PySide6.QtCore.QMetaObject("MainWindow" inherits "QMainWindow": )

Services

Helper utilities for the GUI layer.

class xraylabtool.gui.services.EnergyConfig(start_kev=8.0, end_kev=12.0, points=50, logspace=False)[source]

Bases: object

Parameters:
start_kev: float = 8.0
end_kev: float = 12.0
points: int = 50
logspace: bool = False
to_array()[source]
Return type:

ndarray

__init__(start_kev=8.0, end_kev=12.0, points=50, logspace=False)
Parameters:
Return type:

None

xraylabtool.gui.services.compute_single(formula, density, energy_cfg)[source]
Parameters:
xraylabtool.gui.services.compute_multiple(formulas, densities, energy_cfg, progress_cb=None)[source]
Parameters:
xraylabtool.gui.services.linear_absorption_cm(inv_length_cm)[source]
Return type:

float | None

Parameters:

inv_length_cm (float | None)

Theme Manager

class xraylabtool.gui.theme_manager.ThemeManager(app)[source]

Bases: QObject

Manages application theme state and persistence.

Parameters:

app (QApplication)

theme_changed
__init__(app)[source]
Parameters:

app (QApplication)

Return type:

None

property current_palette: ColorPalette

Get the active ColorPalette object.

set_theme(mode)[source]

Set the active theme mode.

Return type:

None

Parameters:

mode (str)

get_theme()[source]

Get current theme mode string.

Return type:

str

toggle_theme()[source]

Toggle between light and dark modes.

Return type:

None

apply(app_instance)[source]

Apply current theme to application and global resources.

Return type:

None

Parameters:

app_instance (QApplication)

staticMetaObject = PySide6.QtCore.QMetaObject("ThemeManager" inherits "QObject": Methods:   #4 type=Signal, signature=theme_changed(QString), parameters=QString )

Workers

Threaded workers for GUI calculations.

class xraylabtool.gui.workers.WorkerSignals[source]

Bases: QObject

finished
error
progress
staticMetaObject = PySide6.QtCore.QMetaObject("WorkerSignals" inherits "QObject": Methods:   #4 type=Signal, signature=finished(PyObject), parameters=PyObject   #5 type=Signal, signature=error(QString), parameters=QString   #6 type=Signal, signature=progress(int), parameters=int )
class xraylabtool.gui.workers.CalculationWorker(fn, *args, **kwargs)[source]

Bases: QRunnable

Parameters:
  • fn (Callable[..., Any])

  • args (Any)

  • kwargs (Any)

__init__(fn, *args, **kwargs)[source]
Parameters:
Return type:

None

run()[source]
Return type:

None

Protocols

class xraylabtool.gui.protocols.ThemeProtocol(*args, **kwargs)[source]

Bases: Protocol

Interface for the Theme Manager.

set_theme(mode)[source]

Switch the application theme.

Return type:

None

Parameters:

mode (Literal['light', 'dark'])

get_theme()[source]

Get the current active theme.

Return type:

Literal['light', 'dark']

toggle_theme()[source]

Toggle between light and dark modes.

Return type:

None

apply(app_instance)[source]

Apply the current theme stylesheet to the QApplication.

Return type:

None

Parameters:

app_instance (Any)

__init__(*args, **kwargs)
class xraylabtool.gui.protocols.PlotThemeProtocol(*args, **kwargs)[source]

Bases: Protocol

Interface for Plot Theme Integration.

apply_to_figure(figure, mode)[source]

Update a plot figure to match the theme.

Return type:

None

Parameters:
__init__(*args, **kwargs)

Logging Filters

xraylabtool.gui.logging_filters.suppress_qt_noise()[source]

Filter noisy Qt offscreen stderr lines (e.g., propagateSizeHints).

Keeps other stderr intact so real warnings still surface.

Return type:

Generator[None, None, None]

xraylabtool.gui.logging_filters.enable_offscreen_quiet_env()[source]

Set env vars that quiet common Qt offscreen noise without muting real warnings.

Prefers the quieter “minimal” platform when available, otherwise falls back to “offscreen”. Does not override an explicit user choice.

Return type:

None

xraylabtool.gui.logging_filters.suggest_quiet_platforms()[source]

Return optional platform plugins that can be quieter offscreen (opt-in).

Return type:

list[str]

Widgets

Custom widgets for the XRayLabTool GUI.

xraylabtool.gui.widgets.current_palette()[source]

Detect the active palette by checking the application background color.

Return type:

ColorPalette

xraylabtool.gui.widgets.apply_palette_to_widget(pw, palette)[source]

Apply background and foreground colors from palette to a PlotWidget.

Return type:

None

Parameters:
  • pw (Any)

  • palette (ColorPalette)

xraylabtool.gui.widgets.apply_palette_to_item(pi, palette)[source]

Apply background/foreground colors from palette to a PlotItem.

Return type:

None

Parameters:
  • pi (Any)

  • palette (ColorPalette)