简体   繁体   中英

how to enable a entry by clicking a button in Tkinter?

I need to activate many entries when button is clicked

please do not write class based code, modify this code only because i need to change the whole code for the project as i did my whole project without classes

from Tkinter import *
import ttk
x='disabled'
def rakhi():
   global x
   x='NORMAL'
root = Tk()
frame=Frame(root)
frame.pack()
entry1=Entry(frame,state=x)
entry1.pack()
entry2=Entry(frame,state=x)
entry2.pack()
button1=Button(frame,text="press",command=rakhi)
button1.pack()
mainloop()  

You need to use the configure method of each widget:

def rakhi():
    entry1.configure(state="normal")
    entry2.configure(state="normal")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM