From 5684b460019bc59b47f8c30ceb7cccf368592a57 Mon Sep 17 00:00:00 2001 From: Florian Streibelt Date: Sat, 15 Oct 2011 04:15:50 +0200 Subject: [PATCH] Moar functions for the display --- client-barcode/freitagskasse.py | 34 ++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/client-barcode/freitagskasse.py b/client-barcode/freitagskasse.py index 31089e3..3c97246 100644 --- a/client-barcode/freitagskasse.py +++ b/client-barcode/freitagskasse.py @@ -55,6 +55,9 @@ def display_handle_scroll(line,text,offset): def display_scroll_text(line,text): global scroll_line1,scroll_line2 + global offset_line1,offset_line2 + offset_line1=0 + offset_line2=0 lock.acquire() if (line==1): #clear the line on invocation: send_display("\x1f\x24\x01%c\x18" % chr(line) ) @@ -65,7 +68,12 @@ def display_scroll_text(line,text): lock.release() def display_screen(title,message): + global scroll_line1,scroll_line2 + global offset_line1,offset_line2 + offset_line1=0 + offset_line2=0 if (len(title)<21): + scroll_line1=None send_display("\x1f\x24\x01%c\x18%s" % (chr(1),'\xdb'*20) ) if (len(title)<20): pos=1+(20-len(title))/2 @@ -74,12 +82,18 @@ def display_screen(title,message): send_display("\x1f\x24%c%c%s" % (chr(pos),chr(1),title) ) else: display_scroll_text(1,title) - display_scroll_text(2,message) + + if (len(message)<21): + scroll_line2=None + send_display("\x1f\x24%c%c\x18%s" % (chr(1),chr(2),message) ) + else: + display_scroll_text(2,message) def display_thread(x): global scroll_line1,scroll_line2 + global offset_line1,offset_line2 offset_line1=0 offset_line2=0 while(True): @@ -113,10 +127,14 @@ def send_display(s): return def print_display(s): + global scroll_line1,scroll_line2 + global offset_line1,offset_line2 lock.acquire() -# scroll_line1=None -# scroll_line2=None -# send_display(s) + offset_line1=0 + offset_line2=0 + scroll_line1=None + scroll_line2=None + send_display(s) lock.release() def clear(): @@ -258,7 +276,7 @@ class Status: print(COLOR_SOME + 'Committen nicht vergessen.' + COLOR_RESET) else: print('Kontostand beträgt: %s%.2f Euro%s' % (COLOR_MUCH, self.balance, COLOR_RESET)) - print_display('Kontostand: %8.2f' % self.balance) + display_screen("KONTOSTAND","%s: %.2f Euro" % (self.login_name,self.balance)) if self.balance < 0: print() warn_balance() @@ -266,7 +284,7 @@ class Status: print(COLOR_MUCH + 'Bitte einloggen.' + COLOR_RESET) print() print('Scanne dazu deine ID-Karte mit dem Barcode-Leser.') - print_display("\x0cAnmeldung: Bitte ID-Karte scannen\x0b") + display_screen("LOGIN","Bitte scanne Deinen login-Token! *** ") print() def logged_in(self): @@ -422,6 +440,7 @@ def print_prompt(): def handle(line, status): if line == 'exit': clear() + print_display("\x1b\x40exit...") sys.exit(0) if status.logged_in(): @@ -447,7 +466,8 @@ def handle(line, status): status.login(line) except urllib2.HTTPError as e: if e.code == 404: # URL not found == user unknown - print_display('\x0cFEHLER: Nutzer ist unbekannt: "%7s"' % line[:7]) + display_screen("FEHLER","Nutzer ist unbekannt: '%s' *** " % line) + error_page('FEHLER: Benutzer "%s" nicht bekannt' % line, hint_message='Ist in der WebApp unter "Einstellungen" ' \ 'für Ihren Account Plugin "BarcodePlugin" ' \