|
@@ -33,12 +33,19 @@ fps_count = 0
|
|
#a = "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf"
|
|
#a = "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf"
|
|
a = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"
|
|
a = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"
|
|
a = "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf"
|
|
a = "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf"
|
|
|
|
+a = "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf"
|
|
|
|
+#a = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"
|
|
|
|
|
|
|
|
|
|
k=200
|
|
k=200
|
|
-font10 = load_font_ex(a, 10, None, 0);
|
|
|
|
|
|
+font10 = load_font_ex(a, 12, None, 0);
|
|
|
|
+print(dir(font10))
|
|
|
|
+print(font10.baseSize)
|
|
|
|
+##exit()
|
|
font20 = load_font_ex(a, 20, None, 0);
|
|
font20 = load_font_ex(a, 20, None, 0);
|
|
a = "/usr/share/fonts/truetype/freefont/FreeMono.ttf"
|
|
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 = load_font_ex(a, 25, None, 0);
|
|
|
|
|
|
pyray.TextureFilter(3)
|
|
pyray.TextureFilter(3)
|
|
@@ -46,6 +53,68 @@ pyray.TextureFilter(3)
|
|
grid_x = 250
|
|
grid_x = 250
|
|
grid_y = 60
|
|
grid_y = 60
|
|
|
|
|
|
|
|
+class EVENT():
|
|
|
|
+ def __init__(self):
|
|
|
|
+ self.dict = {}
|
|
|
|
+ self.type = 0
|
|
|
|
+ self.button=0
|
|
|
|
+ self.buttons=[0,0,0,0]
|
|
|
|
+xevent=EVENT()
|
|
|
|
+
|
|
|
|
+class BUTTON():
|
|
|
|
+ def __init__(self,master=None,txt="<BUTTON>",pos=[10,10,20,90]):
|
|
|
|
+ #self.btn = tk_elm.Button(None,pos=[390,12,20,90])
|
|
|
|
+ self.btn = tk_elm.Button(master,pos=pos)
|
|
|
|
+ self.btn.btn1.color = [127,127,127,255]
|
|
|
|
+ #btn.btn1.color_on = [155,155,155,255]
|
|
|
|
+ #btn.btn2.color = [155,55,155,255]
|
|
|
|
+ #btn.btn2.color_on = [155,155,155,255]
|
|
|
|
+ self.btn.btn3.color = [55,155,155,255]
|
|
|
|
+ self.btn.btn3.color_on = [55,255,255,255]
|
|
|
|
+ self.btn.btn2.color_on = [55,255,255,255]
|
|
|
|
+
|
|
|
|
+ self.btn.btn1.name=txt
|
|
|
|
+ #x=btn.btn1.name
|
|
|
|
+
|
|
|
|
+ def draw(self,event=None):
|
|
|
|
+ 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)
|
|
|
|
+
|
|
|
|
+ c=self.btn.btn3.get_color()
|
|
|
|
+ draw_rectangle(pos[1]+1,pos[0]+1,pos[3]-2,pos[2]-2,c)
|
|
|
|
+ c=self.btn.btn1.get_color()
|
|
|
|
+ draw_rectangle(pos[1]+2,pos[0]+2,pos[3]-4,pos[2]-4,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)
|
|
|
|
+
|
|
|
|
+ def event(self,x,y,mouse):
|
|
|
|
+ try:
|
|
|
|
+ #print("POS:",old_x,old_y)
|
|
|
|
+ xevent.dict={"pos":[old_y,old_x],"button":1,"buttons":[0,0,0]}
|
|
|
|
+ xevent.type=3
|
|
|
|
+ for i,v in enumerate(mouse):
|
|
|
|
+ if i==0:
|
|
|
|
+ if v == "release":
|
|
|
|
+ xevent.type=6
|
|
|
|
+ xevent.dict["button"] = 1
|
|
|
|
+ #self.btn.btn1.val.set(0)
|
|
|
|
+ if v == "press":
|
|
|
|
+ xevent.type=5
|
|
|
|
+ xevent.dict["button"] = 1
|
|
|
|
+ #self.btn.btn1.val.set(255)
|
|
|
|
+ xevent.dict["buttons"] = mouse
|
|
|
|
+ #print(xevent.dict,xevent.type,xevent.button)
|
|
|
|
+ self.btn.event(xevent)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ import traceback
|
|
|
|
+ print(traceback.format_exc())
|
|
|
|
+ raise e
|
|
|
|
+
|
|
|
|
+mouse_old=[None,None,None]
|
|
|
|
+
|
|
while not window_should_close():
|
|
while not window_should_close():
|
|
begin_drawing()
|
|
begin_drawing()
|
|
|
|
|
|
@@ -53,19 +122,10 @@ while not window_should_close():
|
|
Color(255,0,0,0)
|
|
Color(255,0,0,0)
|
|
rl_enable_smooth_lines()
|
|
rl_enable_smooth_lines()
|
|
|
|
|
|
- if 10:
|
|
|
|
- btn = tk_elm.Button(None,pos=[390,12])
|
|
|
|
- x=btn.btn1.name
|
|
|
|
- a = btn.pos
|
|
|
|
- draw_text(str(x), 5, a[0] , a[1], YELLOW)# VIOLET)
|
|
|
|
- x=btn.btn2.name
|
|
|
|
|
|
+ buttons=[]
|
|
|
|
|
|
- draw_text(str(x), 5, a[0]+15, a[1], YELLOW)# VIOLET)
|
|
|
|
- x=btn.btn3.name
|
|
|
|
- draw_text(str(x), 5, a[0]+30, a[1], YELLOW)# VIOLET)
|
|
|
|
- x=btn.btn4.name
|
|
|
|
|
|
|
|
- font_size = 10
|
|
|
|
|
|
+ font_size = font10.baseSize
|
|
try:
|
|
try:
|
|
DATA=mc.get("index")#cmd)
|
|
DATA=mc.get("index")#cmd)
|
|
GREY = [122,122,122,255]
|
|
GREY = [122,122,122,255]
|
|
@@ -78,7 +138,7 @@ while not window_should_close():
|
|
host_list[k] = DATA[k] #[0]).ljust(" ",18) #,0,"=",0]
|
|
host_list[k] = DATA[k] #[0]).ljust(" ",18) #,0,"=",0]
|
|
keys.sort()
|
|
keys.sort()
|
|
|
|
|
|
- k=keys[2]
|
|
|
|
|
|
+ k=keys[0]
|
|
for i,v in enumerate(range(20)):
|
|
for i,v in enumerate(range(20)):
|
|
# COL NUMBER -> 1 2... 20
|
|
# COL NUMBER -> 1 2... 20
|
|
x2 = grid_x+i*25
|
|
x2 = grid_x+i*25
|
|
@@ -91,6 +151,7 @@ while not window_should_close():
|
|
xi=0
|
|
xi=0
|
|
yi=0
|
|
yi=0
|
|
DMX=mc.get(k)
|
|
DMX=mc.get(k)
|
|
|
|
+ cur = k
|
|
draw_text_ex(font25,"SRC:{}".format(k),[grid_x-20,5], 25, 0, VIOLET)
|
|
draw_text_ex(font25,"SRC:{}".format(k),[grid_x-20,5], 25, 0, VIOLET)
|
|
|
|
|
|
for i,v in enumerate(DMX):
|
|
for i,v in enumerate(DMX):
|
|
@@ -135,9 +196,16 @@ while not window_should_close():
|
|
x2 = 10
|
|
x2 = 10
|
|
y2 = grid_y+p
|
|
y2 = grid_y+p
|
|
txt =str(k)+" "+str(v).replace(" ","").replace("[","").replace("]","")
|
|
txt =str(k)+" "+str(v).replace(" ","").replace("[","").replace("]","")
|
|
- draw_rectangle(x2-2, y2-2,200,18,[125,125,125,255])
|
|
|
|
- draw_text_ex(font10,txt, [x2,y2], font_size, 0, BLACK) # YELLOW)# VIOLET)
|
|
|
|
- p+=20
|
|
|
|
|
|
+ #draw_rectangle(x2-2, y2-2,200,18,[125,125,125,255])
|
|
|
|
+ #draw_text_ex(font10,txt, [x2,y2], font_size, 0, BLACK) # YELLOW)# VIOLET)
|
|
|
|
+ p+=22
|
|
|
|
+
|
|
|
|
+ btn=BUTTON(None,txt,[y2,x2,20,190])
|
|
|
|
+ #btn.btn.btn1.color = [55,155,155,255]
|
|
|
|
+ btn.btn.btn1.color_on = [255,255,0,255]
|
|
|
|
+ if cur in btn.btn.btn1.name:
|
|
|
|
+ btn.btn.btn1.val.set(255)
|
|
|
|
+ buttons.append(btn)
|
|
|
|
|
|
w=200
|
|
w=200
|
|
h=50
|
|
h=50
|
|
@@ -148,10 +216,34 @@ while not window_should_close():
|
|
draw_text_ex(font25,"FPS:{}".format(fps_count),[10,5], 25, 0, VIOLET)
|
|
draw_text_ex(font25,"FPS:{}".format(fps_count),[10,5], 25, 0, VIOLET)
|
|
|
|
|
|
m=get_mouse_position()
|
|
m=get_mouse_position()
|
|
|
|
+ #print(m)
|
|
if m.x != old_x or m.y != old_y:
|
|
if m.x != old_x or m.y != old_y:
|
|
old_x = m.x
|
|
old_x = m.x
|
|
old_y = m.y
|
|
old_y = m.y
|
|
- print("POS:",m.x,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"
|
|
|
|
+
|
|
|
|
+ if mouse != mouse_old and mouse != [None,None,None]:
|
|
|
|
+ print(mouse)
|
|
|
|
+ mouse_old = mouse[:]
|
|
|
|
+
|
|
|
|
+ for btn in buttons:
|
|
|
|
+ btn.event(old_x,old_y,mouse_old)
|
|
|
|
+ btn.draw()
|
|
|
|
+
|
|
|
|
+
|
|
draw_text_ex(font20,"POS:{}:{}".format(int(m.x),int(m.y)),[10,34], 20, 0, VIOLET)
|
|
draw_text_ex(font20,"POS:{}:{}".format(int(m.x),int(m.y)),[10,34], 20, 0, VIOLET)
|
|
|
|
|
|
draw_rectangle(int(old_x-10),int(old_y-1),20,2,[255,0,255,255])
|
|
draw_rectangle(int(old_x-10),int(old_y-1),20,2,[255,0,255,255])
|
|
@@ -170,6 +262,8 @@ while not window_should_close():
|
|
raise e
|
|
raise e
|
|
except Exception as e:# KeyInterupt
|
|
except Exception as e:# KeyInterupt
|
|
print("err",e)
|
|
print("err",e)
|
|
|
|
+ import traceback
|
|
|
|
+ print(traceback.format_exc())
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
close_window()
|
|
close_window()
|
|
|
|
|