GUI for finger v1

This commit is contained in:
ykcheungab
2026-06-18 22:18:19 +08:00
parent f19f092b64
commit 3fd9b839a9
42 changed files with 2326 additions and 1186 deletions
+51
View File
@@ -0,0 +1,51 @@
"""Logging helpers for the finger dashboard."""
from __future__ import annotations
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QPlainTextEdit
class TeeStream:
"""Write to multiple text streams."""
def __init__(self, *streams):
self.streams = streams
def write(self, text):
for stream in self.streams:
stream.write(text)
def flush(self):
for stream in self.streams:
stream.flush()
class WidgetLogHandler:
"""Mirror print output into a QPlainTextEdit."""
def __init__(self, widget: QPlainTextEdit):
self.widget = widget
self.buf = ""
def write(self, text: str):
self.buf += text
while "\n" in self.buf:
line, self.buf = self.buf.split("\n", 1)
if line:
self.widget.appendPlainText(line)
def flush(self):
if self.buf:
self.widget.appendPlainText(self.buf)
self.buf = ""
def make_log_widget() -> QPlainTextEdit:
widget = QPlainTextEdit()
widget.setReadOnly(True)
widget.setMaximumBlockCount(2000)
font = QFont("Consolas", 12)
font.setStyleHint(QFont.Monospace)
widget.setFont(font)
return widget