transactions.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env python
  2. #
  3. # Checks out existing transactions
  4. #
  5. # Hint: master the ability to choose when to expand or not!
  6. #
  7. import os
  8. import sys
  9. import Tkinter as tk
  10. import admin
  11. import config
  12. class GUI:
  13. def checkorder(self):
  14. purchase = admin.view_purchase(self.codefield.get())
  15. finalstring = ""
  16. if purchase is not None:
  17. finalstring += "Cliente: %s (%s)\n" % (purchase[0], purchase[1])
  18. if purchase[2] != 0:
  19. finalstring += "Sabonete de Mel: %s unidades\n" % purchase[2]
  20. if purchase[3] != 0:
  21. finalstring += "Sabonete de Patchouli: %s unidades\n" % purchase[3]
  22. if purchase[4] != 0:
  23. finalstring += "Sabonete de Papoula: %s unidades\n" % purchase[4]
  24. if purchase[5] != 0:
  25. finalstring += "Sabonete de Capim-limao: %s unidades\n" % purchase[5]
  26. if purchase[6] != 0:
  27. finalstring += "Alcool-gel: %s unidades\n" % purchase[6]
  28. finalstring += "Status do pedido: %s\n" % purchase[7]
  29. finalstring += "Criado em: %s" % purchase[8]
  30. self.resultsfield.config(text=finalstring)
  31. else:
  32. self.resultsfield.config(text="Transaction not found")
  33. def __init__(self):
  34. self.window = tk.Tk()
  35. self.window.geometry("400x300")
  36. self.window.title("Compras existentes")
  37. self.coderow = tk.Frame(self.window)
  38. self.codelabel = tk.Label(self.coderow, text="Codigo do pedido")
  39. self.codefield = tk.Entry(self.coderow)
  40. self.checkbutton = tk.Button(self.coderow, text="Checar",
  41. command=self.checkorder)
  42. self.resultsarea = tk.Frame(self.window)
  43. self.resultslabel = tk.Label(self.resultsarea, text="Detalhes do pedido")
  44. self.resultsfield = tk.Label(self.resultsarea, text="")
  45. self.coderow.pack(expand=False)
  46. self.resultsarea.pack(expand=True, fill=tk.BOTH)
  47. self.resultslabel.pack()
  48. self.resultsfield.pack(expand=True, fill=tk.BOTH)
  49. self.codelabel.pack(side="left")
  50. self.codefield.pack(side="left")
  51. self.checkbutton.pack(side="left")
  52. def main(self):
  53. self.window.mainloop()
  54. if __name__ == "__main__":
  55. app = GUI()
  56. app.main()