Here we will learn how to enable the disabled value to allow user to enter in Entry Widget. option state is used to block user input in Entry Widget.
State = DISABLED to block user to enter data in entry widget
State = NORMAL to allow user to enter data in entry widget (set by default)
after launching the application, window appears as
after clicking on Button, window appears as:
below is the code disable the entry widget, GUI will look like as above image
# program
try:
from Tkinter import *
except:
from tkinter import *
def allow_editing():
le.config(state=NORMAL)
mw = Tk()
mw.geometry("500x100+50+50")
mw.title("AETies : Automation Expert Technologies")
mw.config(background='#eeeeee')
l1 = Label(mw, text=' Website : ', bg='#eeeeee')
l1.pack(side=LEFT)
le = Entry(mw, width=20)
le.insert(0,'AETies.com')
le.config(state=DISABLED)
le.pack(side=LEFT)
bt = Button(mw, text=' Edit Username ', fg='red', command=allow_editing)
bt.pack(side=LEFT)
mainloop()
Comments
Post a Comment