I am new to python/tkinter in my lab we use a barcode scanner to scan Sample numbers into a database. I just want to be able to create an entry widget that is able to detect the length of the text that it is given and if it is that length to add it to a listbox. Heres my code:
from tkinter import *
def my_tracer(arg1, arg2, arg3):
SampleNumber = len(e1_var.get())
t_var.set(SampleNumber)
if t_var == 8:
Listbox.insert(END, t_var)
root = Tk()
root.geometry("200x200")
SampleList = Listbox(root, selectmode=EXTENDED)
SampleList.pack()
t_var = StringVar()
e1_var = StringVar()
e1_var.trace("w", my_tracer)
e1 = Entry(root, textvariable=e1_var)
e1.pack()
root.mainloop()
I get no error but nothing happens
I am sure there is something fundamental here that i am missing.
Thanks in advance