Skip to content

log_widget

_log_widget

Output log widget with ANSI color support.

Classes:

Name Description
FXOutputLogHandler

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

FXOutputLogWidget

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

Classes

FXOutputLogHandler

FXOutputLogHandler(log_widget: FXOutputLogWidget)

Bases: Handler


              flowchart TD
              fxgui.fxwidgets._log_widget.FXOutputLogHandler[FXOutputLogHandler]

              

              click fxgui.fxwidgets._log_widget.FXOutputLogHandler href "" "fxgui.fxwidgets._log_widget.FXOutputLogHandler"
            

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.

Methods:
emit
emit(record: LogRecord) -> None

Emit a log record to the output log widget.

FXOutputLogWidget

FXOutputLogWidget(
    parent: Optional[QWidget] = None,
    capture_output: bool = False,
    max_blocks: int = 0,
)

Bases: QWidget


              flowchart TD
              fxgui.fxwidgets._log_widget.FXOutputLogWidget[FXOutputLogWidget]

              

              click fxgui.fxwidgets._log_widget.FXOutputLogWidget href "" "fxgui.fxwidgets._log_widget.FXOutputLogWidget"
            

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
max_blocks
int

How many lines the pane keeps before Qt prunes the oldest, as a terminal's scrollback does. Defaults to 0, which is no limit and is what this has always done.

Left unbounded by default deliberately: dropping the OLDEST records silently is the same class of defect as dropping the newest, and only a consumer knows whether something behind the pane -- a session log file -- makes that safe. A pane that is the only record of a session should stay unbounded; one that is a view onto a file it does not own is exactly what this is for. A long-running application that never sets it grows a document without limit.

0
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()

Initialize the output log widget.

Methods:

Name Description
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.

Methods:
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.

Functions: