From c0cce5d2521855691c9c4bdf22ce2bdbe0c77db2 Mon Sep 17 00:00:00 2001 From: oepen Date: Mon, 2 Aug 2010 20:50:08 +0000 Subject: [PATCH] Only enable the Okay button if enough digits were entered git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@240 96b47cad-a561-4643-ad3b-153ac7d7599c --- eID_gui/src/eid/windows.py | 32 ++++++++++++++++++++------------ eID_gui/src/pinpad.glade | 1 + 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/eID_gui/src/eid/windows.py b/eID_gui/src/eid/windows.py index 73152e2..56d30de 100644 --- a/eID_gui/src/eid/windows.py +++ b/eID_gui/src/eid/windows.py @@ -419,6 +419,19 @@ class PinpadGTK: self.cardChecker.join() gtk.main_quit() + def btnDel_clicked(self, widget): + """Remove one digit from the pin and replace the last * in the output + field with an underscore""" + #Disable the "Okay" button + btn_okay = self.builder.get_object("btnOk") + btn_okay.set_sensitive(False) + #Delete the last digit + self.pin = self.pin[:-1] + num_digits = len(self.pin) + #Update display + output = num_digits * '*' + (self.secret_len - num_digits) * "_" + self.output.set_text(output) + def digit_clicked(self, widget): """We indicate the ammount of digits with underscores For every digit that is enterd we replace one underscore with a star @@ -431,10 +444,14 @@ class PinpadGTK: idx = txt.find('_') output = txt[:idx] + digit + txt[idx+1:] self.output.set_text(output) - gobject.timeout_add(750, self.hide_digits, idx) + gobject.timeout_add(750, self.__hide_digit, idx) self.pin += digit + #If we have enough digits we enable the "Okay" button + if len(self.pin) == self.secret_len: + btn_okay = self.builder.get_object("btnOk") + btn_okay.set_sensitive(True) - def hide_digits(self, idx): + def __hide_digit(self, idx): """Change character number idx of self.output text to a '*' """ output = "" txt = self.output.get_text() @@ -519,19 +536,10 @@ class PinpadGTK: #XXX: Actually we should return to the application that started #the PIN entry self.shutdown(None) - else: + else: popup = MsgBox(self.window, "PIN wurde falsch eingegeben", "error", gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) popup.run() popup.destroy() self.output.set_text(self.secret_len * "_") self.pin = "" - - def btnDel_clicked(self, widget): - """Remove one digit from the pin and replace the last * in the output - field with an underscore""" - self.pin = self.pin[:-1] - num_digits = len(self.pin) - output = num_digits * '*' + (self.secret_len - num_digits) * "_" - self.output.set_text(output) - diff --git a/eID_gui/src/pinpad.glade b/eID_gui/src/pinpad.glade index aab5264..6250e93 100644 --- a/eID_gui/src/pinpad.glade +++ b/eID_gui/src/pinpad.glade @@ -250,6 +250,7 @@ Ok True + False True True