From b8afcee3aee7c74702cf8d2d288032afbf85c6ee Mon Sep 17 00:00:00 2001 From: mfrasca <> Date: Mon, 16 Oct 2006 07:29:49 +0000 Subject: [PATCH] behaviour with different character font sizes... --- examples/pywmhdmon.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/pywmhdmon.py b/examples/pywmhdmon.py index 125ba4d..abb5641 100755 --- a/examples/pywmhdmon.py +++ b/examples/pywmhdmon.py @@ -149,7 +149,12 @@ class PywmHDMon: x + paintWidth + xOffset, y + yOffset) def getY(self, line): - return 2 + (line - 1) * (char_height + 1) + "returns the y coordinate of the top line for the box" + lineCount = (height - yOffset*2) / (char_height+2) + interlinea = (height - yOffset*2) / lineCount + lastBaseline = yOffset + lineCount * interlinea + extraYOffset = (height - yOffset - lastBaseline) / 2 + return extraYOffset + (line - 1) * interlinea def paintLabel(self, line, label): self.addString(label, 1, self.getY(line)) @@ -432,7 +437,10 @@ def main(): sys.stderr.write( 'Unknown display mode: %s, using default.\n' % displayMode) displayMode = defaultMode - pathsToMonitor.append((label[:3], path, displayMode, action)) + takeChars = 3 + if char_width <= 5: + takeChars = 4 + pathsToMonitor.append((label[:takeChars], path, displayMode, action)) procStat = config.get('procstat', defaultProcStat) skipping = int(config.get('skipconf', 0)) actMonEnabled = int(config.get('monitoring',0))