dmx.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. from pyray import *
  2. init_window(800, 450, "RAY-DMX")
  3. import time
  4. import memcache
  5. mc = memcache.Client(['127.0.0.1:11211'], debug=0)
  6. #x=mc.get(k)
  7. old_x = -10
  8. old_y = -10
  9. while not window_should_close():
  10. try:
  11. y=mc.get("index")#cmd)
  12. begin_drawing()
  13. clear_background(BLACK)
  14. GREY = [122,122,122,255]
  15. p=0
  16. keys = []
  17. for k in y:
  18. keys.append(k)
  19. keys.sort()
  20. k=keys[2]
  21. xi=0
  22. yi=0
  23. for i,v in enumerate(range(20+1)):
  24. txt=str(i+1)
  25. draw_text(txt, 180+xi*30, 5+yi*13, 11, YELLOW)# VIOLET)
  26. xi+=1
  27. if xi % 20 == 0:
  28. break
  29. xi=0
  30. yi=0
  31. #draw_text(str(1), 170+xi*30, 5+yi*13, 11, YELLOW)# VIOLET)
  32. for i,v in enumerate(mc.get(k)):
  33. #print(i,v)
  34. txt = str(i)+":"+str(v)
  35. txt = str(v)
  36. x2 = 180+xi*30
  37. y2 = 25+yi*13
  38. try:
  39. draw_rectangle(x2-2, y2-2,24,13,[255,255,255,int(v)])
  40. except:
  41. draw_rectangle(x2-2, y2-2,24,13,[255,2,2,255])
  42. try:
  43. int(v)
  44. except:
  45. v=0
  46. if int(v) > 100:
  47. draw_text(txt, x2, y2, 11, BLACK)# VIOLET)
  48. else:
  49. draw_text(txt, x2, y2, 11, GREY)# VIOLET)
  50. xi+=1
  51. if xi % 20 == 0:
  52. #for o in FontType:
  53. # print(o)
  54. ##exit()
  55. #draw_texture_pro(FontType.FONT_DEFAULT,"hi",[10,10],[0,0],0,10)
  56. #draw_text_pro(font: Font, text: str, position: Vector2, origin: Vector2, rotation: float, fontSize: float, spacing: float, tint: Color)
  57. draw_text(str(int(yi*20)+1), 170-30, y2, 11, YELLOW)# VIOLET)
  58. xi = 0
  59. yi += 1
  60. draw_text(str(int(yi*20)+1), 170-30, y2, 11, YELLOW)# VIOLET)
  61. p=0
  62. for k in keys:
  63. #print(k)
  64. txt =":"+str(k)
  65. draw_text(txt, 10, 20+p, 20, GREY)# VIOLET)
  66. p+=20
  67. x=100
  68. y=100
  69. w=200
  70. h=50
  71. #draw_rectangle(x, y,w,h,[255,0,20,255])
  72. x=200
  73. y=200
  74. #draw_rectangle_lines(x,y,w,h,[255,200,20,255])
  75. #for i in MouseButton:
  76. # if is_key_down(i):
  77. # print(i)
  78. #for i in range(0,512):
  79. # if is_key_down(i):
  80. # print(i)
  81. #draw_text("Hello world", 190, 200, 20, VIOLET)
  82. #Color(255,0,0,0)
  83. m=get_mouse_position()
  84. if m.x != old_x or m.y != old_y:
  85. old_x = m.x
  86. old_y = m.y
  87. print(m.x,m.y)
  88. draw_rectangle(int(old_x-10),int(old_y-1),20,2,[255,0,255,255])
  89. draw_rectangle(int(old_x-1),int(old_y-10),2,20,[255,0,255,255])
  90. end_drawing()
  91. time.sleep(0.1)
  92. except KeyboardInterrupt as e:
  93. raise e
  94. except Exception as e:# KeyInterupt
  95. print("err",e)
  96. time.sleep(1)
  97. #raise e
  98. close_window()