Browse Source

change: FIXTURE-EDITOR list,popup -import -open -user

micha 1 year ago
parent
commit
2636b7557a
2 changed files with 179 additions and 44 deletions
  1. 136 10
      _LibreLightDesk.py
  2. 43 34
      tkgui/GUI.py

+ 136 - 10
_LibreLightDesk.py

@@ -2939,6 +2939,21 @@ class DummyCallback():
     def cb(self,event=None):
         cprint("DummyCallback.cb",[self.name,event])
 
+class BaseCallback():
+    def __init__(self,cb=None,**args):
+        self._cb=cb
+        self.args = args
+
+    def cb(self,**args):
+        print("++",self,"cb()",self.args,self._cb)
+        if self._cb:
+            print()
+            print("cb",self._cb)
+            try:
+                self._cb(self.args) 
+            except TypeError as e:
+                print("  TypeError",e)
+                self._cb() 
 
 def _load_show_list(frame,cb=None):
     c=0
@@ -2997,6 +3012,27 @@ def _parse_fixture_name(name):
         out = [name]
     return out
 
+def online_help(page):
+    print("INIT:online_help",page)
+
+    try:
+        page = page.replace("&","")
+        page = page.replace("=","")
+        page = page.replace("/","")
+        import webbrowser
+        def _cb():
+            print("online_help",page)
+            webbrowser.open("http://librelight.de/wiki/doku.php?id="+page )
+        return _cb
+    except Exception as e:
+        print("online_help Exception",e)
+        raise e
+
+    def _cb():
+        print("error online_help",page)
+    return _cb 
+
+
 def _import_fixture_list(frame,cb=None,master=None,bg="black"):
     frame.configure(bg=bg)
     c=0
@@ -3053,6 +3089,7 @@ def _import_fixture_list(frame,cb=None,master=None,bg="black"):
     
     _tmp_name = ""
     _tmp_flag = 0
+    blist=blist[:10]
     for i in blist:
         #print(i)
         if i[0] != _tmp_name:
@@ -3078,13 +3115,8 @@ def _import_fixture_list(frame,cb=None,master=None,bg="black"):
                 if base.show_name == i[0]:
                     bg="green"
 
-                #print(dir(cb))
-                _cb2 = None
-                try:
-                    cb.master=master
-                    _cb=cb.cb(j)
-                    _cb2 = _cb.cb
-                except:pass
+                _cb2 = BaseCallback(cb=cb,args={"file":j}).cb
+
                 b = tk.Button(frame,text=j,anchor="w",height=1,bg=bg,command=_cb2)
 
                 if base.show_name == i[0]:
@@ -3098,6 +3130,100 @@ def _import_fixture_list(frame,cb=None,master=None,bg="black"):
         r+=1
 
 
+def _load_fixture_list(frame,cb=None,master=None,bg="black"):
+    frame.configure(bg=bg)
+    c=0
+    r=0
+    base = Base()
+    for i in ["source","name","manufacturer","channel's","file","path"]: #,"create"]:
+        b = tk.Label(frame,bg="grey",text=i)
+        b.grid(row=r, column=c, sticky=tk.W) #+tk.E)
+        c+=1
+    r+=1
+    blist = [] #base._list()
+    try:
+        p = HOME+"/LibreLight/fixtures/"
+        ls = os.listdir(p)
+        ls.sort()
+        for l in ls:
+            b = _parse_fixture_name(l)
+            b.append(p)
+            b.insert(0,"user")
+            blist.append(b)
+    except Exception as e:
+        cprint("Exce 877 ",e)
+    try:
+        p="/opt/LibreLight/Xdesk/fixtures/"
+        ls = os.listdir(p )
+        ls.sort()
+        for l in ls:
+            b = _parse_fixture_name(l)
+            b.append(p)
+            b.insert(0,"base")
+            blist.append(b)
+    except Exception as e:
+        cprint("Exce 878 ",e)
+
+    if not blist:
+        blist.append(["MAC-500","martin","Demo"])
+        blist.append(["MAC-2000","martin","Demo"])
+        blist.append(["MAC-VIPER","martin","Demo"])
+        blist.append(["SPARX-7","JB","Demo"])
+        blist.append(["SPARX-11","JB","Demo"])
+        blist.append(["JB-P6","JB","Demo"])
+        blist.append(["JB-P7","JB","Demo"])
+        blist.append(["JB-A7","JB","Demo"])
+        blist.append(["TMH-12","Eurolight","Demo"])
+
+    if len(blist) < 30:
+        for i in range(30-len(blist)):
+            blist.append(["{:0>4}".format(len(blist)+i+1),"",""])
+
+
+    if cb is None: 
+        cb = DummyCallback #("load_show_list.cb")
+    
+    _tmp_name = ""
+    _tmp_flag = 0
+    for i in blist:
+        #print(i)
+        if i[0] != _tmp_name:
+            _tmp_flag = "#aaf"
+            if i[0] == "user":
+                _tmp_flag = "#aaf"
+            if i[0] == "base":
+                _tmp_flag = "#0f0"
+
+        c=0
+        for j in i:
+            bg="lightgrey"
+            dbg="lightgrey"
+            if i[1] > time.strftime("%Y-%m-%d %X",  time.localtime(time.time()-3600*4)):
+                dbg = "lightgreen"
+            elif i[1] > time.strftime("%Y-%m-%d %X",  time.localtime(time.time()-3600*24*7)):
+                dbg = "green"
+
+            if _tmp_flag:
+                bg = "{}".format(_tmp_flag)
+
+            if c == 1:
+                if base.show_name == i[0]:
+                    bg="green"
+
+                _cb2 = BaseCallback(cb=cb,args={"file":j}).cb
+
+                b = tk.Button(frame,text=j,anchor="w",height=1,bg=bg,command=_cb2)
+
+                if base.show_name == i[0]:
+                    b.config(activebackground=bg)
+                b.grid(row=r, column=c, sticky=tk.W+tk.E)
+            else:#ief c > 0:
+                b = tk.Button(frame,text=j,anchor="w",bg=dbg,relief="sunken")
+                b.config(activebackground=dbg)
+                b.grid(row=r, column=c, sticky=tk.W+tk.E)
+            c+=1
+        r+=1
+
 
 def _load_fixture_list(frame,cb=None,master=None,bg="black"):
     frame.configure(bg=bg)
@@ -3179,9 +3305,9 @@ def _load_fixture_list(frame,cb=None,master=None,bg="black"):
                 if base.show_name == i[0]:
                     bg="green"
 
-                cb.master=master
-                _cb=cb.cb(j)
-                b = tk.Button(frame,text=j,anchor="w",height=1,bg=bg,command=_cb.cb)
+                _cb2 = BaseCallback(cb=cb,args={"file":j}).cb
+
+                b = tk.Button(frame,text=j,anchor="w",height=1,bg=bg,command=_cb2)
 
                 if base.show_name == i[0]:
                     b.config(activebackground=bg)

+ 43 - 34
tkgui/GUI.py

@@ -27,8 +27,10 @@ class _LOAD_FIXTURE():
 
     def cb(self,event=None,fixture={}):
         print("LOAD_FIXTURE",self.name,event)
+        print(self,"cb")
         self.parent.clear()
         if fixture:
+            print(len(fixture))
             self.parent.load(fixture)
 
 class LOAD_FIXTURE():
@@ -200,13 +202,6 @@ class GUIHandler():
 
 
 
-
-
-
-
-
-
-
 class X_CLOCK():
     def __init__(self):
         self._last_label_id = 1
@@ -811,6 +806,7 @@ class GUI_FixtureEditor():
         self.b = tk.Button(self.frame,bg="lightblue",text="IMPORT", width=5)#,command=self.event) #bv.change_dmx)
         self.b["command"] = self.import_fixture_list
         self.b.pack( side=tk.LEFT)
+
         self.b = tk.Button(self.frame,bg="lightblue",text="USER", width=5)#,command=self.event) #bv.change_dmx)
         self.b["command"] = self.open_fixture_list
         self.b.pack( side=tk.LEFT)
@@ -818,6 +814,7 @@ class GUI_FixtureEditor():
         self.b["command"] = self.open_fixture_list
         self.b.pack( side=tk.LEFT)
 
+
         self.b = tk.Label(self.frame,bg="#ddd",text="")
         self.b.pack(fill=None, side=tk.LEFT)
 
@@ -825,6 +822,7 @@ class GUI_FixtureEditor():
         self.b["command"] = self.save_fixture
         self.b.pack( side=tk.LEFT)
         
+
         #self.b = tk.Button(self.frame,bg="lightblue",text="SAVE AS", width=5)#,command=self.event) #bv.change_dmx)
         #self.b["command"] = self.save_as_fixture
         #self.b.pack( side=tk.LEFT)
@@ -832,6 +830,10 @@ class GUI_FixtureEditor():
         self.b = tk.Label(self.frame,bg="black",text="") # spacer
         self.b.pack(fill=tk.Y, side=tk.LEFT)
 
+        self.b = tk.Button(self.frame,bg="lightblue",text="HELP", width=5)#,command=self.event) #bv.change_dmx)
+        self.b["command"] = _M.online_help("fixture-editor")
+        self.b.pack( side=tk.LEFT)
+
         # HEAD 1
         
         #root = tk.Frame(root,bg="black",width=width)
@@ -903,10 +905,9 @@ class GUI_FixtureEditor():
             frameS.pack(fill=tk.X, side=tk.TOP)
             c+=1
 
-    def _cb(self,arg,**args):
-        print(self)
-        print(">>",args)
-        print(">>",args)
+    def _cb(self,arg,name="<name>",**args):
+        print(self,"_cb")
+        print(name,"_cb.args >>",arg,args)
         self.count_ch()
 
     def count_ch(self):
@@ -947,40 +948,48 @@ class GUI_FixtureEditor():
     def save_as_fixture(self,event=None):
         print("save_as_fix",self,event)
         self.count_ch()
+
     def save_fixture(self,event=None):
         print("save_fix",self,event)
         self.count_ch()
