Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Are there any other methods to detect the key presses on tkinter?

I’m currently working on a personal project. I was planning to create a Secured Database where only people with Special ID’s are able to access by just swiping their IDs on the scanner to be able to enter. The problem is that whenever the IDs do get read, they don’t automatically return the input from the Entry box. Here’s my code as reference to what i’m talking about:

Entry1 = Entry(main, width = 20)
Entry1.pack()

lbl = Label(main, text = "a")
lbl.pack()
lb2 = Label(main, text = "a")
lb2.pack()
lb3 = Label(main, text = "a")
lb3.pack()

def find():
    with open(CsvFile, newline = '') as csvcsv:
        reader = csv.DictReader(csvcsv)
        barcode = Entry1.get()
        for row in reader:
            if barcode == row['Sample']:
                lbl.config(text = row[''])
                lb2.config(text = row[''])
                break
        else:
            lbl.config(text='Your not a registered User')


keyboard.on_press_key("ENTER", lambda _:find)

Button(main, text='search', command = find).place(x=100, y=170)

main.mainloop()

This just a sample code but if anyone has an answer, It’s appreciated…

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The problem is that whenever the IDs do get read, they don’t automatically return the input from the Entry box.

One possible solution to this problem is to use the .get() method on the Entry widget to retrieve the text inputted by the user.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading