Преглед на файлове

refactro: keysym TK-EXEC ctr+s ctr+c ,r,e,c,s,entf,esc

micha преди 8 месеца
родител
ревизия
b77bc6b3ed
променени са 5 файла, в които са добавени 157 реда и са изтрити 126 реда
  1. 29 23
      _LibreLightDesk.py
  2. 5 5
      lib/execlib.py
  3. 73 86
      lib/jsbc.py
  4. 49 9
      tkgui/EXEC.py
  5. 1 3
      tksdl/fix.py

+ 29 - 23
_LibreLightDesk.py

@@ -143,6 +143,13 @@ class Modes():
         elif type(data) is str:
             if data in self.__cfg:
                 return self.__cfg[data]
+    def clear(self,protect=[]):
+        protected = ["BLIND"]
+        protected.extend(protect)
+        for m in self.modes:
+            if m in protected:
+                continue
+            self.modes[m] = 0
 
     def set(self,mode,value):
         protected = ["BLIND","CLEAR","REC-FX"]
@@ -1001,16 +1008,18 @@ class MASTER():
             jclient_send(data)
 
     def button_refresh(self,name,color,color2=None,text="",fg=None):
-        cprint("button_refresh",name,color)
-        try:
-            if color2 is None:
-                color2 = color
-            if text:
-                text = "\n"+str(text)
+        #cprint("button_refresh",name,color)
+
+        if color2 is None:
+            color2 = color
+        if text:
+            text = "\n"+str(text)
 
-            for elem in [self.commands.elem,self.fx.elem,self.fx_main.elem]:#,self.fx_moves]:
+        elem=None
+        for elem in [self.commands.elem,self.fx.elem,self.fx_main.elem,self.fx_moves.elem]:
+            try:
                 if name in elem:
-                    print(" in xx.elem OK ",[name,color,name,text,color2])
+                    #print(" in xx.elem OK ",[name,color,name,text,color2])
                     if name in ["BLIND","CLEAR"] and color == "lightgrey":
                         color = "grey"
                         color2 = "grey"
@@ -1021,19 +1030,9 @@ class MASTER():
                     if fg:
                         elem[name]["fg"] = fg
 
-            # new version
-            for elems in [self.fx_moves]:
-                if name in elems.elem:
-                    print(" in fx_moves_elem OK",name)
-                    elem = elems.elem[name]
-                    cprint("elem",elem)
-                    elem.config(bg = color)
-                    elem.config(text = name+text)
-                    elem.config(activebackground=color2)
-            
-                    if fg and "fg" in elem:
-                        elem["fg"] = fg
-        except Exception as e:cprint("exc",self,e)
+            except Exception as e:
+                cprint(" master.button_refresh",self,e)
+                cprint("  ",elem)
 
     def btn_cfg(self,nr,testing=0):
         cfg    = EXEC._btn_cfg(nr) 
@@ -1110,6 +1109,13 @@ class MASTER():
         dialog._cb= _cb #_x(nr)
         dialog.askstring("LABEL","EXE:"+str(nr+1),initialvalue=txt)
 
+    def button_clear(self):
+        modes.clear()
+        txt=""
+        for m in modes.modes:
+            if not modes.modes[m]:
+                self.button_refresh(m,color="lightgrey",text=txt)
+
     def xcb(self,mode,value=None):
         cprint("  Master.xcb mode:",str(mode).rjust(10," "),value,color="yellow",end="")
         if value:
@@ -1355,9 +1361,9 @@ class MASTER():
         rdata = EXEC.get_raw_map(nr)
         if not rdata:
             return 0
-        cprint("???????")
+        #cprint("???????")
         cfg   = EXEC.get_cfg(nr)
-        cprint("''''''''")
+        #cprint("''''''''")
         #virtcmd  = FIXTURES.get_virtual(rdata)
         if not cfg:
             cprint("NO CFG",cfg,nr)

+ 5 - 5
lib/execlib.py

@@ -198,7 +198,7 @@ class EXEC(): #Presets():
         exec_set_mc(self.label_exec,self.val_exec)
 
     def check_cfg(self,nr=None):
-        cprint("EXEC.check_cfg()",nr)#,color="red")
+        #cprint("EXEC.check_cfg()",nr)#,color="red")
         ok = 0
         if nr is not None:
             if nr in self.val_exec:
@@ -213,12 +213,12 @@ class EXEC(): #Presets():
         return ok
 
     def _check_cfg(self,sdata):
