Jan-07-2020, 10:15 PM
Hi, he're my request: I want that if all the entries are not filled , the button stays disabled and if not, the button enables. I tried to but I didn't manage it. Could you tell me what's going wrong and how to solve it ? Thanks:
label1 = Label(Appli,text="Entrez votre nom: ",font=("arial",12,"bold"),bg="#2340B6", fg="white") label1.place(x=20, y=100) i= StringVar() entry_box1= Entry(Appli, textvariable=i, bg="white", width="15") entry_box1.place(x=190,y=105) label2= Label(Appli,text="Quelle est votre année de naissance? : ",font=("arial",12,"bold"),bg="#2340B6", fg="white") label2.place(x=20, y=175) k= IntVar() entry_box2= Entry(Appli, textvariable=k, bg="white", width="15") entry_box2.place(x=340,y=180) label3= Label(Appli,text="Quel est votre revenu mensuel sur vos six derniers mois? : ",font=("arial",12,"bold"),bg="#2340B6", fg="white") label3.place(x=20, y=255) revenu_moyen= IntVar() entry_box3= Entry(Appli, textvariable=revenu_moyen, bg="white", width="15") entry_box3.place(x=500,y=260) label4= Label(Appli,text="Combien de trimestres avez vous cotisé? : ",font=("arial",12,"bold"),bg="#2340B6", fg="white") label4.place(x=20, y=335) trimestre_cotisés= IntVar() entry_box4= Entry(Appli, textvariable=trimestre_cotisés, bg="white", width="15") entry_box4.place(x=380,y=340) label5= Label(Appli,text="Combien avez vous d'enfants? : ",font=("arial",12,"bold"),bg="#2340B6", fg="white") label5.place(x=20, y=410) enfants=IntVar() entry_box5 = Entry(Appli, textvariable=enfants, bg="white", width="10") entry_box5.place(x=300,y=415) def do_it(): if i.get() and k.get() and revenu_moyen.get() and trimestre_cotisés.get() and enfants.get() : button["state"]= "normal" F= calcul_fonctionnaire(i.get(), k.get(), revenu_moyen.get(), trimestre_cotisés.get(), enfants.get()) S=int(F) G=F*12 RA=int(G) A= str(i.get())+", ta pension de retraite sera de "+str(S)+"€ par mois, soit de "+str(RA)+"€ par an" button.destroy() label6= Label(Appli,text=A,font=("arial",15,"bold"), fg="white", bg="#2340B6", bd=2, relief=SUNKEN) label6.place(x=40, y=500) else: button["state"]= "disabled" button= Button(Appli, text="Calculer", width="20", height="3",command=do_it,font=("arial",12,"bold"),bg="white",fg="#2340B6", state="disabled") button.place(x=20, y=500)