[Tutor] binding a button to an entry
ramit.prasad at jpmorgan.com
Tue May 1 17:52:04 CEST 2012
> 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 *
> def reveal():
> """Display message based on password"""
> if contents=="trial":
> print "password correct"
> print "password wrong"
> root.title("Password entry box")
> 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)
> #create a submit button
> b=Button(root, text="SUBMIT", command=reveal)
> b.grid(row=0, column=2)
That is because the value of s never changes once it gets assigned.
Change the following in reveal()
You may want to read Alan Gauld's tutorial (he is contributor to this
list). It covers classes and basic GUI programming.
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.
More information about the Tutor