Python Forum
Tkinter exception if entries are not filled up
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter exception if entries are not filled up
#6
from tkinter import *
 
Appli = Tk()
Appli.title("Application de retraite")
Appli.geometry("640x640")
  
  
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 verific():
    if not i.get() or i.get().isnumeric() == True:
        button.configure(state = DISABLED)
        Appli.after(1, verific)
    else:
        button.configure(state = NORMAL)
        Appli.after(1, verific)

def do_it():
    print("execute your function here")


button= Button(Appli, text="Calculer", width="20", height="3",command=do_it,font=("arial",12,"bold"),bg="white",fg="#2340B6")
button.place(x=20, y=500)    

verific()
Appli.mainloop()

entry_box1
is verified by this example.
Reply


Messages In This Thread
RE: Tkinter exception if entries are not filled up - by balenaucigasa - Jan-09-2020, 04:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Tkinter callback exception Ben123 2 637 Feb-17-2024, 06:03 PM
Last Post: deanhystad
  button enabled only when all the inputs are filled cybertooth 5 5,676 Oct-22-2021, 10:10 PM
Last Post: deanhystad
  [Tkinter] Tkinter delete values in Entries, when I'm changing the Frame robertoCarlos 11 5,946 Jul-29-2020, 07:13 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020