Skip to content

Log Widget

Widgets for displaying and handling log output.

Preview

FXLogWidget

Classes

FXOutputLogWidget

Bases: QWidget

A reusable read-only output log widget for displaying application logs.

This widget provides a text display area that captures and shows logging output from the application. It supports ANSI color codes, search functionality, and log throttling for performance.

Parameters:

Name Type Description Default

parent

Optional[QWidget]

Parent widget.

None

capture_output

bool

If True, adds a logging handler to capture log output from Python's logging module.

False
Signals

log_message: Emitted when a log message is received (for thread-safe delivery).

Examples:

>>> from fxgui import fxwidgets
>>> log_widget = fxwidgets.FXOutputLogWidget(capture_output=True)
>>> log_widget.show()

Methods:

Name Description
__init__

Initialize the output log widget.

append_log

Append text to the log output with ANSI color conversion.

clear_log

Clear the log output.

closeEvent

Handle widget close event to restore output streams.

keyPressEvent

Handle keyboard shortcuts.

restore_output_streams

Remove logging handler from all loggers where it was added.

__init__

__init__(parent: Optional[QWidget] = None, capture_output: bool = False)

Initialize the output log widget.

append_log

append_log(text: str) -> None

Append text to the log output with ANSI color conversion.

Parameters:

Name Type Description Default

text

str

Text to append (may contain ANSI color codes).

required

clear_log

clear_log() -> None

Clear the log output.

closeEvent

closeEvent(event: QCloseEvent) -> None

Handle widget close event to restore output streams.

keyPressEvent

keyPressEvent(event: QKeyEvent) -> None

Handle keyboard shortcuts.

restore_output_streams

restore_output_streams() -> None

Remove logging handler from all loggers where it was added.

FXOutputLogHandler

Bases: Handler

Custom logging handler that sends log messages to an output log widget.

This handler is used internally by FXOutputLogWidget to capture log messages and display them in the widget.

Parameters:

Name Type Description Default

log_widget

FXOutputLogWidget

The FXOutputLogWidget to send messages to.

required

Methods:

Name Description
emit

Emit a log record to the output log widget.

emit

emit(record: LogRecord) -> None

Emit a log record to the output log widget.