I have already read around the site about how to just get the input from a barcode scanner but I am not sure on how I should actually do it.
I will be using this barcode scanner: https://www.amazon.co.uk/Esky-Wireless-Handheld-Barcode-Rechargeable/dp/B00O9P3Z7C/ref=sr_1_6?ie=UTF8&qid=1482066778&sr=8-6&keywords=usb+barcode+scanner
I basically need to when a user clicks return button in my tkinter window I need the program to be a while loop until a input is received from the scanner, then I will be using that to scanner to see if it is in my database.
I can do the SQL and everything else, but I am not actually sure what the best way is to strip the data from the barcode scanner since it should act as a keyboard.
Edit: I have attempted this:
barcode = simpledialog.askstring("Barcode scan", "Please scan the barcode of the laptop you rented")
cursor.execute("SELECT barcode FROM laptops WHERE idlaptops=%s",laptopid)
barcodefetch = fetchResult(cursor)
actualbarcode = barcodefetch[0]["barcode"]
if barcode != actualbarcode:
messagebox.showinfo("Barcode invalid", "Barcode did not match please scan the barcode again")
return
Would the scanner type into the askstring box?
A barcode scanner is viewed by the computer as a keyboard. As long as a text field in a window has the focus, when the trigger is pulled, the code is typed in the field, the same way you would do with a keyboard.