|
@@ -4,6 +4,7 @@ import sys
|
|
|
import _thread as thread
|
|
import _thread as thread
|
|
|
sys.path.insert(0,"/opt/LibreLight/Xdesk/")
|
|
sys.path.insert(0,"/opt/LibreLight/Xdesk/")
|
|
|
|
|
|
|
|
|
|
+from lib.cprint import cprint
|
|
|
|
|
|
|
|
CAPTION = 'RAY-FIX-LIST'
|
|
CAPTION = 'RAY-FIX-LIST'
|
|
|
import tool.movewin as movewin
|
|
import tool.movewin as movewin
|
|
@@ -127,6 +128,11 @@ class BUTTON():
|
|
|
self.font = font14
|
|
self.font = font14
|
|
|
self.val = 0
|
|
self.val = 0
|
|
|
self.btn.btn1.name=txt
|
|
self.btn.btn1.name=txt
|
|
|
|
|
+ if " " in txt:
|
|
|
|
|
+ self.ATTR = txt.split()[0]
|
|
|
|
|
+ else:
|
|
|
|
|
+ self.ATTR = txt
|
|
|
|
|
+ self.FIX_ID = 0
|
|
|
#x=btn.btn1.name
|
|
#x=btn.btn1.name
|
|
|
def __repr__(self):
|
|
def __repr__(self):
|
|
|
return "<BUTTON {} {} {}>".format(id(self),str(self.btn.pos),self.btn.btn1.name)
|
|
return "<BUTTON {} {} {}>".format(id(self),str(self.btn.pos),self.btn.btn1.name)
|
|
@@ -152,45 +158,35 @@ class BUTTON():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- def event(self,x,y,mouse):
|
|
|
|
|
|
|
+ def event(self,x,y,mouse,change):
|
|
|
|
|
+
|
|
|
|
|
+ pos=self.btn.pos
|
|
|
|
|
+ if not check_area(pos,[y,x]):
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
try:
|
|
try:
|
|
|
- buttons = [0,0,0]
|
|
|
|
|
- button = 0
|
|
|
|
|
- PRESS=5 #1025
|
|
|
|
|
- RELEASE=6 #1026
|
|
|
|
|
- _type=0
|
|
|
|
|
- for i in range(3):#2,0,-1):
|
|
|
|
|
- #print(i,mouse)
|
|
|
|
|
- if mouse[i] == "press":
|
|
|
|
|
- _type=PRESS
|
|
|
|
|
- if mouse[i] == "release":
|
|
|
|
|
- _type=RELEASE
|
|
|
|
|
- if mouse[i]:
|
|
|
|
|
- buttons[i] = 1
|
|
|
|
|
- button = i+1
|
|
|
|
|
-
|
|
|
|
|
- xevent.dict={"pos":[y,x],"button":button,"buttons":buttons,"type":_type}
|
|
|
|
|
-
|
|
|
|
|
- #print(xevent.dict)
|
|
|
|
|
- pos=self.btn.pos
|
|
|
|
|
-
|
|
|
|
|
- if check_area(pos,[y,x]):
|
|
|
|
|
- #print("POS:",x,y,mouse,xevent.type)
|
|
|
|
|
- for i,v in enumerate(mouse):
|
|
|
|
|
- if i==0:
|
|
|
|
|
- #if v == "release": # or v == "click":
|
|
|
|
|
- if v == "click": #"press" or v == "click": # or v == "release":
|
|
|
|
|
- self.btn.btn1.type = "toggle"
|
|
|
|
|
- self.btn.btn1.press()
|
|
|
|
|
- #xevent.type=5
|
|
|
|
|
- #xevent.dict["button"] = 1
|
|
|
|
|
- #self.btn.btn1.val.set(0)
|
|
|
|
|
- #xevent.dict["buttons"] = mouse
|
|
|
|
|
- #print(xevent.dict,xevent.type,xevent.button)
|
|
|
|
|
- self.btn.event(xevent)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ #xevent.dict={"pos":[y,x],"button":mouse[:],"buttons":mouse[:],"type":""}
|
|
|
|
|
+
|
|
|
|
|
+ for i,v in enumerate(mouse):
|
|
|
|
|
+ _change=change[i]
|
|
|
|
|
+ if i in [0,1]: #==0:
|
|
|
|
|
+ if v and _change:
|
|
|
|
|
+ cprint("POS:",x,y,mouse,change,color="yellow") #,xevent.dict) #,self)
|
|
|
|
|
+ self.btn.btn1.type = "toggle"
|
|
|
|
|
+ self.btn.btn1.val.set(1)
|
|
|
|
|
+ #self.btn.btn1.press()
|
|
|
|
|
+
|
|
|
|
|
+ if self.FIX_ID:
|
|
|
|
|
+ data = {"event": "FIXTURES", "TYPE": "ENCODERS", "FIX": str(self.FIX_ID), "VAL": "click", "ATTR": self.ATTR}
|
|
|
|
|
+ msg=json.dumps([data]).encode("utf-8")
|
|
|
|
|
+ print("send:",msg)
|
|
|
|
|
+ cmd_client.send(msg)
|
|
|
|
|
+
|
|
|
|
|
+ #self.btn.event(xevent)
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
import traceback
|
|
import traceback
|
|
|
- print(traceback.format_exc())
|
|
|
|
|
|
|
+ cprint(traceback.format_exc(),color="red")
|
|
|
raise e
|
|
raise e
|
|
|
|
|
|
|
|
mouse_box_on = 0
|
|
mouse_box_on = 0
|
|
@@ -237,6 +233,7 @@ def draw_mouse_box(window,pos1,mouse=[None,None,None],color=[128,128,128],text=1
|
|
|
return pos1,pos2
|
|
return pos1,pos2
|
|
|
|
|
|
|
|
mouse_old=[None,None,None]
|
|
mouse_old=[None,None,None]
|
|
|
|
|
+mouse_old_change=[None,None,None]
|
|
|
|
|
|
|
|
def check_area_v(v1,v2,event_v):#elm_pos,event_pos):
|
|
def check_area_v(v1,v2,event_v):#elm_pos,event_pos):
|
|
|
if event_v < v1+1:
|
|
if event_v < v1+1:
|
|
@@ -379,7 +376,7 @@ def load_fix():
|
|
|
#return a,b
|
|
#return a,b
|
|
|
#return _load_fix_keys.copy(), _load_fix_fix_list.copy()
|
|
#return _load_fix_keys.copy(), _load_fix_fix_list.copy()
|
|
|
|
|
|
|
|
- print("load_fix update")
|
|
|
|
|
|
|
+ #print("load_fix update")
|
|
|
_load_fix_last = time.time()
|
|
_load_fix_last = time.time()
|
|
|
_load_fix_init = 1
|
|
_load_fix_init = 1
|
|
|
|
|
|
|
@@ -410,7 +407,7 @@ def loop_load_fix():
|
|
|
load_fix()
|
|
load_fix()
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
- print("EXC loop_load_fix:",e)
|
|
|
|
|
|
|
+ cprint("EXC loop_load_fix:",e,color="red")
|
|
|
|
|
|
|
|
load_fix()
|
|
load_fix()
|
|
|
thread.start_new_thread(loop_load_fix,())
|
|
thread.start_new_thread(loop_load_fix,())
|
|
@@ -479,6 +476,7 @@ def check_buttons(buttons,fix_list):
|
|
|
#print("-",kk,vv)
|
|
#print("-",kk,vv)
|
|
|
txt = kk+" "+str(VAL)
|
|
txt = kk+" "+str(VAL)
|
|
|
btn=BUTTON(None,txt,[ay2,ax2,H,W2])
|
|
btn=BUTTON(None,txt,[ay2,ax2,H,W2])
|
|
|
|
|
+ btn.FIX_ID = k
|
|
|
btn.btn.btn1.color_on = on_color
|
|
btn.btn.btn1.color_on = on_color
|
|
|
|
|
|
|
|
|
|
|
|
@@ -569,14 +567,18 @@ def check_buttons(buttons,fix_list):
|
|
|
if _last_v:
|
|
if _last_v:
|
|
|
print("init.button.ok",_last_v)
|
|
print("init.button.ok",_last_v)
|
|
|
|
|
|
|
|
|
|
+def update_buttons(buttons):
|
|
|
|
|
+ global mouse_old_change
|
|
|
|
|
+ for k,btn in buttons.items():
|
|
|
|
|
+ btn.event(old_x,old_y,mouse_old,mouse_old_change)
|
|
|
|
|
+ mouse_old_change = [0,0,0] # reset mouse change
|
|
|
|
|
+
|
|
|
def draw_buttons(buttons):
|
|
def draw_buttons(buttons):
|
|
|
mh = pyray.get_screen_height()
|
|
mh = pyray.get_screen_height()
|
|
|
for k,btn in buttons.items():
|
|
for k,btn in buttons.items():
|
|
|
- btn.event(old_x,old_y,mouse_old)
|
|
|
|
|
- #print(btn)
|
|
|
|
|
pos = btn.btn.pos
|
|
pos = btn.btn.pos
|
|
|
if pos[0] > (mh-40):
|
|
if pos[0] > (mh-40):
|
|
|
- continue
|
|
|
|
|
|
|
+ continue # out of screan-view-area
|
|
|
btn.draw()
|
|
btn.draw()
|
|
|
|
|
|
|
|
def event_loop():
|
|
def event_loop():
|
|
@@ -586,7 +588,7 @@ def event_loop():
|
|
|
_event_loop()
|
|
_event_loop()
|
|
|
time.sleep(0.0001)
|
|
time.sleep(0.0001)
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
- print("EXC event:",e)
|
|
|
|
|
|
|
+ cprint("EXC event:",e,color="red")
|
|
|
#thread.start_new_thread(event_loop,())
|
|
#thread.start_new_thread(event_loop,())
|
|
|
|
|
|
|
|
old_x = 0
|
|
old_x = 0
|
|
@@ -598,12 +600,13 @@ class _M():
|
|
|
self.y=0
|
|
self.y=0
|
|
|
m = _M() # {"x":0,"y":0}
|
|
m = _M() # {"x":0,"y":0}
|
|
|
MOUSE_BTN = [0,0,0]
|
|
MOUSE_BTN = [0,0,0]
|
|
|
-def _event_loop():
|
|
|
|
|
|
|
+def _event_loop(buttons):
|
|
|
global RUN
|
|
global RUN
|
|
|
global old_x
|
|
global old_x
|
|
|
global old_y
|
|
global old_y
|
|
|
global wheel
|
|
global wheel
|
|
|
global mouse_old
|
|
global mouse_old
|
|
|
|
|
+ global mouse_old_change
|
|
|
global m
|
|
global m
|
|
|
wheel = pyray.get_mouse_wheel_move()
|
|
wheel = pyray.get_mouse_wheel_move()
|
|
|
if wheel:
|
|
if wheel:
|
|
@@ -620,6 +623,7 @@ def _event_loop():
|
|
|
# if "gfwl_" not in i.lower():
|
|
# if "gfwl_" not in i.lower():
|
|
|
# print(i)
|
|
# print(i)
|
|
|
#print(pyray.exit_window_requested())
|
|
#print(pyray.exit_window_requested())
|
|
|
|
|
+
|
|
|
if pyray.window_should_close():
|
|
if pyray.window_should_close():
|
|
|
print("sending QUIT ...")
|
|
print("sending QUIT ...")
|
|
|
pyray.close_window()
|
|
pyray.close_window()
|
|
@@ -636,6 +640,7 @@ def _event_loop():
|
|
|
if not MOUSE_BTN[i]:
|
|
if not MOUSE_BTN[i]:
|
|
|
MOUSE_BTN[i] = 1
|
|
MOUSE_BTN[i] = 1
|
|
|
mouse_change=1
|
|
mouse_change=1
|
|
|
|
|
+ mouse_old_change[i] = 1
|
|
|
#print("mouse",i,v)
|
|
#print("mouse",i,v)
|
|
|
print(time.time(),"mouse",i,MOUSE_BTN)#i,v)
|
|
print(time.time(),"mouse",i,MOUSE_BTN)#i,v)
|
|
|
|
|
|
|
@@ -698,12 +703,16 @@ def _event_loop():
|
|
|
# ================================================
|
|
# ================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
- if mouse != mouse_old and mouse != [None,None,None]:
|
|
|
|
|
- #print(mouse)
|
|
|
|
|
- mouse_old = mouse[:]
|
|
|
|
|
|
|
+ #if mouse != mouse_old: # and mouse != [None,None,None]:
|
|
|
|
|
+ if mouse_change:
|
|
|
|
|
+ #mouse_old = mouse[:]
|
|
|
|
|
+ mouse_old =MOUSE_BTN[:]
|
|
|
|
|
+ #print("TT",mouse)
|
|
|
|
|
|
|
|
check_scrollbar()
|
|
check_scrollbar()
|
|
|
|
|
|
|
|
|
|
+ update_buttons(buttons)
|
|
|
|
|
+
|
|
|
MMM = 1
|
|
MMM = 1
|
|
|
def event_mouse_click():
|
|
def event_mouse_click():
|
|
|
global MMM
|
|
global MMM
|
|
@@ -744,12 +753,21 @@ def check_scrollbar():
|
|
|
#btn.btn.btn1.color_on = [255,255,0,255]
|
|
#btn.btn.btn1.color_on = [255,255,0,255]
|
|
|
buttons[key] = btn
|
|
buttons[key] = btn
|
|
|
btn.btn.btn4.val.set(btn.btn.btn4.val._max*0.4)
|
|
btn.btn.btn4.val.set(btn.btn.btn4.val._max*0.4)
|
|
|
|
|
+
|
|
|
|
|
+ import lib.libtk as libtk
|
|
|
|
|
+ def xhelp(event=None):
|
|
|
|
|
+ #print(event)
|
|
|
|
|
+ libtk.online_help("librelight:20-exec")()
|
|
|
|
|
+ btn.btn.btn1.cb_on.set(xhelp)
|
|
|
try:
|
|
try:
|
|
|
key="scroll-bar"
|
|
key="scroll-bar"
|
|
|
buttons[key].btn.pos[1] = mw-35
|
|
buttons[key].btn.pos[1] = mw-35
|
|
|
buttons[key].btn.pos[2] = mh-75
|
|
buttons[key].btn.pos[2] = mh-75
|
|
|
except:pass
|
|
except:pass
|
|
|
|
|
|
|
|
|
|
+#keys,fix_list = get_fix()
|
|
|
|
|
+#keys,fix_list = get_fix()
|
|
|
|
|
+
|
|
|
while not pyray.window_should_close():
|
|
while not pyray.window_should_close():
|
|
|
if pyray.is_window_resized():
|
|
if pyray.is_window_resized():
|
|
|
print( "RESIZE WINDOW OK")
|
|
print( "RESIZE WINDOW OK")
|
|
@@ -824,7 +842,7 @@ while not pyray.window_should_close():
|
|
|
#print(delta)
|
|
#print(delta)
|
|
|
for t in range(8):
|
|
for t in range(8):
|
|
|
time.sleep(delta/8)
|
|
time.sleep(delta/8)
|
|
|
- _event_loop()
|
|
|
|
|
|
|
+ _event_loop(buttons)
|
|
|
pyray.begin_drawing()
|
|
pyray.begin_drawing()
|
|
|
pyray.end_drawing()
|
|
pyray.end_drawing()
|
|
|
|
|
|
|
@@ -841,9 +859,9 @@ while not pyray.window_should_close():
|
|
|
except KeyboardInterrupt as e:
|
|
except KeyboardInterrupt as e:
|
|
|
raise e
|
|
raise e
|
|
|
except Exception as e:# KeyInterupt
|
|
except Exception as e:# KeyInterupt
|
|
|
- print("err",e)
|
|
|
|
|
|
|
+ cprint("err",e,color="red")
|
|
|
import traceback
|
|
import traceback
|
|
|
- print(traceback.format_exc())
|
|
|
|
|
|
|
+ cprint(traceback.format_exc(),color="red")
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
pyray.close_window()
|
|
pyray.close_window()
|
|
|
|
|
|