-        cprint("EXEC._check_cfg()")#,color="red")
+        #cprint("EXEC._check_cfg()")#,color="red")
 
         ok = EXEC_CFG_CHECKER(sdata)
 
         if ok:
-            cprint("REPAIR CFG's",ok,sdata["CFG"],color="red")
+            pass#cprint("REPAIR CFG's",ok,"count:",sdata["CFG"],color="red")
         return ok
         
     def backup_exec(self,save_as="",new=0):
@@ -234,7 +234,7 @@ class EXEC(): #Presets():
         
 
     def get_cfg(self,nr):
-        cprint("EXEC.get_cfg()",nr)
+        #cprint("EXEC.get_cfg()",nr)
         self.check_cfg(nr)
         if nr not in self.val_exec:
             cprint("get_cfg",self,"error get_cfg no nr:",nr,color="red")
@@ -290,7 +290,7 @@ class EXEC(): #Presets():
     def get_raw_map(self,nr):
         self.clean(nr)
 
-        cprint("get_raw_map",nr)
+        #cprint("EXEC.get_raw_map",nr)
         sdata = self.val_exec[nr]
         cmd = ""
         out = []

+ 73 - 86
lib/jsbc.py

@@ -3,6 +3,7 @@
 import time
 import traceback
 import json
+import _thread as thread
 
 import __main__ as MAIN
 from lib.cprint import *
@@ -22,63 +23,51 @@ def JSCB(x,sock=None):
             #print(" JSCB",msgs) #,sock)
             if type(msgs) is not list:
                 continue
-
+            
             for msg in msgs:
                 OK = 0
-                #print("  msg",msg)
+                EXEC_REFRESH = 0
+                val     = -1
+                exec_nr = -1
+                fix_nr  = -1
+                attr    = ""
                 if "event" not in msg:
                     continue
+                if "EXEC" in msg:
+                    try:
+                        exec_nr = int(msg["EXEC"])
+                    except:
+                        exec_nr = -2
+                if "VAL" in msg:
+                    val = msg["VAL"]
+                
+                if "FIX" in msg:
+                    fix_nr=msg["FIX"]
+                if "ATTR" in msg:
+                    attr=msg["ATTR"]
 
-                if "FIXTURES" == msg["event"]:
-                    FIX=0
-                    VAL=""
-                    ATTR=""
-                    if "FIX" in msg:
-                        FIX=msg["FIX"]
-                    if "VAL" in msg:
-                        VAL=msg["VAL"]
-                    if "ATTR" in msg:
-                        ATTR=msg["ATTR"]
-                    print("  MAIN.tk_event",FIX,VAL,ATTR)
-                    #cb = MAIN.tk_event(fix=FIX,elem=None,attr=ATTR,mode="ENCODER",data=[]) #data)
-                    fixlib.encoder(MAIN.FIXTURES.fixtures,str(FIX),ATTR,xval=VAL,xfade=0,xdelay=0)#,blind=0)
-
-                    #print(dir(cb))
-                    #event.num = enum
+                print("  MAIN.tk_event","fix:",fix_nr,"exec_nr:",exec_nr,"val:",val,"attr",attr)
 
-                    #cb.cb(event)
+                if "FIXTURES" == msg["event"]:
+                    fixlib.encoder(MAIN.FIXTURES.fixtures,str(fix_nr),attr,xval=val,xfade=0,xdelay=0)#,blind=0)
                     OK = 1
-                if "CLEAR" == msg["event"]:
-                    #MAIN.FIXTURES.clear()
+                elif "CLEAR" == msg["event"]:
                     fixlib.clear(MAIN.FIXTURES.fixtures)
-                    MAIN.modes.val("REC",0)
-                    #MAIN.master.xcb("CLEAR",1)
-                    OK = 1
-                elif "REC" == msg["event"]:
-                    MAIN.modes.val("REC",1)
-                    OK = 1
-                elif "EDIT" == msg["event"]:
-                    MAIN.modes.val("EDIT",1)
-                    OK = 1
-                elif "BLIND" == msg["event"]:
-                    MAIN.modes.val("BLIND",1)
-                    OK = 1
-                elif "FLASH" == msg["event"]:
-                    MAIN.modes.val("FLASH",1)
                     OK = 1
-                elif "CFG-BTN" == msg["event"]:
-                    MAIN.modes.val("CFG-BTN",1)
-                    OK = 1
-                elif "LABEL" == msg["event"]:
-                    MAIN.modes.val("LABEL",1)
+                elif "ESC" == msg["event"]:
+                    fixlib.clear(MAIN.FIXTURES.fixtures)
+                    MAIN.modes.clear() # FIX
+                    MAIN.master.button_clear() # REC,CFG-BTN ...
                     OK = 1
