Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Tkinter import *
- import tkMessageBox
- from tkMessageBox import *
- from pymongo import MongoClient
- #VENTANA CON BANNERS
- ventana = Tk()
- ventana.title("Venta de Boletos")
- ventana = Canvas(width = 500, height = 630, bg = 'black')
- ventana.pack(expand = YES, fill = BOTH)
- #AREA A ESCOGER
- var = StringVar(ventana)
- var.set("Eliga un area")
- etiqueta_area = Label(ventana, text='Area: ',background="yellow3",foreground="black",font=('Arial',10)).place(x=120, y=250)
- ent_area = OptionMenu(ventana, var, "Pista General", "Segundo Piso", "Tercer Piso")
- ent_area.config(background="yellow3",foreground="black")
- ent_area.place(x=290, y=250)
- #CANTIDAD DE BOELTOS
- et1 = Label(ventana, text="Cantidad de boletos",background="yellow3",foreground="black",font=('Arial',10)).place(x=80, y=320)
- arr1 = [1, 2, 3, 4, 5, 6, 7]
- cantidad = StringVar()
- s1 = Spinbox(ventana, textvariable=cantidad, values=arr1,background="yellow3",foreground="black").place(x=280, y=320)
- #MOSTRAR MAPA DEL EVENTO
- def mostrarmapa():
- mapa= Toplevel()
- mapa.title("Mapa del Evento")
- mostrar = Label(mapa, image=map)
- mostrar.pack()
- mapa.mainloop()
- #CALCULAR TOTAL A PAGAR
- def comprar():
- area = str(var.get())
- boletos = int(cantidad.get())
- total=0
- if area=="Pista General" and boletos<=4:
- total=boletos*1900
- tkMessageBox.showinfo("Total", cantidad.get()+" boletos para Pista General, su total es de: " + str(total))
- print total
- conexion(total)
- elif area=="Pista General" and boletos>4:
- showerror("Error", "No se permite adquirir mas de 4 boletos para esta area")
- elif area=="Segundo Piso" and boletos>0:
- total = boletos * 1500
- tkMessageBox.showinfo("Total", cantidad.get()+" boletos para Segundo Piso, su total es de: " + str(total))
- print total
- conexion(total)
- elif area=="Tercer Piso" and boletos>0:
- total = boletos * 1200
- tkMessageBox.showinfo("Total", cantidad.get()+" boletos para Tercer Piso, su total es de: " + str(total))
- print total
- conexion(total)
- def conexion(total):
- client = MongoClient('localhost', 27017)
- db = client['store']
- document = {"Total":total}
- _id = db['corte_dia'].insert(document)
- print _id
- return
- #BOTONES
- b1=Button(ventana, text='Mostrar mapa',background="yellow3",foreground="black", command=mostrarmapa,font=('Arial',10)).place(x=170, y=400)
- b2=Button(ventana, text='Pagar', background="yellow3",foreground="black", command=comprar,font=('Arial',10)).place(x=275, y=400)
- bc = Button(ventana, text="Conectar BD", command=conexion)
- bc.grid(row=19, column=2, padx=(20, 20), pady=(20, 20))
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement