Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env python3
  2. # Requires openpyxl and openpyxl_image_loader.
  3. #
  4. # ----------------------------------------------------------------------------
  5. # "THE BEER-WARE LICENSE" (Revision 42):
  6. # <xythobuz@xythobuz.de> wrote this file. As long as you retain this notice
  7. # you can do whatever you want with this stuff. If we meet some day, and you
  8. # think this stuff is worth it, you can buy me a beer in return. Thomas Buck
  9. # ----------------------------------------------------------------------------
  10. import sys
  11. from openpyxl import load_workbook
  12. from openpyxl_image_loader import SheetImageLoader
  13. if __name__ != "__main__":
  14. raise RuntimeError("Please run this file directly")
  15. if len(sys.argv) < 2:
  16. raise RuntimeError("Please pass input file as argument")
  17. wb = load_workbook(filename = sys.argv[1])
  18. ws = wb.active
  19. image_loader = SheetImageLoader(ws)
  20. data = []
  21. for row in ws:
  22. try:
  23. id = int(row[0].value)
  24. except:
  25. continue
  26. text = str(row[1].value)
  27. #print("id={} text='{}'".format(id, text))
  28. if not image_loader.image_in(row[2].coordinate):
  29. print("No image found for ID {}".format(id))
  30. image = None
  31. else:
  32. image = image_loader.get(row[2].coordinate)
  33. data.append((
  34. id, text, image
  35. ))
  36. print("Found {} IDs:".format(len(data)))
  37. print()
  38. print(" self.descriptions = [")
  39. for d in data:
  40. if d[2] != None:
  41. img_name = "weather_icon_{}.png".format(d[0])
  42. d[2].save(img_name)
  43. img_name = "'" + img_name + "'"
  44. else:
  45. img_name = "None"
  46. print(" ({}, '{}', {}),".format(d[0], d[1], img_name))
  47. print(" ]")
  48. print()