vendredi 24 mai 2019

Please i have a problem with The function, whenever i click the checkbox it dosen't disable for me to type in something

How can i Make the text box disabled when i click the checkbox?

var1 =IntVar()
var1.set(0)
E_Rice=StringVar()
E_Rice.set("0")

def chkR():
    if  (var1.get()==1):
        txtRice.configure(state = NORMAL)
        txtRice.focus()
        txtRice.delete('0',END)
        E_Rice.set("")
    elif(var1.get()==0):
        txtRice.configure(state = DISABLED)
        E_Rice.set("0")

Rice=Checkbutton(root,text=" Rice",variable=var1, onvalue=1,       offvalue=0,font=('arial',16,'bold'),
                bg='pale green',command=chkR).grid(row=0,sticky=W)

txtRice = Entry(root,font=('arial',10,'bold'),bd=6,width=6, justify='right',state = DISABLED,textvariable=E_Rice).grid(row=0,column=1)




Aucun commentaire:

Enregistrer un commentaire