Selaa lähdekoodia

fix: Fixture-Editor -IMPORT -USER -GLOBAL group fix by ATTR

micha 1 vuosi sitten
vanhempi
commit
8344e0f4f2
2 muutettua tiedostoa jossa 66 lisäystä ja 82 poistoa
  1. 39 62
      _LibreLightDesk.py
  2. 27 20
      tkgui/GUI.py

+ 39 - 62
_LibreLightDesk.py

@@ -2209,6 +2209,7 @@ class Base():
             msg += "\n\ncheck\n-init.txt"
             cprint(msg,color="red")
             showwarning(msg=msg,title="load Error")
+            return
         return _read_sav_file(xpath)
 
 
@@ -3046,6 +3047,7 @@ class PopupList():
 
         b = tk.Entry(xframe,width=10,text="")#,anchor="w")
         b.pack(side="top",expand=0,fill="x") 
+        b["state"] = "readonly"
         b.focus()
 
 
@@ -3176,98 +3178,73 @@ def index_fixtures():
         blist.append(b)
     return blist
 
-def _fixture_load_list(path):
-    blist = []
-    try:
-        ls = os.listdir(path)
-        ls.sort()
-        print("fll",path)
-        for fn in ls:
-            b = _parse_fixture_name(fn)
-            b["xpath"] = path 
-            b["xfname"] = fn.replace(path,"")
-            print("fll ",b)
-            blist.append(b)
-    except Exception as e:
-        cprint("Exce 877 ",e)
-    return blist
-
 
 
+#def _fixture_create_import_list(path=None):
+def _fixture_load_import_list(path=None):
+    if not path:
+        path = "/home/user/LibreLight/show"
 
-def _fixture_create_import_list():
-    path = "/home/user/LibreLight/show"
     blist = []
-    for sname in os.listdir(path):
+    lsd = os.listdir(path)
+    lsd.sort()
+    fname_buffer = []
+    for sname in lsd:
         #print("   ",sname)
+        ok = 0
         try:
             fname = path+"/"+sname+"/patch.sav"
             if os.path.isfile(fname):
+                ok = 1
+            else:
+                fname = path+"/"+sname
+                if os.path.isfile(fname):
+                    ok = 1
+            #fname_buffer = []
+            if ok:
                 f = open(fname)
                 lines = f.readlines()
                 f.close()
 
                 for line in lines:
+                    ok2 = 0
+                    _key = ""
                     line = line.split("\t")
-                    line = json.loads(line[2])
-                    name = line["NAME"]
-                    #row = [name,fname+":"+name,path])
-                    xfname = fname.replace(path,"")
-                    row = {"name":name,"xfname":xfname , "xpath":path}
-                    blist.append(row)
+                    jdata = json.loads(line[2])
+                    if "ATTRIBUT" in jdata:
+                        _len = len(jdata["ATTRIBUT"])
+                        _key = list(jdata["ATTRIBUT"].keys()) 
+                        _key.sort()
+                        _key = str(_key)
+                        if _key not in fname_buffer:
+                            fname_buffer.append(_key) # group same fixtures by ATTR
+                            ok2 = 1
+                    if ok2:
+                        name = jdata["NAME"]
+                        #row = [name,fname+":"+name,path])
+                        xfname = fname.replace(path,"")
+                        row = {"name":name,"xfname":xfname ,"ch":_len, "xpath":path,"d":_key} #,"b":jdata}
+                        blist.append(row)
         except Exception as e:
             print("exception",e)
     return blist
 
-def _fixture_load_import_list():
-    return _fixture_create_import_list()
-
-    pass
-    path = HOME+"/LibreLight/fixture.index.json"
-    if not os.path.isfile(path):
-        blist = _fixture_create_import_list()
-        f = open(path,"w")
-        for line in blist:
-            line = json.dumps(line)
-            f.writelines(line)
-        f.close()
-
-    blist = []
-    if os.path.isfile(path):
-        f = open(path,"r")
-        lines = f.readlines()
-        f.close()
-        for line in lines:
-            print("_fixture_load__import",line)
-            line = line.strip()
-            blist.append(json.loads(line))
-
-    return blist
-
 
-def _fixture_load_data(path,number):
-    data = """1	1	{"DMX": 1, "UNIVERS": 2, "NAME": "VPU_001", "TYPE": "MOVER", "VENDOR": "AYERTON", "ATTRIBUT": {"DIM": {"NR": 1, "MASTER": "0", "MODE": "F", "VALUE": 256, "ACTIVE": 0, "FX": "", "FX2": {}}, "RED": {"NR": 2, "MASTER": "0", "MODE": "F", "VALUE": 0, "ACTIVE": 0, "FX": "", "FX2": {}}, "GREEN": {"NR": 3, "MASTER": "0", "MODE": "F", "VALUE": 0, "ACTIVE": 0, "FX": "", "FX2": {}}, "BLUE": {"NR": 4, "MASTER": "0", "MODE": "F", "VALUE": 255, "ACTIVE": 0, "FX": "", "FX2": {}}, "_ACTIVE": {"NR": 0, "ACTIVE": 0, "VALUE": 0, "FX": "", "FX2": {}}}, "ACTIVE": 0}
-"""
-    return data
 
 def _load_fixture_list(mode="None"):
     blist = []
 
     if mode == "USER":
         path = HOME+"/LibreLight/fixtures/"
