how can i get the total value on entry box using tkinter radiobutton and checkbutton

Viewed 26

Can someone look at my code below and please tell me what I'm doing wrong. I've searched online for hours about this and I just can't see what I'm incorrectly doing.

from tkinter import *

#Function
def total():
    result = "1000"
    if ACvalue.get() == "AC" and Adultvalue.get() == "Adult" and NACvalue.get() == "N/AC":
        data.insert(0,result)

#Window
window = Tk()
window.title("Train Ticket Reservation")


ACvalue = StringVar()
NACvalue = StringVar()
Adultvalue = StringVar()
childvalue = StringVar()
data = StringVar()

#Creating Label 1
l1 = Label(window, text = "Coach: ")
l1.grid(column=0, row= 0)
#Creating Radio button 1
r1 = Radiobutton(window, text = "AC", value = "AC", variable=ACvalue)
r1.grid(column = 1, row = 0)
#Creating Radio button 2
r2 = Radiobutton(window, text = "N/AC", value = "N/AC", variable=NACvalue)
r2.grid(column = 2, row = 0)

#Creating Label 2
l2 = Label(window, text = "Person Type")
l2.grid(column = 0, row = 1)
#Creating Check Button 1
c1 = Checkbutton(window, text = "Adult",variable = Adultvalue)
c1.grid(column = 1, row = 1)
#Creating Check Button 2
c2 = Checkbutton(window, text = "Child", variable=childvalue)
c2.grid(column = 2, row = 1)

#Creating Entry
e1 = Entry(window, textvariable = data)
e1.grid(column = 1, row = 2)

#Creating Button
b1 = Button(window, text = "TOTAL", command = total())
b1.grid(columnspan = 1, row = 2)
#Loop
window.mainloop()

i dont know what else can i do to get the total total value on entrybox

0 Answers
Related