Why is it different between entry val and str(same)?

Viewed 38
    from tkinter import *
    import tkinter.ttk as ttk
    
    root = Tk()
    root.title("TEST ")
    
    lab_pro_val4=Label(root)
    lab_pro_val4=Label(root,    text="Anything input",    width=30,    height=1 )
    lab_pro_val4.pack()
    
    ent_pro_val4 = Entry(root) 
    ent_pro_val4.pack()
    
    
    def btncmd4_add():
       
       tru = (ent_pro_val4=='TEST123')
       print(tru)
        
    
    btn4_ppid = Button(root, text="Check ", command= btncmd4_add,bg = "white")
    btn4_ppid.pack()
    
    
    root.mainloop()
    
    

I used Tkinter but I had some trouble.

My question : why is it diff from entry to str(same)

I type the 'TEST123' in entry box.

But it's False... Why is it different?

Please let me know.

1 Answers

ent_pro_val4 is Entry widget, you need to get value of said widget, which can be done using .get(), that is replace

tru = (ent_pro_val4=='TEST123')

using

tru = (ent_pro_val4.get()=='TEST123')
Related