-                elif "REC" == msg["event"]:
-                    MAIN.modes.val("REC",1)
+                elif msg["event"] in ["REC","REC-FX","EDIT","BLIND","FLASH","CFG-BTN","LABEL","MOVE","GO","SELECT","DEL","COPY"]:
+                    if msg["event"] in ["REC-FX"]:
+                        MAIN.modes.clear(protect=["REC-FX","REC",msg["event"]]) # FIX
+                        MAIN.master.button_clear() # REC,CFG-BTN ...
+                    MAIN.modes.val(msg["event"],1)
                     OK = 1
                 elif "FX-OFF" == msg["event"]:
-                    #MAIN.modes.val("FX-OFF",1)
-                    MAIN.CONSOLE.fx_off("all") #"FX-OFF",1)
-                    #OK = 1
+                    MAIN.CONSOLE.fx_off("all") 
+                    OK = 1
                 elif "SAVE\nSHOW" == msg["event"]:
                     MAIN.save_show()
                     OK = 1
@@ -86,54 +75,52 @@ def JSCB(x,sock=None):
                     print("OK OK")
                     MAIN.LOAD_SHOW_AND_RESTART("").cb(force=1)
                     OK = 1
-                elif "REC-FX" == msg["event"]:
-                    MAIN.modes.val("REC-FX",1)
-                    OK = 1
-                elif "REC-EXEC" == msg["event"]:
-                    print("  JSCB.REC-EXEC")
-                    val = -1
-                    exec_nr = -1
-                    try:
-                        if "VAL" in msg:
-                            val = int(msg["VAL"])
-                        if "EXEC" in msg:
-                            exec_nr = int(msg["EXEC"])
-
-                        if val >= 1 and exec_nr > 0: # VAL >=1 !!!
-                            print(" EXEC_GOOO",exec_nr)
-                            s = time.time()
-                            MAIN.master.exec_rec(exec_nr-1)
-                            e = time.time()
-                            print("EXE TIME:","{:0.02f}".format(e-s),int(e*100)/100)
-                            print()
-                            OK = 1
-                    except Exception as e:
-                        print("REC-EXEC ERR:",[e])
-                        raise e
                 elif "EXEC" == msg["event"]:
-                    print("  JSCB.EXEC")
-                    val = -1
-                    exec_nr = -1
+                    print("  JSCB:",msg["event"])
                     try:
-                        if "VAL" in msg:
-                            val = int(msg["VAL"])
-                        if "EXEC" in msg:
-                            exec_nr = int(msg["EXEC"])
-                        if val >= 0 and exec_nr > 0:
-                            print("EXEC_GOOO",exec_nr,val)
-                            s = time.time()
-                            MAIN.master.exec_go(exec_nr-1,xfade=None,val=val)
-                            e = time.time()
-                            print("EXE TIME:","{:0.02f}".format(e-s),int(e*100)/100)
-                            print()
-                            OK = 1
+                        if exec_nr > 0:
+                            if val >= 1: # only Press
+                                pass
+                                if MAIN.modes.val("REC"):
+                                    MAIN.master.exec_rec(exec_nr-1)
+                                    msg["OK"] = "REC"
+                                    EXEC_REFRESH = 1
+                                    OK = 1
+                                elif MAIN.modes.val("COPY"):
+                                    MAIN.EXEC.copy(exec_nr-1)
+                                    msg["OK"] = "COPY"
+                                    if MAIN.modes.val("COPY") > 2:
+                                        MAIN.modes.val("COPY",0)
+                                    EXEC_REFRESH = 1
+                                    OK = 1
+                                elif MAIN.modes.val("MOVE"):
+                                    MAIN.EXEC.move(exec_nr-1)
+                                    msg["OK"] = "MOVE"
+                                    EXEC_REFRESH = 1
+                                    OK = 1
+                                elif MAIN.modes.val("DEL"):
+                                    MAIN.EXEC.delete(exec_nr-1)
+                                    MAIN.modes.val("DEL",0)
+                                    msg["OK"] = "DEL"
+                                    EXEC_REFRESH = 1
+                                    OK = 1
+
+                            if not OK:
+                                if val >= 0: #Press/Release
+                                    MAIN.master.exec_go(exec_nr-1,xfade=None,val=val)
+                                    OK = 1
+                                    EXEC_REFRESH = 1
+
                     except Exception as e:
                         print("EXEC ERR:",e)
