mdt.gui package

Subpackages

Submodules

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]
write(string)[source]
class mdt.gui.utils.MainTab[source]

Bases: object

tab_opened()[source]

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.

is_running

set to False to stop the receiver.

Type:boolean
finished = <MockNamedComponent name='mock()' id='140163130132800'>
run()[source]
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 (_).

mdt.gui.utils.blocked_signals(*widgets)[source]

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

Parameters:widgets (QWidget) – one or more widgets
mdt.gui.utils.center_window(window)[source]

Center the given window on the screen.

Parameters:
  • q_app (QApplication) – for desktop information
  • window (QMainWindow) – the window to center
mdt.gui.utils.enable_pyqt_exception_hook()[source]

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.

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

decorator function

mdt.gui.utils.get_script_file_header_text(info_fields=None)[source]

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
mdt.gui.utils.print_welcome_message()[source]

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

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

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

Return type:

str

Module contents