> Hi all, > Please can anyone tell me how i bind the activation of a button with input > from an entry widget. i know i should be using classes etc. but i don't > understand them fully yet.. problem here is that no matter what i enter in > the entry window it displays as password incorrect. > > from Tkinter import * > > password="trial" > > def reveal(): > """Display message based on password""" > contents=s > if contents=="trial": > print "password correct" > else: > print "password wrong" > > #main > root=Tk() > root.title("Password entry box") > root.geometry("300x100") > app=Frame(root) > app.grid() > > #labels > lbl=Label(app, text="Enter your password: ") > lbl.grid(row=1, column=0) > > #create entry widgets > e = Entry(root) > e.grid(row=1, column=1) > s=e.get() > > #create a submit button > b=Button(root, text="SUBMIT", command=reveal) > b.grid(row=0, column=2) > > > root.mainloop()
That is because the value of s never changes once it gets assigned. Change the following in reveal() contents=s to : contents=e.get() You may want to read Alan Gauld's tutorial (he is contributor to this list). It covers classes and basic GUI programming. http://www.alan-g.me.uk/tutor/index.htm Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor