urclib.ui_qt.prog_log_dlg

Dialog and support functions for monitoring the progress of URC analysis

Module Contents

Classes

ProgHandler

Object for managing inter-thread communication.

ProgLogDlg

Dialog for displaying progress of URC calculations.

Functions

redirect_print(prog_handler)

Context for redirecting print statements to dialog display and progress bar.

urclib.ui_qt.prog_log_dlg.redirect_print(prog_handler)

Context for redirecting print statements to dialog display and progress bar.

Parameters:

prog_handler (ProgHandler) – The object capable of displaying messages.

Yields:

None – Required for context manager to function.

class urclib.ui_qt.prog_log_dlg.ProgHandler(workfn, fn_args, fn_kwargs, dlg)

Bases: PyQt5.QtCore.QObject

Object for managing inter-thread communication.

Parameters:
  • workfn (function) – Method or function to be executed in a separate thread.

  • fn_args (tuple) – Positional arguments for workFn.

  • fn_kwargs (dict) – Keyword arguments for workFn.

  • dlg (PyQt5.QtWidgets.QDialog) – The parent dialog.

cancelled

Flag indicating whether the process should be treated as user cancelled.

Type:

bool

logMsg
progress
errMsg
wire_up(update_fn, err_fn, progbar_fn, thread)

Wire up slots and signals.

Parameters:
  • update_fn (function) – Function/slot to bind to logMsg signal.

  • err_fn (function) – Function/slot to bind to errMsg signal.

  • progbar_fn (function) – Function/slot to bind to progbar_fn signal.

  • thread (PyQt5.QtCore.QSignal) – Thread to bind to run method.

_check_interrupt()

Check to see if a user has requested cancellation. :raises SimThread._CancelException: If the simulation was cancelled by a user.

post_log_msg(msg)

Emit logMsg signal and check for thread interrupt.

Parameters:

msg (str) – Payload for logMsg signal.

post_progress(val)

Emit progress signal and check for interrupt.

Parameters:

val (int) – Payload for progress signal; should be in range [0,100].

run()

Thread execution logic.

mark_for_exit()

Indicate that the thread is ready to exit at the next interrupt point.

class urclib.ui_qt.prog_log_dlg.ProgLogDlg(fn, finish_fn, prog_count=0, fn_args=None, fn_kwargs=None, parent=None, title='Progress', use_progressbar=False)

Bases: PyQt5.QtWidgets.QDialog

Dialog for displaying progress of URC calculations.

Parameters:
  • fn (function) – Method or function to be executed and monitored.

  • finish_fn (function) – Method or function to call on successful completion.

  • prog_count (int,optional) – The total number of progress steps expected to be reported. Default is 0.

  • fn_args (tuple,optional) – Any positional arguments required by fn, or None if no positional arguments are required. Default is None.

  • fn_kwargs (dict,optional) – Any keyword arguments required by fn, or None if no keyword arguments are required. Default is None.

  • parent (PyQt5.QtWidgets.QWidget,optional) – Optional Qt parent widget, or None. Default is None.

  • title (str,optional) – The title to display at the top of the dialog. Defaultl is “Progress”.

  • use_progressbar (bool,optional) – If True the progress bar is displayed; otherwise, it is hidden. Defaults to False.

_on_cancel()

Cleanup method which is invoked when the user cancels the process.

_flush_msgs()

Flush any messages awaiting writing to the text display

_update_log(msg)

Write message to a buffer which will be flushed regularly to a display widget.

Parameters:

msg (str) – The message to submit to the log.

_update_progressbar(prog)

Refresh the progress bar.

Parameters:

prog (int) – The current progress to display.

_err_msg(ex)

Receive a forwarded exception.

Parameters:

ex (Exception) – The forwarded exception.

Raises:

ex – The forwarded exception (presumably from another thread).

_run_finish()

Cleanup details at the conclusion of a process run.

closeEvent(event)

This is an overload of a method in the QDialog class. See the official Qt documentation.

Parameters:

event (PyQt5.QtGui.QCloseEvent) – The triggering event.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qdialog.html#closeEvent)

log_text()

Retrieve the text log.

Returns:

The log recorded during the run.

Return type:

str