|
@@ -13,68 +13,80 @@ import _thread as thread
|
|
|
import dialog
|
|
|
DIALOG = dialog.Dialog()
|
|
|
|
|
|
-gui=None
|
|
|
GLOBAL_old_btn_nr = -1
|
|
|
-def Dcb(exec_nr): #DAILOG CONFIG CALLBACK
|
|
|
+GLOBAL_mode_on = -1
|
|
|
+
|
|
|
+def refresh_exec_btn(btn_nr):
|
|
|
+ global GLOBAL_old_btn_nr
|
|
|
+ nr2= GLOBAL_old_btn_nr
|
|
|
+ print()
|
|
|
+ print(" refresh_exec_btn:",btn_nr)
|
|
|
+
|
|
|
+ time.sleep(0.5)
|
|
|
+ nr = btn_nr #+1 #-1
|
|
|
+ b = gui.elem_exec[nr]
|
|
|
+
|
|
|
+ print("---")
|
|
|
+ gui._refresh_exec_single(nr,b) #,METAS):
|
|
|
+ if nr2 >= 0 and nr2 != nr:
|
|
|
+ b = gui.elem_exec[nr2]
|
|
|
+ gui._refresh_exec_single(nr2,b) #,METAS):
|
|
|
+
|
|
|
+ GLOBAL_old_btn_nr = nr
|
|
|
+
|
|
|
+gui=None
|
|
|
+def dialog_cfg_open(btn_nr,META):
|
|
|
+ print("META",META)
|
|
|
+ cfg = META["CFG"]
|
|
|
+ label = META["LABEL"]
|
|
|
+ button = cfg["BUTTON"]
|
|
|
+ DIALOG._cb = dialog_cb_cfg(btn_nr+1)
|
|
|
+ DIALOG.ask_exec_config(str(btn_nr+1),button=button,label=label,cfg=cfg)
|
|
|
+ #print("INFO",master.commands.elem)
|
|
|
+
|
|
|
+def dialog_label_open(btn_nr,META):
|
|
|
+ print("META",META)
|
|
|
+ cfg = META["CFG"]
|
|
|
+ label = META["LABEL"]
|
|
|
+ button = cfg["BUTTON"]
|
|
|
+ DIALOG._cb = dialog_cb_label(btn_nr+1)
|
|
|
+ #DIALOG.ask_exec_config(str(btn_nr+1),button=button,label=label,cfg=cfg)
|
|
|
+ DIALOG.askstring("LABEL","LABEL EXE:"+str(btn_nr+1),initialvalue=label)
|
|
|
+ #print("INFO",master.commands.elem)
|
|
|
+
|
|
|
+def dialog_cb_cfg(exec_nr): #DAILOG CONFIG CALLBACK
|
|
|
def _Dcb(*args):
|
|
|
- print("Dcb:",args)
|
|
|
+ print("dialog_cb_cfg:",args)
|
|
|
msg=json.dumps([{"event":"EXEC-CFG","EXEC":exec_nr,"VALUE":255,"DATA":args[0]}]).encode("utf-8")
|
|
|
- cprint("SEND DIALOG.cb",msg,color="green")
|
|
|
+ cprint(" SEND DIALOG.cb",msg,color="green")
|
|
|
cmd_client.send(msg)
|
|
|
- def _X_refresh():
|
|
|
- global GLOBAL_old_btn_nr
|
|
|
- if 1:#REFRESH:
|
|
|
- btn_nr = exec_nr
|
|
|
- time.sleep(1.2)
|
|
|
- print()
|
|
|
- print("CFG CB REFRESH !?",btn_nr)
|
|
|
- nr = btn_nr-1
|
|
|
- b = gui.elem_exec[nr]
|
|
|
-
|
|
|
- gui._refresh_exec_single(nr,b) #,METAS):
|
|
|
- time.sleep(0.2)
|
|
|
- nr2= GLOBAL_old_btn_nr
|
|
|
- if nr2 >= 0 and nr2 != nr:
|
|
|
- gui._refresh_exec_single(nr2,b) #,METAS):
|
|
|
- print("CFG CB2 REFRESH ",nr,nr2)
|
|
|
- if 1:
|
|
|
- GLOBAL_old_btn_nr = nr
|
|
|
- thread.start_new_thread(_X_refresh,())
|
|
|
+
|
|
|
+ thread.start_new_thread(refresh_exec_btn,(exec_nr,))
|
|
|
return _Dcb
|
|
|
|
|
|
-def Dcb_label(exec_nr): #DAILOG CONFIG CALLBACK
|
|
|
+def dialog_cb_label(exec_nr): #DAILOG CONFIG CALLBACK
|
|
|
def _Dcb(*args):
|
|
|
- print("Dcb_label:",args)
|
|
|
+ cprint("dialog_cb_label:",args,"EXEC_NR:",exec_nr)
|
|
|
+ if not args:
|
|
|
+ cprint(" dialog_cb args_error !",color="red")
|
|
|
+ return
|
|
|
+ if args[0] is None:
|
|
|
+ cprint(" dialog_cb cancel !",color="red")
|
|
|
+ return
|
|
|
if "Value" in args[0]:
|
|
|
DATA = {"Label":args[0]["Value"]}
|
|
|
- #msg=json.dumps([{"event":"LABEL","EXEC":exec_nr,"VALUE":255,"DATA":args[0]}]).encode("utf-8")
|
|
|
+
|
|
|
msg=json.dumps([{"event":"EXEC-LABEL","EXEC":exec_nr,"VALUE":255,"DATA":DATA}]).encode("utf-8")
|
|
|
- cprint("SEND DIALOG.cb",msg,color="green")
|
|
|
- cmd_client.send(msg)
|
|
|
+ cprint(" SEND DIALOG.cb",msg,color="green")
|
|
|
+ cmd_client.send(msg) # send new meta-data
|
|
|
+
|
|
|
msg=json.dumps([{"event":"LABEL","EXEC":exec_nr,"VALUE":255,"DATA":{}}]).encode("utf-8")
|
|
|
- cmd_client.send(msg)
|
|
|
- def _X_refresh():
|
|
|
- global GLOBAL_old_btn_nr
|
|
|
- if 1:#REFRESH:
|
|
|
- btn_nr = exec_nr
|
|
|
- time.sleep(1.2)
|
|
|
- print()
|
|
|
- print("CFG CB REFRESH !?",btn_nr)
|
|
|
- nr = btn_nr-1
|
|
|
- b = gui.elem_exec[nr]
|
|
|
-
|
|
|
- gui._refresh_exec_single(nr,b) #,METAS):
|
|
|
- time.sleep(0.2)
|
|
|
- nr2= GLOBAL_old_btn_nr
|
|
|
- if nr2 >= 0 and nr2 != nr:
|
|
|
- gui._refresh_exec_single(nr2,b) #,METAS):
|
|
|
- print("CFG CB2 REFRESH ",nr,nr2)
|
|
|
- if 1:
|
|
|
- GLOBAL_old_btn_nr = nr
|
|
|
- thread.start_new_thread(_X_refresh,())
|
|
|
+ cmd_client.send(msg) # diable LABEL mode
|
|
|
+
|
|
|
+ thread.start_new_thread(refresh_exec_btn,(exec_nr,))
|
|
|
return _Dcb
|
|
|
|
|
|
-DIALOG._cb = Dcb(-3)
|
|
|
+DIALOG._cb = dialog_cb_cfg(-3)
|
|
|
#d = dialog.Dialog()
|
|
|
#d.ask_exec_config(str(nr+1),button=button,label=label,cfg=cfg)
|
|
|
|
|
@@ -254,20 +266,23 @@ class Gui(): # DUMMY
|
|
|
for i in range(512):
|
|
|
self.METAS.append({})
|
|
|
|
|
|
+ def _load_meta(self,nr):
|
|
|
+ data = {}
|
|
|
+ try:
|
|
|
+ data = mc.get("EXEC-META-"+str(nr))
|
|
|
+ data = json.loads(data)
|
|
|
+ except Exception as e:
|
|
|
+ print(" ER1R mc...",e)
|
|
|
+ return data
|
|
|
+
|
|
|
def _refresh_exec(self,*arg,**args):
|
|
|
#print("EXEC_Gui._refresh_exec",arg,args)
|
|
|
-
|
|
|
- nr = 14-1
|
|
|
+ start = time.time()
|
|
|
|
|
|
METAS = []
|
|
|
for i in range(512):
|
|
|
nr = i #+1
|
|
|
- try:
|
|
|
- data = mc.get("EXEC-META-"+str(nr)) #,json.dumps(index))
|
|
|
- data = json.loads(data)
|
|
|
- METAS.append(data)
|
|
|
- except Exception as e:
|
|
|
- print(" ER1R mc...",e)
|
|
|
+ METAS.append( self._load_meta(nr) )
|
|
|
|
|
|
self.METAS = METAS
|
|
|
|
|
@@ -275,94 +290,104 @@ class Gui(): # DUMMY
|
|
|
self._refresh_exec_single(nr,b,METAS)
|
|
|
#time.sleep(0.001)
|
|
|
|
|
|
+ print( "refres_exec:",time.time()-start )
|
|
|
+
|
|
|
def _refresh_exec_single(self,nr,b,METAS=None):
|
|
|
- if not METAS:
|
|
|
- try:
|
|
|
- data = mc.get("EXEC-META-"+str(nr)) #,json.dumps(index))
|
|
|
- data = json.loads(data)
|
|
|
- self.METAS[nr] = data #.append(data)
|
|
|
- print(time.time())
|
|
|
- print(" _REFRESH_EXEC_SINGLE",nr,b,data)
|
|
|
- except Exception as e:
|
|
|
- print(" ER1R mc...",e)
|
|
|
-
|
|
|
- METAS = self.METAS
|
|
|
- _bg = "grey"
|
|
|
- _ba = "grey"
|
|
|
- _bg = "grey"
|
|
|
- _fg = "#555" #darkgrey"
|
|
|
- _text = "0 N/V 0\n N/V"
|
|
|
-
|
|
|
- txt = "None/nNone"
|
|
|
- txt1 = "None/nNone"
|
|
|
-
|
|
|
- out = {} # default
|
|
|
- out["fx"] = ""
|
|
|
- out["bg"] = _bg # "grey"
|
|
|
- out["ba"] = _ba #"grey"
|
|
|
- out["fg"] = _fg
|
|
|
- out["text"] = _text #"? "+str(nr+1)
|
|
|
-
|
|
|
- META = {'LABEL': 'ERR', 'CFG': {}}
|
|
|
- META["CFG"] = {'FADE': 3.0, 'DEALY': 0, 'DELAY': 4.0, 'BUTTON': 'ON', 'HTP-MASTER': 100
|
|
|
- ,'SIZE-MASTER': 100, 'SPEED-MASTER': 100, 'OFFSET-MASTER': 100, 'OUT-FADE': 10.0
|
|
|
- ,'FIX-COUNT':0 ,'HAVE-FX':0,'HAVE-VAL':0
|
|
|
- }
|
|
|
-
|
|
|
- try:
|
|
|
- META = METAS[nr]
|
|
|
- label = "{} {} {}\n{}".format(nr+1,META["CFG"]["BUTTON"],META["CFG"]["FIX-COUNT"],META["LABEL"])
|
|
|
- out["text"] = str(label)
|
|
|
+ start = time.time()
|
|
|
+ no_meta = 0
|
|
|
|
|
|
- except Exception as e:
|
|
|
- print(" ER4R",e,nr)
|
|
|
- time.sleep(0.001)
|
|
|
+ if not METAS:
|
|
|
+ no_meta = 1
|
|
|
try:
|
|
|
- txt1 = META["CFG"]["BUTTON"]
|
|
|
- except:
|
|
|
- pass
|
|
|
+ data = mc.get("EXEC-META-"+str(nr)) #,json.dumps(index))
|
|
|
+ data = json.loads(data)
|
|
|
+ self.METAS[nr] = data #.append(data)
|
|
|
+ #print(time.time())
|
|
|
+ print(" _REFRESH_EXEC_SINGLE",nr,b,data["LABEL"])
|
|
|
+ except Exception as e:
|
|
|
+ print(" ER1R mc...",e)
|
|
|
|
|
|
- if META["CFG"]["FIX-COUNT"]:
|
|
|
+ METAS = self.METAS
|
|
|
+ _bg = "grey"
|
|
|
+ _ba = "grey"
|
|
|
+ _bg = "grey"
|
|
|
+ _fg = "#555" #darkgrey"
|
|
|
+ _text = "0 N/V 0\n N/V"
|
|
|
+
|
|
|
+ txt = "None/nNone"
|
|
|
+ txt1 = "None/nNone"
|
|
|
+
|
|
|
+ out = {} # default
|
|
|
+ out["fx"] = ""
|
|
|
+ out["bg"] = _bg # "grey"
|
|
|
+ out["ba"] = _ba #"grey"
|
|
|
+ out["fg"] = _fg
|
|
|
+ out["text"] = _text #"? "+str(nr+1)
|
|
|
+
|
|
|
+ META = {'LABEL': 'ERR', 'CFG': {}}
|
|
|
+ META["CFG"] = {'FADE': 3.0, 'DEALY': 0, 'DELAY': 4.0, 'BUTTON': 'ON', 'HTP-MASTER': 100
|
|
|
+ ,'SIZE-MASTER': 100, 'SPEED-MASTER': 100, 'OFFSET-MASTER': 100, 'OUT-FADE': 10.0
|
|
|
+ ,'FIX-COUNT':0 ,'HAVE-FX':0,'HAVE-VAL':0
|
|
|
+ }
|
|
|
+
|
|
|
+ try:
|
|
|
+ META = METAS[nr]
|
|
|
+ label = "{} {} {}\n{}".format(nr+1,META["CFG"]["BUTTON"],META["CFG"]["FIX-COUNT"],META["LABEL"])
|
|
|
+ out["text"] = str(label)
|
|
|
+ if no_meta:
|
|
|
+ print(" no_meta:",[label])
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ print(" ER4R",e,nr)
|
|
|
+ time.sleep(0.001)
|
|
|
+ try:
|
|
|
+ txt1 = META["CFG"]["BUTTON"]
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+ if META["CFG"]["FIX-COUNT"]:
|
|
|
+ _fg = "black"
|
|
|
+
|
|
|
+ if META["CFG"]["HAVE-VAL"]:
|
|
|
+ _fg = "black"
|
|
|
+ _bg = "yellow"
|
|
|
+ _ba = "#ffaa55"
|
|
|
+ if "SEL" in txt1:
|
|
|
+ #_bg = "blue"
|
|
|
+ #_fg = "blue"
|
|
|
+ _bg = "gold"
|
|
|
+ _bg = "#77f"
|
|
|
+ elif "ON" in txt1:
|
|
|
+ _bg = "gold"
|
|
|
+ _fg = "#040"
|
|
|
_fg = "black"
|
|
|
-
|
|
|
- if META["CFG"]["HAVE-VAL"]:
|
|
|
+ elif "GO" in txt1:
|
|
|
+ _bg = "gold"
|
|
|
+ _fg = "#555"
|
|
|
_fg = "black"
|
|
|
- _bg = "yellow"
|
|
|
- _ba = "#ffaa55"
|
|
|
- if "SEL" in txt1:
|
|
|
- #_bg = "blue"
|
|
|
- #_fg = "blue"
|
|
|
- _bg = "gold"
|
|
|
- _bg = "#77f"
|
|
|
- elif "ON" in txt1:
|
|
|
- _bg = "gold"
|
|
|
- _fg = "#040"
|
|
|
- _fg = "black"
|
|
|
- elif "GO" in txt1:
|
|
|
- _bg = "gold"
|
|
|
- _fg = "#555"
|
|
|
- _fg = "black"
|
|
|
- elif "FL" in txt1:
|
|
|
- _bg = "gold"
|
|
|
-
|
|
|
- out["fx"] = ""
|
|
|
- if META["CFG"]["HAVE-FX"] >= 1:
|
|
|
- out["fx"] = META["CFG"]["HAVE-FX"] # show FX on EXEC-BTN
|
|
|
-
|
|
|
- if META["CFG"]["HAVE-FX"] >= 1 and META["CFG"]["HAVE-VAL"] == 0:
|
|
|
- _bg = "cyan"
|
|
|
-
|
|
|
- if "FL" in txt1:
|
|
|
- _fg = "#00e"
|
|
|
-
|
|
|
- out["fg"] = _fg #= "#00e"
|
|
|
- out["bg"] = _bg #= "#00e"
|
|
|
- cfg = out
|
|
|
-
|
|
|
- self.elem_meta[nr] = META
|
|
|
+ elif "FL" in txt1:
|
|
|
+ _bg = "gold"
|
|
|
+
|
|
|
+ out["fx"] = ""
|
|
|
+ if META["CFG"]["HAVE-FX"] >= 1:
|
|
|
+ out["fx"] = META["CFG"]["HAVE-FX"] # show FX on EXEC-BTN
|
|
|
+
|
|
|
+ if META["CFG"]["HAVE-FX"] >= 1 and META["CFG"]["HAVE-VAL"] == 0:
|
|
|
+ _bg = "cyan"
|
|
|
|
|
|
- b = self.elem_exec[nr]
|
|
|
- b.configure(fg=cfg["fg"],bg=cfg["bg"],activebackground=cfg["ba"],text=cfg["text"],fx=cfg["fx"])
|
|
|
+ if "FL" in txt1:
|
|
|
+ _fg = "#00e"
|
|
|
+
|
|
|
+ out["fg"] = _fg #= "#00e"
|
|
|
+ out["bg"] = _bg #= "#00e"
|
|
|
+ cfg = out
|
|
|
+
|
|
|
+ self.elem_meta[nr] = META
|
|
|
+ #print(" -",nr, round(time.time()-start,4))
|
|
|
+
|
|
|
+ b = self.elem_exec[nr]
|
|
|
+ b.configure(fg=cfg["fg"],bg=cfg["bg"],activebackground=cfg["ba"],text=cfg["text"],fx=cfg["fx"])
|
|
|
+ #print(" -",nr, round(time.time()-start,4))
|
|
|
|
|
|
def exec_go(self,*arg,**args):
|
|
|
print("Gui.exec_go",arg,args)
|
|
@@ -375,14 +400,7 @@ class Gui(): # DUMMY
|
|
|
|
|
|
if v:
|
|
|
META = self.elem_meta[btn_nr]
|
|
|
- print("META",META)
|
|
|
- cfg = META["CFG"]
|
|
|
- label = META["LABEL"]
|
|
|
- button = cfg["BUTTON"]
|
|
|
- DIALOG._cb = Dcb(btn_nr+1)
|
|
|
- DIALOG.ask_exec_config(str(btn_nr+1),button=button,label=label,cfg=cfg)
|
|
|
- #print("INFO",master.commands.elem)
|
|
|
-
|
|
|
+ dialog_cfg_open(btn_nr,META)
|
|
|
return #STOP
|
|
|
|
|
|
if "LABEL" in modes.modes:
|
|
@@ -391,32 +409,20 @@ class Gui(): # DUMMY
|
|
|
|
|
|
if v:
|
|
|
META = self.elem_meta[btn_nr]
|
|
|
- print("META",META)
|
|
|
- cfg = META["CFG"]
|
|
|
- label = META["LABEL"]
|
|
|
- button = cfg["BUTTON"]
|
|
|
- DIALOG._cb = Dcb_label(btn_nr+1)
|
|
|
- #DIALOG.ask_exec_config(str(btn_nr+1),button=button,label=label,cfg=cfg)
|
|
|
- DIALOG.askstring("LABEL","LABEL EXE:"+str(btn_nr+1),initialvalue=label)
|
|
|
- #print("INFO",master.commands.elem)
|
|
|
-
|
|
|
+ dialog_label_open(btn_nr,META)
|
|
|
return #STOP
|
|
|
|
|
|
- PREFIX = ""
|
|
|
- REFRESH = 0
|
|
|
- for k in ["REC","EDIT","COPY","MOVE","DEL","REC-FX"]:#,"SELECT","FLASH","GO","EDIT"]:
|
|
|
- if k in modes.modes:
|
|
|
- PREFIX = str(k) #+"-"
|
|
|
-
|
|
|
- for k in ["REC","COPY","MOVE","DEL","REC-FX"]:
|
|
|
- if k in modes.modes:
|
|
|
- REFRESH = 1
|
|
|
+ #REFRESH = 0
|
|
|
+ #for k in ["REC","COPY","MOVE","DEL","REC-FX","LABEL"]:
|
|
|
+ # if k in modes.modes:
|
|
|
+ # REFRESH = 1
|
|
|
|
|
|
print(" ",[arg,args])
|
|
|
edata={}
|
|
|
if "event" in args:
|
|
|
edata = libtk2.serialize_event(args["event"])
|
|
|
print(" ",edata)
|
|
|
+
|
|
|
num = -1
|
|
|
MOUSE = ""
|
|
|
out={"event": "EXEC","EXEC":btn_nr+1,"VAL":v,"NR-KEY":btn_nr}
|
|
@@ -433,32 +439,8 @@ class Gui(): # DUMMY
|
|
|
cmd_client.send(msg)
|
|
|
cprint("SEND GUI.EXEC_GO",msg,color="green")
|
|
|
|
|
|
-
|
|
|
- def _X_refresh():
|
|
|
- #if 1:#REFRESH:
|
|
|
- time.sleep(0.2)
|
|
|
- print()
|
|
|
- print("REC REFRESH !?",PREFIX)
|
|
|
- nr = btn_nr
|
|
|
- b = self.elem_exec[nr]
|
|
|
-
|
|
|
- refresh_both = 0
|
|
|
- if self.old_btn_nr >= 0 and self.old_btn_nr != nr:
|
|
|
- self.old_btn_nr = nr
|
|
|
- refresh_both = 1
|
|
|
-
|
|
|
- time.sleep(0.4)
|
|
|
- self._refresh_exec_single(nr,b) #,METAS):
|
|
|
- time.sleep(0.4)
|
|
|
- if refresh_both:
|
|
|
- self._refresh_exec_single(self.old_btn_nr,b) #,METAS):
|
|
|
-
|
|
|
- time.sleep(2.)
|
|
|
- self._refresh_exec_single(nr,b) #,METAS):
|
|
|
- if refresh_both:
|
|
|
- self._refresh_exec_single(self.old_btn_nr,b) #,METAS):
|
|
|
-
|
|
|
- thread.start_new_thread(_X_refresh,())
|
|
|
+ if v == 0: # release btn
|
|
|
+ thread.start_new_thread(refresh_exec_btn,(btn_nr,))
|
|
|
|
|
|
gui = Gui()
|
|
|
|
|
@@ -540,7 +522,7 @@ def _refr_loop():
|
|
|
time.sleep(3)
|
|
|
while 1:
|
|
|
gui._refresh_exec()
|
|
|
- time.sleep(10)
|
|
|
+ time.sleep(3)
|
|
|
|
|
|
thread.start_new_thread(_refr_loop,())
|
|
|
|