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()
|
||||
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()
|
||||
@@ -526,12 +543,3 @@ class PinpadGTK:
|
||||
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)
|
||||
|
||||
|
||||
@@ -250,6 +250,7 @@
|
||||
<object class="GtkButton" id="btnOk">
|
||||
<property name="label">Ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="on_btnOk_clicked"/>
|
||||
|
||||
Reference in New Issue
Block a user