Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.9 kB
19
Indexable
Never
from tkinter import *
from tkinter import messagebox
from tkinter.messagebox import askyesno
a=Tk()
lb1=Label(a,text="Metro Ticket Booking",
          font=("Arial bold",15))
lb1.grid(column=1,row=0)
lb2=Label(a,text="Passenger Name")
lb2.grid(column=0,row=1)
lb3=Label(a,text="From Station")
lb3.grid(column=0,row=2)
lb4=Label(a,text="To Station")
lb4.grid(column=0,row=3)
lb5=Label(a,text="Tickets")
lb5.grid(column=0,row=4)
lb6=Label(a,text="Do you need a cab?",
          font=("Arial bold",10))
lb6.grid(column=0,row=5)
e1=Entry(a,width=15)
e1.grid(column=1,row=1)
fs=["KPHB","JNTUH","MYP"]
v1=StringVar()
d1=OptionMenu(a,v1,*fs)
d1.grid(column=1,row=2)
ts=["KPHB","JNTUH","MYP"]
v2=StringVar()
d2=OptionMenu(a,v2,*ts)
d2.grid(column=1,row=3)
tickets=[1,2,3,4,5]
v3=IntVar()
d3=OptionMenu(a,v3,*tickets)
d3.grid(column=1,row=4)
def y():
    lb7=Label(a,text="Drop Location")
    lb7.grid(column=0,row=6)
    e2=Entry(a,width=15)
    e2.grid(column=1,row=6)
    def book():
        t=v3.get()
        bill=t*40
        ans=askyesno("","Hello "+e1.get()+
            "\n ***Metro*** \n From :"+v1.get()+
            "\n To :"+v2.get()+
            "\n Tickets :"+str(t)+
            "\n Metro bill:"+str(bill)+
            "\n *** CAB *** \n From:"+v2.get()+
            "\n To:"+e2.get()+" \n Please confirm?")
        if ans:
            messagebox.showinfo("","done")
        else:
            messagebox.showerror("","cancelled")
    b3=Button(a,text="Book",command=book)
    b3.grid(column=1,row=7)  
b1=Button(a,text="Yes",command=y)
b1.grid(column=1,row=5)
def n():
    t=v3.get()
    bill=t*40
    messagebox.showinfo("","Hello "+e1.get()+
        "\n ***Metro*** \n From :"+v1.get()+
        "\n To :"+v2.get()+
        "\n Tickets :"+str(t)+
        "\n Metro bill:"+str(bill))
b2=Button(a,text="No",command=n)
b2.grid(column=2,row=5)
a.mainloop()