+
             
                 if OK:
                     cprint(" remote-key:",msg ,color="green")
-                    if "REC-EXEC" in msg["event"]:
-                        MAIN.execlib.exec_set_mc(MAIN.EXEC.label_exec,MAIN.EXEC.val_exec)
+                    if EXEC_REFRESH:
+                        def xx():
+                            MAIN.execlib.exec_set_mc(MAIN.EXEC.label_exec,MAIN.EXEC.val_exec)
+                        thread.start_new_thread(xx,())
                 else:
                     cprint(" remote-key:",msg ,color="red")
     except Exception as e:

+ 49 - 9
tkgui/EXEC.py

@@ -228,7 +228,7 @@ class Gui(): # DUMMY
             return #STOP
 
         PREFIX = ""
-        for k in ["REC","EDIT"]: #,"DEL","SELECT","FLASH","GO","EDIT"]:
+        for k in []:#:["REC","EDIT","COPY","MOVE","DEL"]: #,"DEL","SELECT","FLASH","GO","EDIT"]:
             if k in modes.modes:
                 PREFIX = str(k) +"-"
                 
@@ -341,27 +341,67 @@ def serialize_event(event):
         data2[k] = data[k] 
     return data2
 
+Control_L = 0
+Alt_L = 0
 def tk_event(event,data={}):
     #print("tk_event",event,data)
+    global Control_L,Alt_L
     if _global_key_lock:
         return
     #print("   ",dir(event)) #.dict())
     data =  serialize_event(event)
 
+    if 'keysym' in data:
+        keysym = data["keysym"]
+        if keysym == 'Control_L':  
+            if "Press" in data["event"]:
+                Control_L = 1
+            if "Release" in data["event"]:
+                Control_L = 1
+        if keysym == 'Alt_L':  
+            if "Press" in data["event"]:
+                Alt_L = 1
+            if "Release" in data["event"]:
+                Alt_L = 1
+
+        data["Alt_L"] = Alt_L
+        data["Control_L"] = Control_L
+        
     print("tk_event",data)
     ok=0
+
+    # CONTROL + KEY
+    key_code = {"s":"SAVE\nSHOW","c":"RESTART" }
     if 'keysym' in data:
-        if data['keysym'] == 'End':
+        keysym = data["keysym"]
+
+        if keysym in key_code:
+            if "Press" in data['event'] and data["Control_L"]:
+                MOD = key_code[keysym]
+                msg=json.dumps([{"event":MOD}]).encode("utf-8")
+                cprint("SEND tk_event",msg,color="green")
+                cmd_client.send(msg)
             ok = 1
-            msg=json.dumps([{"event":"FX-OFF"}]).encode("utf-8")
-            cprint("SEND tk_event",msg,color="green")
-            cmd_client.send(msg)
 
-        if data['keysym'] == 'Escape':
+        if ok:
+            return
+
+    # NORMAL KEY
+    key_code = {"r":"REC","x":"REC-FX","e":"EDIT","c":"CFG-BTN"
+                ,"m":"MOVE","Delete":"DEL","End":"FX-OFF"
+                ,"Escape":"ESC","s":"SELECT","f":"FLASH"
+                ,"C":"COPY","d":"DEL"
+                }
+    if 'keysym' in data:
+        keysym = data["keysym"]
+
+        if keysym in key_code:
+            if "Press" in data['event']:
+                MOD = key_code[keysym]
+                msg=json.dumps([{"event":MOD}]).encode("utf-8")
+                cprint("SEND tk_event",msg,color="green")
+                cmd_client.send(msg)
             ok = 1
-            msg=json.dumps([{"event":"CLEAR"}]).encode("utf-8")
-            cprint("SEND tk_event",msg,color="green")
-            cmd_client.send(msg)
 
     if not ok:
         libtk.tk_keyboard_callback(event,data=data)

+ 1 - 3
tksdl/fix.py

@@ -745,14 +745,12 @@ while 1:
                 if event['scancode'] in [9,41]:
                     for k in table_draw:
                         t = table[k]
-                        #t.btn2.clean()
                         t.btn1.clean()
                     for k in table_grid_draw:
                         t = table_grid[k]
-                        #t.btn2.clean()
                         t.btn1.clean()
 
-                    msg=json.dumps([{"event":"CLEAR"}]).encode("utf-8")
+                    msg=json.dumps([{"event":"ESC"}]).encode("utf-8")
                     print("ESC",msg)
                     cmd_client.send(msg)