Browse Source

client-barcode: Handle long labels better

Sebastian Pipping 9 years ago
parent
commit
dd27a1e5ab
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      client-barcode/freitagskasse.py

+ 7
- 1
client-barcode/freitagskasse.py View File

@@ -108,9 +108,15 @@ class Status:
108 108
 					% ('', '', color(balance), sign(balance, plus),
109 109
 						abs(balance), COLOR_RESET))
110 110
 
111
+		def shorten(text, length):
112
+			if len(text) <= length:
113
+				return text
114
+			else:
115
+				return text[:length - 3] + '...'
116
+
111 117
 		def show_item(position, diff, label, color):
112 118
 			print('%2d) %-40s  %s%c %6.2f Euro%s' \
113
-					% (position, label, color, sign(diff),
119
+					% (position, shorten(label, 40), color, sign(diff),
114 120
 					abs(diff), COLOR_RESET))
115 121
 
116 122
 		def show_bar():

Loading…
Cancel
Save