Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. from Tkinter import *
  2. import tkMessageBox
  3. from tkMessageBox import *
  4. from pymongo import MongoClient
  5.  
  6. #VENTANA CON BANNERS
  7. ventana = Tk()
  8. ventana.title("Venta de Boletos")
  9. ventana = Canvas(width = 500, height = 630, bg = 'black')
  10. ventana.pack(expand = YES, fill = BOTH)
  11.  
  12.  
  13. #AREA A ESCOGER
  14. var = StringVar(ventana)
  15. var.set("Eliga un area")
  16. etiqueta_area = Label(ventana, text='Area: ',background="yellow3",foreground="black",font=('Arial',10)).place(x=120, y=250)
  17. ent_area = OptionMenu(ventana, var, "Pista General", "Segundo Piso", "Tercer Piso")
  18. ent_area.config(background="yellow3",foreground="black")
  19. ent_area.place(x=290, y=250)
  20.  
  21. #CANTIDAD DE BOELTOS
  22. et1 = Label(ventana, text="Cantidad de boletos",background="yellow3",foreground="black",font=('Arial',10)).place(x=80, y=320)
  23. arr1 = [1, 2, 3, 4, 5, 6, 7]
  24. cantidad = StringVar()
  25. s1 = Spinbox(ventana, textvariable=cantidad, values=arr1,background="yellow3",foreground="black").place(x=280, y=320)
  26.  
  27. #MOSTRAR MAPA DEL EVENTO
  28. def mostrarmapa():
  29. mapa= Toplevel()
  30. mapa.title("Mapa del Evento")
  31. mostrar = Label(mapa, image=map)
  32. mostrar.pack()
  33. mapa.mainloop()
  34.  
  35. #CALCULAR TOTAL A PAGAR
  36. def comprar():
  37. area = str(var.get())
  38. boletos = int(cantidad.get())
  39. total=0
  40.  
  41. if area=="Pista General" and boletos<=4:
  42. total=boletos*1900
  43. tkMessageBox.showinfo("Total", cantidad.get()+" boletos para Pista General, su total es de: " + str(total))
  44. print total
  45. conexion(total)
  46.  
  47.  
  48. elif area=="Pista General" and boletos>4:
  49. showerror("Error", "No se permite adquirir mas de 4 boletos para esta area")
  50.  
  51. elif area=="Segundo Piso" and boletos>0:
  52. total = boletos * 1500
  53. tkMessageBox.showinfo("Total", cantidad.get()+" boletos para Segundo Piso, su total es de: " + str(total))
  54. print total
  55. conexion(total)
  56.  
  57.  
  58. elif area=="Tercer Piso" and boletos>0:
  59. total = boletos * 1200
  60. tkMessageBox.showinfo("Total", cantidad.get()+" boletos para Tercer Piso, su total es de: " + str(total))
  61. print total
  62. conexion(total)
  63.  
  64. def conexion(total):
  65. client = MongoClient('localhost', 27017)
  66. db = client['store']
  67.  
  68. document = {"Total":total}
  69. _id = db['corte_dia'].insert(document)
  70. print _id
  71. return
  72.  
  73. #BOTONES
  74. b1=Button(ventana, text='Mostrar mapa',background="yellow3",foreground="black", command=mostrarmapa,font=('Arial',10)).place(x=170, y=400)
  75. b2=Button(ventana, text='Pagar', background="yellow3",foreground="black", command=comprar,font=('Arial',10)).place(x=275, y=400)
  76. bc = Button(ventana, text="Conectar BD", command=conexion)
  77. bc.grid(row=19, column=2, padx=(20, 20), pady=(20, 20))
  78. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement