2

Good day,

I'm currently developing a simple Tkinter project. I have an RFID Reader that automatically prints/pastes its ID# once scanned. I have created this simple Tkinter window wherein the ID# is pasted on the Entry. My problem is that the messagebox does not appear even after the ID# is already pasted on the Entry field.

from tkinter import *
from tkinter import messagebox

root = Tk()
root.title("RFID Reader")
root.geometry("400x250")

rfid_label = Label(root, text="RFID Reader", font=("arial", 15, 'bold'), fg='red')
rfid_label.place(x=100, y=50)

rfid_entry = Entry(root, font=('arial', 15, 'bold'))
rfid_entry.focus()
rfid_entry.place(x=100, y=100)

scanned_ID = rfid_entry.get()
if len(scanned_ID) > 1:
    messagebox.showinfo(title="RFID Reader", message="RFID Scan Successful.")


root.mainloop()

Please help! Thanks!

k1dlat
  • 49
  • 5
  • Does this answer your question? [How do I get an event callback when a Tkinter Entry widget is modified?](https://stackoverflow.com/questions/6548837/how-do-i-get-an-event-callback-when-a-tkinter-entry-widget-is-modified) – Art Jun 12 '22 at 11:11

1 Answers1

0

It requires a mainloop

from tkinter import *
from tkinter import messagebox

root = Tk()
root.title("RFID Reader")
root.geometry("400x250")
def read():
    scanned_ID = rfid_entry.get()
    if len(scanned_ID) > 1:
        messagebox.showinfo(title="RFID Reader", message="RFID Scan Successful.")
rfid_label = Label(root, text="RFID Reader", font=("arial", 15, 'bold'), fg='red')
rfid_label.place(x=100, y=50)

rfid_entry = Entry(root, font=('arial', 15, 'bold'))
rfid_entry.focus()
rfid_entry.place(x=100, y=100)
B=Button(root,text="Enter",command=read)
B.pack()
root.mainloop()

Please check this solution and tell me whether this helped you

Midhun Raj
  • 925
  • 2
  • 7
  • 21
  • This is a valid workaround. However, I need the system to be fully handsfree because I'm going to use this as a handsfree attendance checker. Users can only interact with the system simply by scanning their RFID. Thanks for the effort though. – k1dlat Jun 12 '22 at 10:35
  • I think you can try pyembedded for this https://pypi.org/project/pyembedded/ – Midhun Raj Jun 12 '22 at 11:24
  • Does this help? messagebox.showinfo(title="RFID Reader", message="RFID Scan Successful. {scanned_ID}") – toyota Supra Mar 02 '23 at 12:31