-        _r = _fixture_load_list(path=path)
-        blist.extend( _r )
 
     elif mode == "GLOBAL":
         path="/opt/LibreLight/Xdesk/fixtures/"
-        _r = _fixture_load_list(path=path)
-        blist.extend( _r )
 
     elif mode == "IMPORT":
-        _r=_fixture_load_import_list()
-        blist.extend( _r )
-    #for i in blist:
-    #    print(" -",i)
+        path=None 
+
+    _r =  _fixture_load_import_list(path=path)
+    blist.extend( _r )
     return blist
 
 

+ 27 - 20
tkgui/GUI.py

@@ -777,7 +777,7 @@ def GUI_LOAD_FIXTURE_LIST(frame,data={"EMPTY":"None"},cb=None,bg="black"):
     #print("__func__",__func__)
     print("#",sys._getframe().f_code.co_name)
     blist = data
-    blist = blist[:10]
+    blist = blist[:100]
 
     frame.configure(bg=bg)
 
@@ -786,10 +786,10 @@ def GUI_LOAD_FIXTURE_LIST(frame,data={"EMPTY":"None"},cb=None,bg="black"):
     for r,row in enumerate(blist):
         bg="lightgrey"
         dbg="grey"
-        #c+=1
-        #b = tk.Label(frame,bg="grey",text=str(r+1))
-        #b = tk.Button(frame,text=r+1,anchor="w",bg=dbg,relief="sunken")
-        #b.grid(row=r, column=c, sticky=tk.W) #+tk.E)
+        dbg="lightgrey"
+        c+=1
+        b = tk.Label(frame,bg="grey",text=str("Nr."))
+        b.grid(row=r, column=c, sticky=tk.W) #+tk.E)
         c+=1
         for k,v in row.items():
             b = tk.Label(frame,bg="grey",text=k)
@@ -805,17 +805,17 @@ def GUI_LOAD_FIXTURE_LIST(frame,data={"EMPTY":"None"},cb=None,bg="black"):
         c=1
 
         bg="lightgrey"
-        dbg="grey"
+        #dbg="grey"
         b = tk.Button(frame,text=r+1,anchor="w",bg=dbg,width=6,relief="sunken")
         b.grid(row=r+1, column=c, sticky=tk.W ) #+tk.E)
         c+=1
+        bg="grey"
+        dbg="grey"
         for k,v in row.items():
-            bg="lightgrey"
-            dbg="lightgrey"
-            if v > time.strftime("%Y-%m-%d %X",  time.localtime(time.time()-3600*4)):
-                dbg = "lightgreen"
-            elif v > time.strftime("%Y-%m-%d %X",  time.localtime(time.time()-3600*24*7)):
-                dbg = "green"
+            #if v > time.strftime("%Y-%m-%d %X",  time.localtime(time.time()-3600*4)):
+            #    dbg = "lightgreen"
+            #elif v > time.strftime("%Y-%m-%d %X",  time.localtime(time.time()-3600*24*7)):
+            #    dbg = "green"
 
 
             if c == 2:
@@ -826,6 +826,8 @@ def GUI_LOAD_FIXTURE_LIST(frame,data={"EMPTY":"None"},cb=None,bg="black"):
                 b.config(activebackground=dbg)
             b.grid(row=r+1, column=c, sticky=tk.W+tk.E)
             c+=1
+            bg="lightgrey"
+            dbg="lightgrey"
 
 
 class GUI_FixtureEditor():
@@ -1083,7 +1085,7 @@ class GUI_FixtureEditor():
 
 
         def cb(event=None,args={}):
-            print("open_fixture_list")
+            print("open_fixture_list.cb(")
             print("   ",args)
             if self.pw:
                 self.pw.w.tk.destroy()
@@ -1096,14 +1098,19 @@ class GUI_FixtureEditor():
             a = []
             m = []
             for row in fdata:
-                print("row:  ",row.keys())
-                print("a-")
-                for k,v in row.items():#keys():
+                #print("row:  ",row.keys())
+                #print("a-")
+                for k,fixture in row.items():#keys():
                     #v = row[k]
-                    print("a    :",k,str(v)[:120],"...")
-                    print("a    ::",type(k),":",type(v))
-                    if "ATTRIBUT" in v:
-                        for at in v["ATTRIBUT"]:
+                    if "NAME" not in fixture:
+                        continue
+                    if fixture["NAME"] != args["val"]:
+                        continue
+
+                    print("a    :",k,str(fixture)[:120],"...")
+                    #print("a    ::",type(k),":",type(fixture))
+                    if "ATTRIBUT" in fixture:
+                        for at in fixture["ATTRIBUT"]:
                             if at.startswith("_"):
                                  continue
                             a.append(at)