2016-03-24 16 views
-1

Ahududu pi üzerinde bir parmak izi tarayıcısı kullanıyorum ve tizter kullanarak birden çok sayfa oluşturdum. Parmak izi aramadan sonra bir hoşgeldin sayfasından bir sonraki sayfaya geçmek istiyorum. Veritabanında bir eşleşme varsa, hoşgeldin sayfasındaki bir sonraki sayfaya geçmeyi sağlar.parmak iziyle eşleştikten sonra yeni bir sayfanın nasıl açılacağı

import Tkinter as tk 
from Tkinter import IntVar 
# python3 
#import Tkinter as tk # python 

TITLE_FONT = ("Helvetica", 18, "bold") 

class oscarApp(tk.Tk): 

    def __init__(self, *args, **kwargs): 
     tk.Tk.__init__(self, *args, **kwargs) 

     # the container is where we'll stack a bunch of frames 
     # on top of each other, then the one we want visible 
     # will be raised above the others 
     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 

      # put all of the pages in the same location; 
      # the one on the top of the stacking order 
      # will be the one that is visible. 
      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() 

İşte parmak izi search.py

import hashlib 
from pyfingerprint.pyfingerprint import PyFingerprint 


## Search for a finger 
## 

## Tries to initialize the sensor 
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) 

## Gets some sensor information 
print('Currently stored templates: ' + str(f.getTemplateCount())) 

## Tries to search the finger and calculate hash 
try: 
    print('Waiting for finger...') 

    ## Wait that finger is read 
    while (f.readImage() == False): 
     pass 

    ## Converts read image to characteristics and stores it in charbuffer 1 
    f.convertImage(0x01) 

    ## Searchs template 
    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)) 

    ## OPTIONAL stuff 
    ## 

    ## Loads the found template to charbuffer 1 
    f.loadTemplate(positionNumber, 0x01) 

    ## Downloads the characteristics of template loaded in charbuffer 1 
    characterics = str(f.downloadCharacteristics(0x01)) 

    ## Hashes characteristics of template 
    print('SHA-2 hash of template: ' + hashlib.sha256(characterics).hexdigest()) 

except Exception as e: 
    print('Operation failed!') 
    print('Exception message: ' + str(e)) 
    exit(1) 
+1

kullanmak kapatmak için. Lütfen cevaplayabileceğimiz kesin bir sorunuz olması için bir [mcve] yayınlayın. –

+0

Merhaba PM 2Ring, sayfaları oluşturmama yol budur –

cevap

0
root2 = Toplevel(self.master) 
#when iv done this iv made a notepad file with the root levels and page 
#associated with them this makes it easier when opening and closing pages 

mygui2 = nameofclass(root2) 
#note that the root2 which i just made above is used here 
#when i was doing mine i used mygui and root for all of them but changed 
#number when opeing different webpages 

Sonra sayfalar size "sayfalar" tanımladığınız nasıl Duruma göre

self.master.destroy() 
İlgili konular