mdt.gui package



mdt.gui.utils module

class mdt.gui.utils.ForwardingListener(queue)[source]

Bases: mdt.lib.log_handlers.LogListenerInterface

Forwards all incoming messages to the given _logging_update_queue.

Instances of this class can be used as a log listener to the MDT LogDispatchHandler and as a sys.stdout replacement.

Parameters:queue (Queue) – the _logging_update_queue to forward the messages to
emit(record, formatted_message)[source]
class mdt.gui.utils.MainTab[source]

Bases: object


Called when this tab is selected by the user.

class mdt.gui.utils.MessageReceiver(queue, *args, **kwargs)[source]

Bases: MockClass

A QObject (to be run in a QThread) which sits waiting for data to come through a Queue.Queue().

It blocks until data is available, and one it has got something from the _logging_update_queue, it sends it to the “MainThread” by emitting a Qt Signal.


set to False to stop the receiver.

finished = <MockNamedComponent name='mock()' id='140163130132800'>
text_message_signal = <MockNamedComponent name='mock()' id='140163130132800'>
class mdt.gui.utils.QtManager[source]

Bases: object

static add_window(window)[source]
static empty_windows_list()[source]
static exec_()[source]
static get_qt_application_instance()[source]
windows = []
class mdt.gui.utils.UpdateDescriptor(attribute_name)[source]

Bases: object

Descriptor that will emit a state_updated_signal at each update.

This accesses from the instance the attribute name prepended with an underscore (_).


Small context in which the signals of the given widget are blocked.

Parameters:widgets (QWidget) – one or more widgets

Center the given window on the screen.

  • q_app (QApplication) – for desktop information
  • window (QMainWindow) – the window to center

Enable the PyQt exception handling hook for PyQt versions larger than 5.5.

If this is not enabled, exceptions will be handled silently and will not be printed to the user. This makes it harder to solve the issue.

mdt.gui.utils.function_message_decorator(header, footer)[source]

This creates and returns a decorator that prints a header and footer before executing the function.

  • header (str) – the header text, we will add extra decoration to it
  • footer (str) – the footer text, we will add extra decoration to it

decorator function


Get the header file text to use when outputting script files matching GUI actions.

Parameters:info_fields (dict) – fields holding information. Common fields are ‘Purpose’ and ‘Example usage’. These fields are appended to the header text.
Returns:the header (comment) text for the automatically generated script.
Return type:str

Prints a small welcome message for after the GUI has loaded.

This prints to stdout. We expect the GUI to catch the stdout events and redirect them to the GUI.

mdt.gui.utils.split_long_path_elements(original_path, max_single_element_length=25)[source]

Split long path elements into smaller ones using spaces

  • original_path (str) – the path you want to split
  • max_single_element_length (int) – the maximum length allowed per path component (folders and filename).

the same path but with spaces in long path elements. The result will no longer be a valid path.

Return type:


Module contents