aboutsummaryrefslogtreecommitdiff
path: root/fprintd_tk.py
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-09-24 11:20:38 -0400
committerB. Stack <bgstack15@gmail.com>2024-09-24 11:20:38 -0400
commit1046b013a0deb2d2a212106b0d9324ebea3b7b9b (patch)
tree1d8290838f565bd6c8b8f938b91b9896629fb8be /fprintd_tk.py
parentinitial protection against empty response from get_enrolled_fingers (diff)
downloadfprintd-tk-1046b013a0deb2d2a212106b0d9324ebea3b7b9b.tar.gz
fprintd-tk-1046b013a0deb2d2a212106b0d9324ebea3b7b9b.tar.bz2
fprintd-tk-1046b013a0deb2d2a212106b0d9324ebea3b7b9b.zip
flash finger that completed an action
Diffstat (limited to 'fprintd_tk.py')
-rwxr-xr-xfprintd_tk.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/fprintd_tk.py b/fprintd_tk.py
index a2cfd99..9af4513 100755
--- a/fprintd_tk.py
+++ b/fprintd_tk.py
@@ -6,7 +6,7 @@
# References:
# stackrpms_tk.py
# Improve:
-# flash the newly enrolled finger, and/or the failed verify on a finger.
+# if user can control other users' fingerprints, then show a drop-down of users?
import tkinter as tk, os, tkinter.simpledialog, sys, threading, time
import tkstackrpms as stk
@@ -48,6 +48,7 @@ class App(tk.Frame):
menu.add_cascade(label="Help",menu=menu_help,underline=0)
self.master.config(menu=menu)
self.grid() # use this instead of pack()
+ self.background_color = self.master.cget("bg")
# statusbar variable
self.statustext = tk.StringVar()
@@ -63,6 +64,7 @@ class App(tk.Frame):
self.frm_actions = tk.Frame(self.master)
self.frm_actions.grid(row=0,column=0)
self.action = tk.IntVar(value=1)
+ self.last_fingerbutton_used = tk.StringVar()
stk.Radiobutton(self.frm_actions,value=1,text="enroll",variable=self.action,underline=0).grid(row=0,column=0)
stk.Radiobutton(self.frm_actions,value=2,text="verify",variable=self.action,underline=0).grid(row=1,column=0)
@@ -99,7 +101,6 @@ class App(tk.Frame):
def load_data_into_form(self):
time.sleep(0.05)
- # WORKHERE: if the fprintd-list fails because the device is open, we will want to keep the old enrolled_fingers list. maybe check if statustext contains "failed to open" or whatever the message is. if it does, do not update the self.enrolled_fingers?
try:
self.old_enrolled_fingers = self.enrolled_fingers
except:
@@ -110,6 +111,7 @@ class App(tk.Frame):
self.enrolled_fingers = temp1
else:
print(f"DEBUG (load_data_into_form): having to skip empty response from get_enrolled_fingers")
+ self.func_update_status("Unable to update enrolled fingers.")
print(f"DEBUG (load_data_into_form): got enrolled fingers {self.enrolled_fingers}")
for i in self.fingers:
if str(i.cget('text')) in self.enrolled_fingers:
@@ -137,6 +139,7 @@ class App(tk.Frame):
except ValueError:
action_str = "OFF"
if action_str in available_actions:
+ self.last_fingerbutton_used.set(finger)
try:
t1 = threading.Thread(target=lib.fprintd_action, args=(action_str, finger, self.func_update_status))
t1.start()
@@ -151,8 +154,36 @@ class App(tk.Frame):
def func_update_status(self, msg):
msg = msg.strip()
- print(f"DEBUG (func_update_status: msg {msg}",file=sys.stderr)
+ print(f"DEBUG (func_update_status): msg {msg}",file=sys.stderr)
self.statustext.set(msg)
+ try:
+ this_finger = [i for i in self.fingers if i.cget("text") == self.last_fingerbutton_used.get()][0]
+ except Exception as e:
+ this_finger = None
+ print(f"DEBUG (func_update_status): while evaluating last-used finger, got {e}")
+ # flash these red
+ failure_messages = [
+ "enroll-duplicate",
+ "verify-no-match"
+ ]
+ # flash these green
+ success_messages = [
+ "verify-match",
+ "enroll-completed"
+ ]
+ flashed = False
+ for i in failure_messages:
+ if i in msg:
+ flashed = True
+ if this_finger:
+ stk.flash_entry(this_finger,["red",self.background_color]*3,300)
+ break
+ if not flashed:
+ for i in success_messages:
+ if i in msg:
+ if this_finger:
+ stk.flash_entry(this_finger,["green",self.background_color]*3,300)
+ break
self.load_data_into_form()
def func_delete(self):
bgstack15