diff --git a/lightgui/xframe/monitor.py b/lightgui/xframe/monitor.py index 39c9eeb..781414f 100644 --- a/lightgui/xframe/monitor.py +++ b/lightgui/xframe/monitor.py @@ -1335,8 +1335,16 @@ class MonitorWidget(Widget): cr.restore() if major: label = "%.0f" % (lo + f * (hi - lo)) - lx = cx + (r - 26) * math.cos(ang) - ly = cy + (r - 26) * math.sin(ang) \ + # Numeral centre radius: the glyph box's farthest + # corner in the radial direction must stay inside the + # tick ring (inner end r-16) with 4 px clearance, so a + # wide 4-digit label never crosses the dial rim. + lw = _text_width(cr, self, label, size=numeral_px, bold=True) + extent = (lw / 2) * abs(math.cos(ang)) \ + + (numeral_px / 2) * abs(math.sin(ang)) + lr = max(8.0, r - 16 - extent - 4) + lx = cx + lr * math.cos(ang) + ly = cy + lr * math.sin(ang) \ + numeral_px * 0.35 rgb = _RED if f >= red_frac else _TEXT _wtext(cr, self, label, lx, ly, size=numeral_px,