GUI Widget Helpers

Provides a collection of custom QWidget subclasses that provide specific functionalities.

class prism._gui.widgets.helpers.ExceptionDialog(parent, etype, value, tb)[source]

Defines the ExceptionDialog class for the Projection GUI.

This class takes a set of exception details and converts it into a format that can be shown using a dialog.

__init__(parent, etype, value, tb)[source]

Initialize an instance of the ExceptionDialog class.

Parameters:
  • parent (QWidget object or None) – The parent widget for this dialog or None for no parent.
  • etype (Exception class) – The Exception class that is associated with this error.
  • value (Exception object) – The Exception instance that is associated with this error.
  • tb (traceback object) – The corresponding traceback object.
create_traceback_box()[source]

Creates a special box for the exception dialog that contains the traceback information and returns it.

format_exception()[source]

Formats the exception provided during initialization and returns it.

format_traceback()[source]

Formats the traceback provided during initialization and returns it.

init()[source]

Sets up the exception dialog after it has been initialized.

This function is mainly responsible for gathering all required information; formatting it; and drawing the dialog.

toggle_traceback_box()[source]

Toggles the visibility of the traceback box and updates the dimensions of the exception dialog accordingly.

This function acts as a Qt slot.

update_size()[source]

Updates the dimensions of the exception dialog depending on its current state (traceback box visibility).

class prism._gui.widgets.helpers.OverviewListWidget(*args, **kwargs)[source]

Defines the OverviewListWidget class.

This class defines the overview lists that are used by the OverviewDockWidget class.

__init__(*args, **kwargs)[source]

Initialize an instance of the OverviewListWidget class.

Parameters:
  • args (positional arguments) – The positional arguments that need to be passed to init().
  • kwargs (keyword arguments) – The keyword arguments that need to be passed to init().
init(*, hcubes_list, status_tip, context_menu, activated)[source]

Sets up the overview list after it has been initialized.

This function is mainly responsible for creating the list; adding the items to it; and setting some properties.

Parameters:
  • hcubes_list (list of str) – List of projection hypercube names that must be used to initialize this overview list with.
  • statustip (str) – The statustip that will be displayed in the statusbar whenever this overview list is hovered.
  • context_menu (function) – The function that must be called whenever the context menu is requested.
  • activated (function) – The function that must be called whenever an item in this overview list is activated. This corresponds to the default action.
class prism._gui.widgets.helpers.ThreadedProgressDialog(main_window_obj, *args, **kwargs)[source]

Defines the ThreadedProgressDialog class for the Projection GUI.

This class provides a QProgressDialog class that automatically executes a provided operation on a separate thread, allowing for the user to interrupt it.

__init__(main_window_obj, *args, **kwargs)[source]

Initialize an instance of the ThreadedProgressDialog class.

Parameters:
  • main_window_obj (MainViewerWindow object) – Instance of the MainViewerWindow class that acts as the parent of progress dialog.
  • args (positional arguments) – The positional arguments that need to be passed to init().
  • kwargs (keyword arguments) – The keyword arguments that need to be passed to init().
init(label, func, *iterables)[source]

Sets up the progress dialog after it has been initialized.

This function is mainly responsible for preparing the dialog to be opened and the func function to be executed.

Parameters:
  • label (str) – The label that is used as the description of what operation is currently being executed.
  • func (function) – The function that must be called iteratively using the arguments provided in iterables.
  • iterables (positional arguments) – All iterables that must be used to call func with.
kill_threads()[source]

Terminates all currently running threads besides the main thread (on all MPI ranks) and returns control to the main thread.

This function is the sole way to abort the operation.

This function acts as a Qt slot.

open()[source]

Opens the progress dialog and starts the execution of the requested operation.

Returns:result (bool) – Whether or not the operations ended successfully, which can be used by other functions to determine if it should continue.
raise_exception(exception)[source]

Qt slot that raises a provided exception.

set_successful_finish()[source]

Qt slot that marks the operation as ‘successful’.

prism._gui.widgets.helpers.show_exception_details(parent, *args, **kwargs)[source]

Creates an instance of the ExceptionDialog class and shows it.

Parameters:

parent (QWidget object or None) – The parent widget for this dialog or None for no parent.

Other Parameters:
 
  • args (positional arguments) – The positional arguments that must be passed to the constructor of the ExceptionDialog class.
  • kwargs (keyword arguments) – The keyword arguments that must be passed to the constructor of the ExceptionDialog class.