Python port of the Task Manager clone: TPageControl with two tabs (tab clicks need app-level hit handling, fixed tab-width 140). Processes tab is a live XProcessList from /proc (sortable PID / Program / User / Mem / CPU% columns, header clicks toggle the direction). Performance tab is XHistoryGraph (60 s CPU + memory), XCoreGrid (per-core), XUsageBar (Memory, Disk /, Swap), XStackBar (memory breakdown) and XNetGraph (live /proc/net/dev rates). Data sampled every 500 ms (GLib timeout); window repaints every 2 s (a full redraw is ~38 rows x 5 text calls plus the graphs, and repainting every tick burned ~40% of a core); the process list refreshes every 2 s. Python monitor widgets draw dark btop-style panels, so the window background is dark. Also fixes two XProcessList issues the app exposed: the columns were fixed offsets drawn for the 360px demo widget (a wide widget was mostly empty) -> width-relative fractions, same as the C++ widget, plus a v/^ sort marker in the header; and _read_processes opened /proc/<pid>/status for every process on every scan (671 ms CPU for 400 processes) -> RSS now comes from stat field 24 and the uid lookup is cached per (pid, starttime), so a warm scan is ~75 ms (9x faster).
Task Manager — monitor app (Python)
A Windows-style Task Manager clone in one 1024x768 window, tabbed
with TPageControl. Built with the LightGUI XFrame widgets (Python
port) and live /proc data — no seeded demo data survives the
first tick.
What it shows
- Processes tab —
XProcessListwith live processes from/proc(PID / Program / User / Mem / CPU%). Click a column header to sort (clicking the current column toggles the direction); rows refresh every 2 s. CPU% is per-core (100% = one core), computed from wall-time deltas between scans. - Performance tab —
XHistoryGraph(60 s CPU + memory),XCoreGrid(per-core busy %),XUsageBar(Memory, Disk /, Swap),XStackBar(memory breakdown: Used / Cached / Buffers / Free) andXNetGraph(live down/up rates from/proc/net/devwith accumulated totals).
Run
PYTHONPATH=/root/monitor-wt/task-manager/lightgui_python \
python3 examples/monitor_task_manager/main.py
Data is sampled every 500 ms (GLib timeout); the window repaints
every 2 s (a full redraw is ~38 process rows x 5 text calls plus the
graphs, and repainting every tick burned ~40% of a core). Close the
window to quit. The Python monitor widgets draw dark btop-style
panels, so the window background is dark (#1a1a1e).
Notes
- The
TPageControldraws its tabs itself but tab clicks need app-level hit handling (fixedtab-width140, so the hit math is deterministic); theXProcessListsort also needs app-level header hit handling, using the same column fractions as the widget's draw. - The
XProcessListcolumns are width-relative (same fractions as the C++ widget) — the widget fix lives inlightgui/xframe/monitor.pyon this branch: the old fixed offsets were drawn for the 360px demo widget and left a wide widget mostly empty; the header also now shows the sort column with av/^marker. refresh_processes()needs two samples before CPU% is real, so the app primes it twice at startup; the graphs are primed with 60 live samples (the net graph is primed withpush(), notpush_net(), so priming does not inflate the totals).