瀏覽代碼

add: "S" selection in fixture sheet

micha 2 年之前
父節點
當前提交
6d95c81c83
共有 3 個文件被更改,包括 146 次插入74 次删除
  1. 55 28
      _LibreLightDesk.py
  2. 86 43
      tkgui/GUI.py
  3. 5 3
      tkgui/draw.py

+ 55 - 28
_LibreLightDesk.py

@@ -394,7 +394,8 @@ def jclient_send(data):
                         jdata["DMX-FINE"] = FIXTURES.get_dmx(fix,attr+"-FINE")
                     jdatas.append(jdata)
                 else:
-                    cprint("jclient_send, ignore DMX ",jdata["DMX"],color="red")
+                    cprint("jclient_send, ignore DMX ",color="red")
+                    cprint("-- ",jdata,color="red")
             except Exception as e:
                 cprint("jclient_send, Exception DMX ",color="red")
                 cprint("",jdata,color="red")
@@ -2215,34 +2216,44 @@ class MASTER():
             sdata = FIXTURES.fixtures[fix]                            
             _c_a = 0
             for attr in sdata["ATTRIBUT"]:
-                if "FINE" in attr:
+                #if attr.startswith("_"):
+                #    continue
+                if attr.endswith("-FINE"):
                     continue
+
                 v2 = sdata["ATTRIBUT"][attr]["VALUE"]
                 if fix in self.elem_attr:
-                    
-                    elem = self.elem_attr[fix][attr]
-                    #print( attr,v2)
-                    elem["text"] = "{} {:0.2f}".format(attr,v2)
-                    if sdata["ATTRIBUT"][attr]["ACTIVE"]:
-                        elem["bg"] = "yellow"
-                        elem.config(activebackground="yellow")
-                        if "DIM" in sdata["ATTRIBUT"] and len(sdata["ATTRIBUT"]) == 1:
-                            c_d+=1
-                        else:
-                            _c_a += 1
-                    else:
-                        elem["bg"] = "grey"
-                        elem.config(activebackground="grey")
-
-                    if "FX2" not in sdata["ATTRIBUT"][attr]: # insert FX2 excetption
-                        sdata["ATTRIBUT"][attr]["FX2"] = OrderedDict()
-                        
-                    if sdata["ATTRIBUT"][attr]["FX"]:
-                        elem["fg"] = "blue"
-                    elif sdata["ATTRIBUT"][attr]["FX2"]:
-                        elem["fg"] = "red"
+                    b_attr = attr
+                    if b_attr == "_ACTIVE":
+                        b_attr = "S"
+                    if b_attr in self.elem_attr[fix]:
+                        elem = self.elem_attr[fix][b_attr]
+                        #print( "::::",attr,v2,elem)
+                        if elem:
+                            if not attr.startswith("_"):
+                                elem["text"] = "{} {:0.2f}".format(attr,v2)
+                            if sdata["ATTRIBUT"][attr]["ACTIVE"]:
+                                elem["bg"] = "yellow"
+                                elem.config(activebackground="yellow")
+                                if "DIM" in sdata["ATTRIBUT"] and len(sdata["ATTRIBUT"]) == 1:
+                                    c_d+=1
+                                else:
+                                    _c_a += 1
+                            else:
+                                elem["bg"] = "grey"
+                                elem.config(activebackground="grey")
+
+                            if "FX2" not in sdata["ATTRIBUT"][attr]: # insert FX2 excetption
+                                sdata["ATTRIBUT"][attr]["FX2"] = OrderedDict()
+                                
+                            if sdata["ATTRIBUT"][attr]["FX"]:
+                                elem["fg"] = "blue"
+                            elif sdata["ATTRIBUT"][attr]["FX2"]:
+                                elem["fg"] = "red"
+                            else:
+                                elem["fg"] = "black"
                     else:
-                        elem["fg"] = "black"
+                        print( ":::;",attr,v2,elem)
             c_a += _c_a
             if _c_a>0:
                 c_f +=1
@@ -2301,7 +2312,8 @@ class MASTER():
                     if attr in self.elem_attr[fix]:
                         elem = self.elem_attr[fix][attr]
                         FIXTURES.fixtures[fix]["ATTRIBUT"][attr]["ACTIVE"] = 1
-                        elem["bg"] = "yellow"
+                        FIXTURES.fixtures[fix]["ATTRIBUT"]["_ACTIVE"]["ACTIVE"] = 1
+                        #elem["bg"] = "yellow"
 
     def preset_go(self,nr,val=None,xfade=None,event=None,button="",ptfade=None):
         t_start = time.time()
@@ -2754,6 +2766,11 @@ class Fixtures():
             sdata = new_f
             if "ACTIVE" not in sdata:
                 sdata["ACTIVE"] = 0
+            sdata["ATTRIBUT"]["_ACTIVE"] = OrderedDict()
+            sdata["ATTRIBUT"]["_ACTIVE"]["NR"] = 0
+            sdata["ATTRIBUT"]["_ACTIVE"]["ACTIVE"] = 1
+            sdata["ATTRIBUT"]["_ACTIVE"]["VALUE"] = 0
+
             for attr in sdata["ATTRIBUT"]:
                 sdata["ATTRIBUT"][attr]["ACTIVE"] = 0
             #print("load",filename,sdata)
@@ -3026,6 +3043,7 @@ class Fixtures():
         out = {} 
         if change:
             data["ATTRIBUT"][attr]["ACTIVE"] = 1
+            data["ATTRIBUT"]["_ACTIVE"]["ACTIVE"] = 1
             data["ATTRIBUT"][attr]["VALUE"] = round(v2,4)
 
             jdata["FADE"] = 0
@@ -3075,6 +3093,8 @@ class Fixtures():
                         sdata[fix][attr]["FX2"] = data["ATTRIBUT"][attr]["FX2"] 
     
         return sdata
+    def get_active2(self):
+        pass
 
     def _deselect_all(self,fix=None):
         cprint("FIXTURES._deselect_all()",fix,"ALL",color="yellow")
@@ -3105,7 +3125,8 @@ class Fixtures():
                 if mode == "toggle":
                     c+=self.select(fix,attr,mode="on",mute=mute)
                 elif mode == "swap":
-                    c+=self.select(fix,attr,mode="toggle",mute=mute)
+                    if not attr.startswith("_"):
+                        c+=self.select(fix,attr,mode="toggle",mute=mute)
 
             if not c and mode == "toggle": # unselect all
                 c= self._deselect_all(fix=fix)
@@ -3134,6 +3155,7 @@ class Fixtures():
                 if mode == "on":
                     if not data["ATTRIBUT"][attr]["ACTIVE"]:
                         data["ATTRIBUT"][attr]["ACTIVE"] = 1
+                        data["ATTRIBUT"]["_ACTIVE"]["ACTIVE"] = 1
                         out = 1
                 elif mode == "off":
                     if data["ATTRIBUT"][attr]["ACTIVE"]:
@@ -3144,6 +3166,7 @@ class Fixtures():
                         data["ATTRIBUT"][attr]["ACTIVE"] = 0
                     else:
                         data["ATTRIBUT"][attr]["ACTIVE"] = 1
+                        data["ATTRIBUT"]["_ACTIVE"]["ACTIVE"] = 1
                     out = 1
         return out
 
@@ -3844,6 +3867,10 @@ class Refresher():
                 tkinter.Tk.update_idletasks(gui_menu_gui.tk)
             except Exception as e:
                 print("loop exc",e)
+                traceback.print_exc()
+                cprint("== cb EXCEPT",e,color="red")
+                cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
+                cprint(''.join(traceback.format_exception(None, e, e.__traceback__)),color="red")
 
             time.sleep(0.2)
 
@@ -3869,7 +3896,7 @@ refresher_exec = Refresher()
 refresher_exec.name = "exec"
 
 def loops(**args):
-    time.sleep(30) # wait until draw all window's 
+    time.sleep(15) # wait until draw all window's 
     thread.start_new_thread(refresher_fix.loop,())
     thread.start_new_thread(refresher_exec.loop,())
 

+ 86 - 43
tkgui/GUI.py

@@ -200,14 +200,22 @@ def draw_sub_dim(gui,fix,data,c=0,r=0,frame=None):
     if fix not in gui.elem_attr:
         gui.elem_attr[fix] = {}
         
+    attr_list = []    
     for attr in data["ATTRIBUT"]:
-        
         if attr not in gui.all_attr:
             gui.all_attr.append(attr)
+
         if attr not in gui.elem_attr[fix]:
             gui.elem_attr[fix][attr] = []
+        
         if attr.endswith("-FINE"):
             continue
+        if attr.startswith("_"):
+            continue
+        attr_list.append(attr)
+
+
+    for attr in attr_list:#data["ATTRIBUT"]:
         v= data["ATTRIBUT"][attr]["VALUE"]
         b = tk.Button(frame,bg="lightblue", text=""+str(fix),width=3,anchor="w")
         b.config(padx=1)
@@ -219,6 +227,13 @@ def draw_sub_dim(gui,fix,data,c=0,r=0,frame=None):
         b.bind("<Button>",Xevent(fix=fix,mode="D-SELECT",elem=b).cb)
         b.grid(row=r, column=c, sticky=tk.W+tk.E)
         c+=1
+        b = tk.Button(frame,bg="grey", text="S",width=2,anchor="c")
+        b.config(padx=1)
+        myTip = Hovertip(b,'SELECT')
+        b.bind("<Button>",Xevent(fix=fix,elem=b,attr="_ACTIVE",mode="ENCODER",data=data).cb)
+        b.grid(row=r, column=c, sticky=tk.W+tk.E)
+        gui.elem_attr[fix]["S"] = b
+        c+=1
         b = tk.Button(frame,bg="grey", text=str(round(v,2)),width=10,anchor="w")
         b.config(padx=1)
         gui.elem_attr[fix][attr] = b
@@ -269,52 +284,80 @@ class GUI_FIX():
             i+=1
             data = FIXTURES.fixtures[fix]
             #print("draw_fix", fix ,data )
+            if fix not in gui.elem_attr:
+                gui.elem_attr[fix] = {}
             
-            if(len(data["ATTRIBUT"].keys()) <= 1):
+            #if (len(data["ATTRIBUT"].keys()) <= 1):
+            #    c,r=draw_sub_dim(gui,fix,data,c=c,r=r,frame=dim_frame)
+            kix = []
+            for ix in data["ATTRIBUT"].keys():
+                if not ix.startswith("_") and not ix.endswith("-FINE"):
+                    kix.append(ix)
+
+            if "DIM" in kix and len(kix) == 1:
                 c,r=draw_sub_dim(gui,fix,data,c=c,r=r,frame=dim_frame)
-            else:
-                if not dim_end:
-                    dim_end=1
-                    c=0
-                    r=0
-                #gui._draw_fix(fix,data,root=fix_frame)
-                frame = fix_frame
-            
-                b = tk.Button(frame,bg="lightblue", text="ID:"+str(fix),width=6,anchor="w")
-                b.bind("<Button>",Xevent(fix=fix,mode="SELECT",elem=b).cb)
-                b.grid(row=r, column=c, sticky=tk.W+tk.E)
-                c+=1
-                b = tk.Button(frame,bg="#55f", text=data["NAME"],width=10,anchor="w")
-                b.bind("<Button>",Xevent(fix=fix,attr="ALL",mode="ENCODER",elem=b).cb)
-                b.grid(row=r, column=c, sticky=tk.W+tk.E)
-                c+=1
-                #r+=1
-                start_c=3
-                c=start_c
-                if fix not in gui.elem_attr:
-                    gui.elem_attr[fix] = {}
-                    
-                for attr in data["ATTRIBUT"]:
-                    
-                    if attr.endswith("-FINE"):
-                        continue
-                    if attr not in gui.all_attr:
-                        gui.all_attr.append(attr)
-                    if attr not in gui.elem_attr[fix]:
-                        gui.elem_attr[fix][attr] = ["line1348",fix,attr]
-                    v= data["ATTRIBUT"][attr]["VALUE"]
-                    
-                    b = tk.Button(frame,bg="grey", text=str(attr)+' '+str(round(v,2)),width=12, anchor="w")
-                    gui.elem_attr[fix][attr] = b
-                    b.bind("<Button>",Xevent(fix=fix,elem=b,attr=attr,mode="ENCODER",data=data).cb)
-                    b.grid(row=r, column=c, sticky=tk.W+tk.E,ipadx=0,ipady=0,padx=0,pady=0)
-                    c+=1
-                    if c >=8:
-                        c=start_c
-                        r+=1
+                continue
+
+
+
+            if not dim_end:
+                dim_end=1
                 c=0
