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
This commit is contained in:
@@ -419,6 +419,19 @@ class PinpadGTK:
|
|||||||
self.cardChecker.join()
|
self.cardChecker.join()
|
||||||
gtk.main_quit()
|
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):
|
def digit_clicked(self, widget):
|
||||||
"""We indicate the ammount of digits with underscores
|
"""We indicate the ammount of digits with underscores
|
||||||
For every digit that is enterd we replace one underscore with a star
|
For every digit that is enterd we replace one underscore with a star
|
||||||
@@ -431,10 +444,14 @@ class PinpadGTK:
|
|||||||
idx = txt.find('_')
|
idx = txt.find('_')
|
||||||
output = txt[:idx] + digit + txt[idx+1:]
|
output = txt[:idx] + digit + txt[idx+1:]
|
||||||
self.output.set_text(output)
|
self.output.set_text(output)
|
||||||
gobject.timeout_add(750, self.hide_digits, idx)
|
gobject.timeout_add(750, self.__hide_digit, idx)
|
||||||
self.pin += digit
|
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 '*' """
|
"""Change character number idx of self.output text to a '*' """
|
||||||
output = ""
|
output = ""
|
||||||
txt = self.output.get_text()
|
txt = self.output.get_text()
|
||||||
@@ -519,19 +536,10 @@ class PinpadGTK:
|
|||||||
#XXX: Actually we should return to the application that started
|
#XXX: Actually we should return to the application that started
|
||||||
#the PIN entry
|
#the PIN entry
|
||||||
self.shutdown(None)
|
self.shutdown(None)
|
||||||
else:
|
else:
|
||||||
popup = MsgBox(self.window, "PIN wurde falsch eingegeben", "error",
|
popup = MsgBox(self.window, "PIN wurde falsch eingegeben", "error",
|
||||||
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
|
||||||
popup.run()
|
popup.run()
|
||||||
popup.destroy()
|
popup.destroy()
|
||||||
self.output.set_text(self.secret_len * "_")
|
self.output.set_text(self.secret_len * "_")
|
||||||
self.pin = ""
|
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)
|
|
||||||
|
|
||||||
|
|||||||
@@ -250,6 +250,7 @@
|
|||||||
<object class="GtkButton" id="btnOk">
|
<object class="GtkButton" id="btnOk">
|
||||||
<property name="label">Ok</property>
|
<property name="label">Ok</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="sensitive">False</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<signal name="clicked" handler="on_btnOk_clicked"/>
|
<signal name="clicked" handler="on_btnOk_clicked"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user