+
     def import_fixture_list(self):
         name = "FIXTURE-IMPORT"
         line1="Fixture Import from SHOW"
         line2="CHOOS to EDIT >> DEMO MODUS"
         line3="CHOOS to EDIT >> DEMO MODUS"
+
         cb = LOAD_FIXTURE(self,"IMPORT").cb
-        pw = _M.PopupList(name,width=600,cb=cb,left=_M._POS_LEFT+620,bg="#333")
-        self.pw = pw
-        #print(dir(pw.w))
-        #print(dir(pw))
-        frame = pw.sframe(line1=line1,line2=line2) #,line3=line3)
+        self.pw = _M.PopupList(name,width=600,cb=cb,left=_M._POS_LEFT+620,bg="#333")
+        frame = self.pw.sframe(line1=line1,line2=line2) #,line3=line3)
+        def cb(**args):
+            self._cb(args,name="import_fixture_list")
+            if self.pw:
+                self.pw.w.tk.destroy()
+            #self.load_EMPTY()
+            self.load_MH()
         r=_M._import_fixture_list(frame,cb=cb,master=self,bg="#333")
-        self.count_ch()
+
     def open_fixture_list(self):
         name = "FIXTURE-LIB"
         line1="Fixture Library"
         line2="CHOOS to EDIT >> DEMO MODUS"
         line3="CHOOS to EDIT >> DEMO MODUS"
-        cb = LOAD_FIXTURE(self,"USER") #a.cb
-        pw = _M.PopupList(name,width=600,cb=cb,left=_M._POS_LEFT+620,bg="#333")
-        self.pw = pw
-        #print(dir(pw.w))
-        #print(dir(pw))
-        frame = pw.sframe(line1=line1,line2=line2) #,line3=line3)
+
+        cb = LOAD_FIXTURE(self,"USER").cb 
+        self.pw = _M.PopupList(name,width=600,cb=cb,left=_M._POS_LEFT+620,bg="#333")
+        frame = self.pw.sframe(line1=line1,line2=line2) #,line3=line3)
+
+        def cb(**args):
+            self._cb(args,name="open_fixture_list") 
+            if self.pw:
+                self.pw.w.tk.destroy()
+            #self.load_EMPTY()
+            self.load_DIM()
         r=_M._load_fixture_list(frame,cb=cb,master=self,bg="#333")
-        self.count_ch()
+
     def close_fixture_list(self):
         if self.pw:
-            #print("*._"*30)
-            #print(dir(self.pw.w.tk))
-            #self.pw.w.tk.quit()
             self.pw.w.tk.destroy()
 
     def clear(self,_event=None,attr=[]):
@@ -1031,7 +1040,7 @@ class GUI_FixtureEditor():
         #for i,e in enumerate(self.elem):
         for i,e in enumerate(self.elem):
             #print(self,"event",_event,e)
-            print("event",_event,e)
+            #print("event",_event,e)
             e._set_attr( "")
             if len(attr) > i:
                 e._set_attr( attr[i])
@@ -1155,7 +1164,7 @@ class ELEM_FADER():
         if self._fader_cb is not None:
             self._fader_cb(a1,a2,nr=self.nr)
         else:
-            print(self,"event",[self.nr,a1,a2])
+            #print(self,"event",[self.nr,a1,a2])
             j=[]
             jdata = {'VALUE': int(a1), 'args': [] , 'FADE': 0,'DMX': str(self.nr)}
             j.append(jdata)
@@ -1170,7 +1179,7 @@ class ELEM_FADER():
                 print("err443",self,"_cb",data)
                 return None
             txt = data["Value"]
-            print(self,"set_attr._cb()",txt)
+            #print(self,"set_attr._cb()",txt)
             self._set_attr(txt)
             if self._cb:
                 self._cb([self,"set_attr",txt])
@@ -1180,7 +1189,7 @@ class ELEM_FADER():
     def _set_attr(self,txt=""):
         if type(txt) is str:
             self.attr["text"] = "{}".format(txt)
-            print("_set_attr",[self])
+            #print("_set_attr",[self])
         if self._cb:
             self._cb([self,"_set_attr",txt])
 
@@ -1211,7 +1220,7 @@ class ELEM_FADER():
         if type(txt) is str:
             txt = txt[0].upper()
             self.mode["text"] = "{}".format(txt)
-            print("_set_attr",[self])
+            #print("_set_mode",[self])
         if self._cb:
             self._cb([self,"_set_mode",txt])
 
@@ -1307,7 +1316,7 @@ class EXEC_FADER():
     def _set_attr(self,txt=""):
         if type(txt) is str:
             self.attr["text"] = "{}".format(txt)
-            print("_set_attr",[self])
+            #print("_set_attr",[self])
     def set_label(self,name=""):
         #print("set_label",self.b,name)
         self.label["text"] = name
@@ -1329,7 +1338,7 @@ class EXEC_FADER():
     def _set_mode(self,txt=""):
         if type(txt) is str:
             self.mode["text"] = "{}".format(txt[0].upper())
-            print("_set_attr",[self])
+            #print("_set_mode",[self])
     def _refresh(self):
         pass
     def pack(self,init=None,from_=255,to=0,**args):