-                r+=1
+                r=0
+            #gui._draw_fix(fix,data,root=fix_frame)
+            frame = fix_frame
+        
+            b = tk.Button(frame,bg="lightblue", text="ID:"+str(fix),width=6,anchor="w")
+            b.bind("<Button>",Xevent(fix=fix,mode="SELECT",elem=b).cb)
+            b.grid(row=r, column=c, sticky=tk.W+tk.E)
+            c+=1
+            b = tk.Button(frame,bg="#55f", text=data["NAME"],width=10,anchor="w")
+            b.bind("<Button>",Xevent(fix=fix,attr="ALL",mode="ENCODER",elem=b).cb)
+            b.grid(row=r, column=c, sticky=tk.W+tk.E)
+            c+=1
+
+            b = tk.Button(frame,bg="grey", text="S",width=2,anchor="c")
+            b.config(padx=1)
+            myTip = Hovertip(b,'SELECT')
+            b.bind("<Button>",Xevent(fix=fix,elem=b,attr="_ACTIVE",mode="ENCODER",data=data).cb)
+            b.grid(row=r, column=c, sticky=tk.W+tk.E)
+            gui.elem_attr[fix]["S"] = b
+            c+=1
+
+            #r+=1
+            start_c=3
+            c=start_c
+            attr_list = []    
+            for attr in data["ATTRIBUT"]:
+                
+                if attr.endswith("-FINE"):
+                    continue
+                #if attr.startswith("_"):
+                #    continue
+                attr_list.append(attr)
+
+
+            for attr in attr_list:#data["ATTRIBUT"]:
+
+                if attr not in gui.all_attr:
+                    gui.all_attr.append(attr)
+                if attr not in gui.elem_attr[fix]:
+                    gui.elem_attr[fix][attr] = ["line1348",fix,attr]
+                v= data["ATTRIBUT"][attr]["VALUE"]
                 
+                if attr.startswith("_"):
+                    continue
+                b = tk.Button(frame,bg="grey", text=str(attr)+' '+str(round(v,2)),width=12, anchor="w")
+                gui.elem_attr[fix][attr] = b
+                b.bind("<Button>",Xevent(fix=fix,elem=b,attr=attr,mode="ENCODER",data=data).cb)
+                b.grid(row=r, column=c, sticky=tk.W+tk.E,ipadx=0,ipady=0,padx=0,pady=0)
+                c+=1
+                if c >=8:
+                    c=start_c
+                    r+=1
+            c=0
+            r+=1
+            
 
         #master._refresh_exec()
         #master.refresh_exec()

+ 5 - 3
tkgui/draw.py

@@ -512,14 +512,16 @@ def draw_enc(gui,xframe):
     #for attr in ["xx"]*23: # gui.all_attr:
     eat = gui.all_attr
 
-    if len(eat) < 23:
-        for i in range(23-len(eat)):
+    if len(eat) < 24:
+        for i in range(24-len(eat)):
             eat.append("")
     for attr in eat:
         if attr.endswith("-FINE"):
             continue
         v=0
-        
+        if attr.startswith("_"):
+            continue
+
         b = tk.Button(frame,bg="#6e6e6e", text=str(attr)+'',width=7)#, anchor="w")
         if attr == "DIM":
             b = tk.Button(frame,bg="#ff7f00", text=str(attr)+'',width=7)#, anchor="w")