inventory.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python
  2. #
  3. # Program to view the inventory,
  4. #
  5. import os
  6. import sys
  7. import Tkinter as tk
  8. import config
  9. import admin
  10. class Inventory(object):
  11. '''
  12. Window to check out the inventory.
  13. '''
  14. def availability(self):
  15. '''
  16. Queries the database to see if there are any items still available
  17. '''
  18. product = self.menuvalue.get()
  19. stock = admin.view_availability(product)
  20. self.counter.config(text="Quantidade em estoque: %s" % stock)
  21. def __init__(self):
  22. self.window = tk.Tk()
  23. self.window.title("Gestor de inventario")
  24. self.inventory_frame = tk.Frame(self.window)
  25. self.counter = tk.Label(text="Selecione um item para checar")
  26. # Stuff for Dropdown menu:
  27. self.menuvalue = tk.StringVar(self.window)
  28. self.menuvalue.set("Clique para escolher")
  29. self.inventoryframe = tk.Frame(self.inventory_frame)
  30. self.dropdown = apply(tk.OptionMenu, (self.inventoryframe,
  31. self.menuvalue) + config.products)
  32. self.checker = tk.Button(self.inventory_frame, text="Checar disponibilidade",
  33. command=self.availability)
  34. # Pack everything:
  35. self.inventoryframe.pack(side="left", expand=1)
  36. self.dropdown.pack(expand=1)
  37. self.checker.pack(side="right")
  38. self.counter.pack(expand=1)
  39. self.inventory_frame.pack(expand=1)
  40. def main(self):
  41. self.window.mainloop()
  42. if __name__ == "__main__":
  43. app = Inventory()
  44. app.main()