spacr.qt.widgets.usage_bar¶
UsageBar — labeled slim progress bar for RAM/GPU/CPU indicators.
Classes¶
Labeled thin progress bar with a right-aligned percent readout. |
Module Contents¶
- class spacr.qt.widgets.usage_bar.UsageBar(label: str, parent=None)[source]¶
Bases:
PySide6.QtWidgets.QWidgetLabeled thin progress bar with a right-aligned percent readout.
BOTH TEXT COLUMNS ARE FIXED-WIDTH ON PURPOSE, and that is what made them a bug at a large font scale. The caption column is wider than “RAM” needs so the four bars of the System card line up; the readout column is fixed so the bar does not jitter sideways as 9 % becomes 10 %. Neither reason survives being written as a constant: see
_size_the_columns().- Parameters:
label – text shown to the left of the bar (e.g. “RAM”, “GPU”).
parent – parent widget; ownership only.
Build one labelled resource meter.
The row itself must paint nothing: the application sheet’s blanket background rule would otherwise put an opaque rectangle behind the bar, whatever is behind the page. The theme sheet’s
UsageBarRowrule says so for every row at once, so a row carries no sheet of its own.- Parameters:
label – what is being measured.
parent – parent widget, or
None.
- changeEvent(event) None[source]¶
Re-measure when the font under this row changes.
The stylesheet is what carries the font scale, and it is installed on the application AFTER these widgets are built – a preferences save re-installs it on a live window. Both arrive as a font change on the widgets whose resolved font moved, so the columns are re-measured there rather than being right only for the sheet that happened to be current at construction.
- Parameters:
event – the change event, passed to the base class; a font, application-font or style change re-measures the columns.
- set_value(pct: float) None[source]¶
Set the bar value, clamped to 0-100, and re-color at 75/90 %.
- Parameters:
pct – value in
0.0-100.0; out-of-range values clamp.
- showEvent(event) None[source]¶
Re-measure on the way to being seen.
A widget’s QSS font is resolved when it is polished, which for a screen built into a stacked page happens on the way to the first show. Measuring here as well as on the font change is what keeps a row that was never sent a font change – because its own font was inherited whole – from being sized by the default metrics.
- Parameters:
event – the show event, passed to the base class after the columns are re-measured.