|
@@ -1,14 +1,14 @@
|
|
|
-from pyray import *
|
|
|
+#from pyray import *
|
|
|
import pyray
|
|
|
|
|
|
for i in dir(pyray):
|
|
|
if i.startswith("draw_"):
|
|
|
print(i)
|
|
|
#exit()
|
|
|
-ConfigFlags(FLAG_MSAA_4X_HINT) #|FLAG_WINDOW_RESIZABLE )
|
|
|
-#ConfigFlags(FLAG_WINDOW_RESIZABLE )
|
|
|
-ConfigFlags(FLAG_WINDOW_HIGHDPI )
|
|
|
-init_window(760, 450, "RAY-DMX")#,10,10,10,10)
|
|
|
+pyray.ConfigFlags(pyray.FLAG_MSAA_4X_HINT) #|FLAG_WINDOW_RESIZABLE )
|
|
|
+#pyray.ConfigFlags(pyray.FLAG_WINDOW_RESIZABLE )
|
|
|
+pyray.ConfigFlags(pyray.FLAG_WINDOW_HIGHDPI )
|
|
|
+pyray.init_window(760, 450, "RAY-DMX")#,10,10,10,10)
|
|
|
#pyray.TextureFilter(font10,1)
|
|
|
|
|
|
import sys
|
|
@@ -17,8 +17,8 @@ import tool.tk_elm as tk_elm
|
|
|
#import tool.sdl_elm as sdl_elm
|
|
|
|
|
|
img = "/opt/LibreLight/Xdesk/icon/scribble.png"
|
|
|
-IMG = load_image(img)
|
|
|
-print(set_window_icon(IMG))
|
|
|
+IMG = pyray.load_image(img)
|
|
|
+print(pyray.set_window_icon(IMG))
|
|
|
|
|
|
import time
|
|
|
import memcache
|
|
@@ -45,22 +45,20 @@ a = "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf"
|
|
|
|
|
|
k=200
|
|
|
a = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"
|
|
|
-font10l = load_font_ex(a, 10, None, 0);
|
|
|
+font10l = pyray.load_font_ex(a, 10, None, 0);
|
|
|
a = "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf"
|
|
|
-font10 = load_font_ex(a, 12, None, 0);
|
|
|
+font10 = pyray.load_font_ex(a, 12, None, 0);
|
|
|
print(dir(font10))
|
|
|
print(font10.baseSize)
|
|
|
##exit()
|
|
|
-font20 = load_font_ex(a, 20, None, 0);
|
|
|
+font20 = pyray.load_font_ex(a, 20, None, 0);
|
|
|
a = "/usr/share/fonts/truetype/freefont/FreeMono.ttf"
|
|
|
a = "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf"
|
|
|
a = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"
|
|
|
-font25 = load_font_ex(a, 25, None, 0);
|
|
|
+font25 = pyray.load_font_ex(a, 25, None, 0);
|
|
|
|
|
|
pyray.TextureFilter(3)
|
|
|
|
|
|
-grid_x = 250
|
|
|
-grid_y = 60
|
|
|
|
|
|
class EVENT():
|
|
|
def __init__(self):
|
|
@@ -92,17 +90,17 @@ class BUTTON():
|
|
|
font_size = font10.baseSize
|
|
|
pos=self.btn.pos
|
|
|
c=[122,122,122,122] #btn.btn2.get_color()
|
|
|
- draw_rectangle(pos[1],pos[0],pos[3],pos[2],c)
|
|
|
+ pyray.draw_rectangle(pos[1],pos[0],pos[3],pos[2],c)
|
|
|
|
|
|
c=self.btn.btn1.get_color()
|
|
|
- draw_rectangle(pos[1]+2,pos[0]+2,pos[3]-4,pos[2]-4,c)
|
|
|
+ pyray.draw_rectangle(pos[1]+2,pos[0]+2,pos[3]-4,pos[2]-4,c)
|
|
|
|
|
|
c=self.btn.btn3.get_color()
|
|
|
- #draw_rectangle(pos[1]+1,pos[0]+1,pos[3]-2,pos[2]-2,c)
|
|
|
- draw_rectangle_lines_ex([pos[1]+1,pos[0]+1,pos[3]-2,pos[2]-2],1,c)
|
|
|
+ #pyray.draw_rectangle(pos[1]+1,pos[0]+1,pos[3]-2,pos[2]-2,c)
|
|
|
+ pyray.draw_rectangle_lines_ex([pos[1]+1,pos[0]+1,pos[3]-2,pos[2]-2],1,c)
|
|
|
|
|
|
x=self.btn.btn1.name
|
|
|
- draw_text_ex(font10,str(x), [pos[1]+4,pos[0]+4], font_size, 0, [0,0,0,255])#YELLOW)#[0,255,0,255]) #YELLOW)
|
|
|
+ pyray.draw_text_ex(font10,str(x), [pos[1]+4,pos[0]+4], font_size, 0, [0,0,0,255])#pyray.YELLOW)#[0,255,0,255]) #pyray.YELLOW)
|
|
|
|
|
|
def event(self,x,y,mouse):
|
|
|
try:
|
|
@@ -162,12 +160,12 @@ def draw_mouse_box(window,pos1,mouse=[None,None,None],color=[128,128,128],text=1
|
|
|
|
|
|
if w > 10 or h > 10:
|
|
|
c=[255,255,255,255]
|
|
|
- draw_rectangle_lines_ex([pos[0],pos[1],w,h],1,c)
|
|
|
+ pyray.draw_rectangle_lines_ex([pos[0],pos[1],w,h],1,c)
|
|
|
font_size = font10l.baseSize
|
|
|
- draw_text_ex(font10l,str(pos1[0])+" "+str(pos1[1]), [pos1[0],pos1[1]-10], font_size, 0, WHITE)
|
|
|
- draw_text_ex(font10l,str(pos2[0])+" "+str(pos2[1]), [pos2[0]+5,pos2[1]+10], font_size, 0, WHITE)
|
|
|
- draw_text_ex(font10l,str(w), [pos2[0]+5+w/2*wd,pos2[1]], font_size, 0, WHITE)
|
|
|
- draw_text_ex(font10l,str(h), [pos2[0]+5,pos2[1]+h/2*hd], font_size, 0, WHITE)
|
|
|
+ pyray.draw_text_ex(font10l,str(pos1[0])+" "+str(pos1[1]), [pos1[0],pos1[1]-10], font_size, 0, pyray.WHITE)
|
|
|
+ pyray.draw_text_ex(font10l,str(pos2[0])+" "+str(pos2[1]), [pos2[0]+5,pos2[1]+10], font_size, 0, pyray.WHITE)
|
|
|
+ pyray.draw_text_ex(font10l,str(w), [pos2[0]+5+w/2*wd,pos2[1]], font_size, 0, pyray.WHITE)
|
|
|
+ pyray.draw_text_ex(font10l,str(h), [pos2[0]+5,pos2[1]+h/2*hd], font_size, 0, pyray.WHITE)
|
|
|
return pos1,pos2
|
|
|
|
|
|
mouse_old=[None,None,None]
|
|
@@ -187,16 +185,112 @@ def check_area(pos,event_pos):
|
|
|
if x and y:
|
|
|
return 1
|
|
|
|
|
|
+def render_spectrum(cur,x,y):
|
|
|
+ xi=0
|
|
|
+ yi=0
|
|
|
+ grid_x = x #250
|
|
|
+ grid_y = y #60
|
|
|
+
|
|
|
+ for i,v in enumerate(range(20)):
|
|
|
+ # COL NUMBER -> 1 2... 20
|
|
|
+ x2 = grid_x+i*25#+xi
|
|
|
+ y2 = grid_y-20 #+yi
|
|
|
+
|
|
|
+ txt=str(i+1)
|
|
|
+ pyray.draw_text_ex(font10,txt, [x2,y2], font_size, 0, [0,255,0,255]) #pyray.YELLOW)
|
|
|
+ i+=1
|
|
|
+ DMX=mc.get(cur)
|
|
|
+ pyray.draw_text_ex(font25,"SRC:{}".format(cur),[grid_x-20,grid_y-50], 25, 0, pyray.VIOLET)
|
|
|
+
|
|
|
+ for i,v in enumerate(DMX):
|
|
|
+ if v:
|
|
|
+ host_list[k][-1] +=1
|
|
|
+ txt = str(v)
|
|
|
+ x2 = grid_x+xi*25
|
|
|
+ y2 = grid_y+yi*15
|
|
|
+ try:
|
|
|
+ pyray.draw_rectangle(x2-2, y2-2,24,13,[255,255,255,int(v)])
|
|
|
+ except:
|
|
|
+ pyray.draw_rectangle(x2-2, y2-2,24,13,[255,2,2,255])
|
|
|
+
|
|
|
+ try:
|
|
|
+ int(v)
|
|
|
+ except:
|
|
|
+ v=0
|
|
|
+
|
|
|
+
|
|
|
+ if int(v) > 100:
|
|
|
+ pyray.draw_text_ex(font10,txt, [x2,y2], font_size, 0, pyray.BLACK)# pyray.VIOLET)
|
|
|
+ else:
|
|
|
+ pyray.draw_text_ex(font10,txt, [x2,y2], font_size, 0, pyray.GRAY)# pyray.VIOLET)
|
|
|
+ xi+=1
|
|
|
+
|
|
|
+ if xi % 20 == 0:
|
|
|
+ txt = str(int(yi*20)+1)
|
|
|
+ pyray.draw_text_ex(font10,txt, [grid_x-30,y2], font_size, 0, pyray.YELLOW)# pyray.VIOLET) # ROEW NR
|
|
|
+
|
|
|
+ xi = 0
|
|
|
+ yi += 1
|
|
|
+ txt = str(int(yi*20)+1)
|
|
|
+ pyray.draw_text_ex(font10,txt, [grid_x-30,y2], font_size, 0, pyray.YELLOW)# pyray.VIOLET) # ROEW NR
|
|
|
+def render_grid(cur,x,y):
|
|
|
+ xi=0
|
|
|
+ yi=0
|
|
|
+ grid_x = x #250
|
|
|
+ grid_y = y #60
|
|
|
+
|
|
|
+ for i,v in enumerate(range(20)):
|
|
|
+ # COL NUMBER -> 1 2... 20
|
|
|
+ x2 = grid_x+i*25#+xi
|
|
|
+ y2 = grid_y-20 #+yi
|
|
|
+
|
|
|
+ txt=str(i+1)
|
|
|
+ pyray.draw_text_ex(font10,txt, [x2,y2], font_size, 0, [0,255,0,255]) #pyray.YELLOW)
|
|
|
+ i+=1
|
|
|
+ DMX=mc.get(cur)
|
|
|
+ pyray.draw_text_ex(font25,"SRC:{}".format(cur),[grid_x-20,grid_y-50], 25, 0, pyray.VIOLET)
|
|
|
+
|
|
|
+ for i,v in enumerate(DMX):
|
|
|
+ if v:
|
|
|
+ host_list[k][-1] +=1
|
|
|
+ txt = str(v)
|
|
|
+ x2 = grid_x+xi*25
|
|
|
+ y2 = grid_y+yi*15
|
|
|
+ try:
|
|
|
+ pyray.draw_rectangle(x2-2, y2-2,24,13,[255,255,255,int(v)])
|
|
|
+ except:
|
|
|
+ pyray.draw_rectangle(x2-2, y2-2,24,13,[255,2,2,255])
|
|
|
+
|
|
|
+ try:
|
|
|
+ int(v)
|
|
|
+ except:
|
|
|
+ v=0
|
|
|
+
|
|
|
+
|
|
|
+ if int(v) > 100:
|
|
|
+ pyray.draw_text_ex(font10,txt, [x2,y2], font_size, 0, pyray.BLACK)# pyray.VIOLET)
|
|
|
+ else:
|
|
|
+ pyray.draw_text_ex(font10,txt, [x2,y2], font_size, 0, pyray.GREY)# pyray.VIOLET)
|
|
|
+ xi+=1
|
|
|
+
|
|
|
+ if xi % 20 == 0:
|
|
|
+ txt = str(int(yi*20)+1)
|
|
|
+ pyray.draw_text_ex(font10,txt, [grid_x-30,y2], font_size, 0, pyray.YELLOW)# pyray.VIOLET) # ROEW NR
|
|
|
+
|
|
|
+ xi = 0
|
|
|
+ yi += 1
|
|
|
+ txt = str(int(yi*20)+1)
|
|
|
+ pyray.draw_text_ex(font10,txt, [grid_x-30,y2], font_size, 0, pyray.YELLOW)# pyray.VIOLET) # ROEW NR
|
|
|
|
|
|
buttons={} #[]
|
|
|
cur = None
|
|
|
+history = []
|
|
|
+while not pyray.window_should_close():
|
|
|
+ pyray.begin_drawing()
|
|
|
|
|
|
-while not window_should_close():
|
|
|
- begin_drawing()
|
|
|
-
|
|
|
- clear_background(BLACK)
|
|
|
- Color(255,0,0,0)
|
|
|
- rl_enable_smooth_lines()
|
|
|
+ pyray.clear_background(pyray.BLACK)
|
|
|
+ pyray.Color(255,0,0,0)
|
|
|
+ pyray.rl_enable_smooth_lines()
|
|
|
|
|
|
|
|
|
|
|
@@ -208,65 +302,23 @@ while not window_should_close():
|
|
|
keys = []
|
|
|
host_list = {}
|
|
|
for k in DATA:
|
|
|
- print(k,DATA[k])
|
|
|
+ #print(k,DATA[k])
|
|
|
#print(k)
|
|
|
keys.append(k)
|
|
|
host_list[k] = DATA[k] #[0]).ljust(" ",18) #,0,"=",0]
|
|
|
keys.sort()
|
|
|
|
|
|
- k=keys[1]
|
|
|
- for i,v in enumerate(range(20)):
|
|
|
- # COL NUMBER -> 1 2... 20
|
|
|
- x2 = grid_x+i*25
|
|
|
- y2 = grid_y-20
|
|
|
-
|
|
|
- txt=str(i+1)
|
|
|
- draw_text_ex(font10,txt, [x2,y2], font_size, 0, [0,255,0,255]) #YELLOW)
|
|
|
- i+=1
|
|
|
+ k=keys[0]
|
|
|
|
|
|
- xi=0
|
|
|
- yi=0
|
|
|
if cur is None:
|
|
|
cur = k #k[3] #"xx123" # k
|
|
|
- DMX=mc.get(cur)
|
|
|
- draw_text_ex(font25,"SRC:{}".format(cur),[grid_x-20,5], 25, 0, VIOLET)
|
|
|
-
|
|
|
- for i,v in enumerate(DMX):
|
|
|
- if v:
|
|
|
- host_list[k][-1] +=1
|
|
|
- txt = str(v)
|
|
|
- x2 = grid_x+xi*25
|
|
|
- y2 = grid_y+yi*15
|
|
|
- try:
|
|
|
- draw_rectangle(x2-2, y2-2,24,13,[255,255,255,int(v)])
|
|
|
- except:
|
|
|
- draw_rectangle(x2-2, y2-2,24,13,[255,2,2,255])
|
|
|
-
|
|
|
- try:
|
|
|
- int(v)
|
|
|
- except:
|
|
|
- v=0
|
|
|
-
|
|
|
-
|
|
|
- if int(v) > 100:
|
|
|
- draw_text_ex(font10,txt, [x2,y2], font_size, 0, BLACK)# VIOLET)
|
|
|
- else:
|
|
|
- draw_text_ex(font10,txt, [x2,y2], font_size, 0, GREY)# VIOLET)
|
|
|
- xi+=1
|
|
|
-
|
|
|
- if xi % 20 == 0:
|
|
|
- txt = str(int(yi*20)+1)
|
|
|
- draw_text_ex(font10,txt, [grid_x-30,y2], font_size, 0, YELLOW)# VIOLET) # ROEW NR
|
|
|
-
|
|
|
- xi = 0
|
|
|
- yi += 1
|
|
|
- txt = str(int(yi*20)+1)
|
|
|
- draw_text_ex(font10,txt, [grid_x-30,y2], font_size, 0, YELLOW)# VIOLET) # ROEW NR
|
|
|
+ #render_grid(cur,250,50)
|
|
|
+ render_spectrum(cur,250,50)
|
|
|
|
|
|
p=0
|
|
|
for k,v in host_list.items():
|
|
|
x2 = 10
|
|
|
- y2 = grid_y+p
|
|
|
+ y2 = 60+p #grid_y+p
|
|
|
v = str(v).replace(" ","").replace("[","").replace("]","")
|
|
|
txt = str(k)+" "+str(v)
|
|
|
|
|
@@ -294,27 +346,25 @@ while not window_should_close():
|
|
|
x=200
|
|
|
y=200
|
|
|
|
|
|
- draw_text_ex(font25,"FPS:{}".format(fps_count),[10,5], 25, 0, VIOLET)
|
|
|
+ pyray.draw_text_ex(font25,"FPS:{}".format(fps_count),[10,5], 25, 0, pyray.VIOLET)
|
|
|
|
|
|
- m=get_mouse_position()
|
|
|
+ m=pyray.get_mouse_position()
|
|
|
#print(m)
|
|
|
if m.x != old_x or m.y != old_y:
|
|
|
old_x = m.x
|
|
|
old_y = m.y
|
|
|
|
|
|
mouse=[None,None,None]
|
|
|
- if is_mouse_button_released(0):
|
|
|
- mouse[0] = "release"
|
|
|
- if is_mouse_button_released(1):
|
|
|
- mouse[1] = "release"
|
|
|
- if is_mouse_button_released(2):
|
|
|
- mouse[2] = "release"
|
|
|
- if is_mouse_button_pressed(0):
|
|
|
- mouse[0] = "press"
|
|
|
- if is_mouse_button_pressed(1):
|
|
|
- mouse[1] = "press"
|
|
|
- if is_mouse_button_pressed(2):
|
|
|
- mouse[2] = "press"
|
|
|
+ mouse_change=0
|
|
|
+ for i in range(3):
|
|
|
+ ev = ""
|
|
|
+ if pyray.is_mouse_button_released(i):
|
|
|
+ ev = "release"
|
|
|
+ if pyray.is_mouse_button_pressed(i):
|
|
|
+ ev = "press"
|
|
|
+ if ev and ev != mouse[i]:
|
|
|
+ mouse[i] = ev
|
|
|
+ mouse_change=1
|
|
|
|
|
|
if mouse != mouse_old and mouse != [None,None,None]:
|
|
|
print(mouse)
|
|
@@ -322,11 +372,12 @@ while not window_should_close():
|
|
|
|
|
|
for k,btn in buttons.items():
|
|
|
btn.event(old_x,old_y,mouse_old)
|
|
|
- if "press" == mouse_old[0]:
|
|
|
+ #if "press" == mouse_old[0]:
|
|
|
+ if "release" == mouse_old[0]:
|
|
|
btn.button = 1
|
|
|
#if check_area(btn.btn.pos,[old_x,old_y]):#event_pos):
|
|
|
if check_area(btn.btn.pos,[old_y,old_x]):#event_pos):
|
|
|
- print(k,btn.btn.pos)
|
|
|
+ #print(k,btn.btn.pos)
|
|
|
#btn.btn.btn1.val.set(255)
|
|
|
#cur = k
|
|
|
cur = k # btn.btn.btn1.name
|
|
@@ -334,14 +385,18 @@ while not window_should_close():
|
|
|
aapos = draw_mouse_box(None,[old_x,old_y],mouse_old,color=[128,128,128],text=1)
|
|
|
|
|
|
|
|
|
- draw_text_ex(font20,"POS:{}:{}".format(int(m.x),int(m.y)),[10,34], 20, 0, VIOLET)
|
|
|
+ pyray.draw_text_ex(font20,"POS:{}:{}".format(int(m.x),int(m.y)),[10,34], 20, 0, pyray.VIOLET)
|
|
|
|
|
|
- draw_rectangle(int(old_x-10),int(old_y-1),20,2,[255,0,255,255])
|
|
|
- draw_rectangle(int(old_x-1),int(old_y-10),2,20,[255,0,255,255])
|
|
|
+ pyray.draw_rectangle(int(old_x-10),int(old_y-1),20,2,[255,0,255,255])
|
|
|
+ pyray.draw_rectangle(int(old_x-1),int(old_y-10),2,20,[255,0,255,255])
|
|
|
|
|
|
- end_drawing()
|
|
|
+ pyray.end_drawing()
|
|
|
time.sleep(1/10)
|
|
|
|
|
|
+ for i,v in enumerate(mouse_old):
|
|
|
+ if v == "release":
|
|
|
+ mouse_old[i] = None
|
|
|
+ print(mouse_old)
|
|
|
frame_count += 1
|
|
|
if time.time()-start > 1:
|
|
|
start = time.time()
|
|
@@ -355,5 +410,5 @@ while not window_should_close():
|
|
|
import traceback
|
|
|
print(traceback.format_exc())
|
|
|
time.sleep(1)
|
|
|
-close_window()
|
|
|
+pyray.close_window()
|
|
|
|