Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Problem with Submit button Tkinter
#1
HI, If you take a look on my precedent code , I managed to do it. The issue is when I press the button "make_it", it prints me 0, so I think that nothing happened and the values that I registered weren't taken.
Btw, the function "calcul_fonctionnaire" is just a function in which I take all the values and make some calculation and gives me a list of 2 int in it
def retraite_fonctionnaire():
    i=input("Entrez votre nom: ")
    k=input("Quelle est votre année de naissance ?: ")
    revenu_moyen=int(input("Quel est votre salaire mensuel sur ces 6 derniers mois?: "))
    trimestre_cotisés = int(input("Combien de trimestres avez vous cotisé ?: " ))
    enfants = int(input("Combien avez vous d'enfants ?: " ))
    L = calcul_fonctionnaire(i,k,revenu_moyen,trimestre_cotisés,enfants)
    return L


window= Tk()
window.title("Application de retraite")
window.geometry("640x640")


label1= Label(window,text="Entrez votre nom: ",font=("arial",15,"bold"), fg="black").place(x=20, y=200)
i= StringVar()
entry_box1= Entry(window, textvariable="i", bg="gray", width="15").place(x=300,y=200)



label2= Label(window,text="Quelle est votre année de naissance?: ",font=("arial",15,"bold"), fg="black").place(x=20, y=300)
k= int()
entry_box2= Entry(window, textvariable="k", bg="gray", width="15").place(x=300,y=300)



label3= Label(window,text="Quel est votre revenu mensuel sur vos vingt-cinq meilleures années ?: ",font=("arial",15,"bold"), fg="black").place(x=20, y=400)
revenu_moyen= int()
entry_box3= Entry(window, textvariable="revenu_moyen", bg="gray", width="15").place(x=300,y=400)



label4= Label(window,text="Combien de trimestres avez vous cotisé ?: ",font=("arial",15,"bold"), fg="black").place(x=20, y=500)
trimestre_cotisés= int()
entry_box4= Entry(window, textvariable="trimestre_cotisés", bg="gray", width="15").place(x=300,y=500)




label5= Label(window,text="Combien avez vous d'enfants ?: ",font=("arial",15,"bold"), fg="black").place(x=20, y=600)
enfants=int()
entry_box5 = Entry(window, textvariable="enfants", bg="gray", width="15").place(x=300,y=600)

calcul_salarie(i,k,revenu_moyen,trimestre_cotisés,enfants)



def do_it():
    calcul_salarie(i,k,revenu_moyen,trimestre_cotisés,enfants)
    print(calcul_salarie(i,k,revenu_moyen,trimestre_cotisés,enfants))
    
make_it= Button(window, text="PRINT", width="30", height="20",command=do_it,bg="lightblue").place(x=500, y=500)
    
window.mainloop()
Quote
#2
replace all "int()" with "IntVar()" e.g. k= IntVar()
remove all "" from textvariable="i", ="k", ="revenu_moyen" ... correct is textvariable=i
Quote
#3
from tkinter import *

window = Tk()
window.title("Application de retraite")
window.geometry("640x640")
 
 
label1 = Label(window,text="Entrez votre nom: ",font=("arial",15,"bold"), fg="black").place(x=20, y=200)
i= StringVar()
entry_box1= Entry(window, textvariable=i, bg="gray", width="15").place(x=300,y=200)
 
 
label2= Label(window,text="Quelle est votre année de naissance?: ",font=("arial",15,"bold"), fg="black").place(x=20, y=300)
k= IntVar()
entry_box2= Entry(window, textvariable=k, bg="gray", width="15").place(x=300,y=300)
 
 
label3= Label(window,text="Quel est votre revenu mensuel sur vos vingt-cinq meilleures années ?: ",font=("arial",15,"bold"), fg="black").place(x=20, y=400)
revenu_moyen= IntVar()
entry_box3= Entry(window, textvariable=revenu_moyen, bg="gray", width="15").place(x=300,y=400)
 
 
label4= Label(window,text="Combien de trimestres avez vous cotisé ?: ",font=("arial",15,"bold"), fg="black").place(x=20, y=500)
trimestre_cotisés= IntVar()
entry_box4= Entry(window, textvariable=trimestre_cotisés, bg="gray", width="15").place(x=300,y=500)
 
 
label5= Label(window,text="Combien avez vous d'enfants ?: ",font=("arial",15,"bold"), fg="black").place(x=20, y=600)
enfants=IntVar()
entry_box5 = Entry(window, textvariable=enfants, bg="gray", width="15").place(x=300,y=600)

 
def do_it():
    print(i.get(), k.get(), revenu_moyen.get(), trimestre_cotisés.get(), enfants.get())

     
make_it = Button(window, text="PRINT", width="18", height="9",command=do_it,bg="lightblue").place(x=500, y=470)
     
window.mainloop()
you must use .get()
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Database Submit Entry Syntax Error Melford 27 237 Jan-27-2020, 04:20 PM
Last Post: Denni
  [Tkinter] Tkinter problem catlessness 1 93 Jan-15-2020, 05:17 AM
Last Post: Larz60+
  tkinter button not accessing the command when clicked jhf2 1 196 Nov-23-2019, 10:17 PM
Last Post: DT2000
  Tkinter button in for Simpsunt 3 164 Nov-23-2019, 01:41 AM
Last Post: Larz60+
  [Tkinter] Checking button click in Tkinter GalaxyCoyote 3 344 Oct-20-2019, 03:28 AM
Last Post: GalaxyCoyote
  tkinter GUI, problem running seperate files fishglue 17 691 Oct-15-2019, 02:56 PM
Last Post: Denni
  [Tkinter] Tkinter button help and general commands Iceman 1 320 Sep-01-2019, 05:09 PM
Last Post: Yoriz
  [PyQt] Problem how to click a button inside a group box? mart79 2 305 Aug-05-2019, 01:21 PM
Last Post: mart79
  [python] [Tkinter] Problem bidding combobox with np.array NEL 3 306 Aug-04-2019, 11:07 AM
Last Post: Yoriz
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 526 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp

Forum Jump:


Users browsing this thread: 1 Guest(s)