i have created multiple interfaces in Tkinter using python,and i would like to display a page ("you are registered ") if a match is found in the database else ("you are not registered").
code for multiple pages
import Tkinter as tk
from Tkinter import IntVar
TITLE_FONT = ("Helvetica", 18, "bold")
class oscarApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
container = tk.Frame(self,bg="green")
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (StartPage, PageOne, PageTwo,PageFour):
page_name = F.__name__
frame = F(container, self)
self.frames[page_name] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("StartPage")
def show_frame(self, page_name):
'''Show a frame for the given page name'''
frame = self.frames[page_name]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self,bg="green",
text="PLease place your thumb print\n on fingerprint scanner to start ",
font=TITLE_FONT)
label.pack(side="top", fill="x", pady=10)
button1 = tk.Button(self, text="NEXT",bg="yellow",
command=lambda: controller.show_frame("PageOne"))
button1.pack(pady=10)
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="This is page ONE", font=TITLE_FONT)
label.pack(side="top", fill="x", pady=10)
label = tk.Label(self, text="YOU ARE NOT REGISTERED", font=TITLE_FONT)
label.pack(side="top", fill="x", pady=10)
button = tk.Button(self, text="NEXT",
command=lambda: controller.show_frame("StartPage"))
button.pack()
class PageTwo(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="you are registered\n press NEXT to START", font=TITLE_FONT,bg="green")
label.pack(side="top", fill="x", pady=10)
button = tk.Button(self, text="NEXT",
command=lambda: controller.show_frame("pagefour"))
button.pack()
class PageFour(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="This is page four", font=TITLE_FONT)
label.pack(side="top", fill="x", pady=10)
label = tk.Label(self, text="THANKS ", font=TITLE_FONT)
label.pack(side="top", fill="x", pady=10)
button = tk.Button(self, text="Go to the start page",
command=lambda: controller.show_frame("StartPage"))
button.pack()
if __name__ == "__main__":
app = oscarApp()
app.mainloop()
code finger print is
import hashlib
from pyfingerprint.pyfingerprint import PyFingerprint
try:
f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000)
if ( f.verifyPassword() == False ):
raise ValueError('The given fingerprint sensor password is wrong!')
except Exception as e:
print('The fingerprint sensor could not be initialized!')
print('Exception message: ' + str(e))
exit(1)
print('Currently stored templates: ' + str(f.getTemplateCount()))
try:
print('Waiting for finger...')
while ( f.readImage() == False ):
pass
f.convertImage(0x01)
result = f.searchTemplate()
positionNumber = result[0]
accuracyScore = result[1]
if ( positionNumber == -1 ):
print('No match found!')
exit(0)
else:
print('Found template at position #' + str(positionNumber))
print('The accuracy score is: ' + str(accuracyScore))
f.loadTemplate(positionNumber, 0x01)
characterics = str(f.downloadCharacteristics(0x01))
print('SHA-2 hash of template: ' + hashlib.sha256(characterics).hexdigest())
except Exception as e:
print('Operation failed!')
print('Exception message: ' + str(e))
exit(1)
What I have tried:
i have tried to create a search for fingerprint template code and its working well and creating multiple pages.i would like to integrate them together