Browse Source

cleanup: FX3.py

micha 2 months ago
parent
commit
c2b6bd11b8
4 changed files with 102 additions and 453 deletions
  1. 19 35
      _LibreLightDesk.py
  2. 5 3
      lib/meta.py
  3. 71 414
      tkgui/FX3.py
  4. 7 1
      tool/movewin.py

+ 19 - 35
_LibreLightDesk.py

@@ -2538,44 +2538,28 @@ if __run_main:
 
 
     # =======================================================================
-    if 1:
-        name="FX3" #"TK-EXEC"
-        def sdl_starter():
-            cmd="/usr/bin/python3 /opt/LibreLight/Xdesk/tkgui/FX3.py " #&"
-            print(cmd)
-
-            def xyz123(cmd):
-                os.system(cmd)
-            thread.start_new_thread(xyz123,(cmd,))
-            return [None,None,None]
-        args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
-        geo = libwin.filter_window_geo(geo_list,name)
-        if geo:
-            args.update(geo)
+    name="FX3" #"TK-EXEC"
+    def sdl_starter():
+        cmd="/usr/bin/python3 /opt/LibreLight/Xdesk/tkgui/FX3.py " #&"
+        print(cmd)
 
-        data = []
-        cls = sdl_starter #: None #GUI_CONF
-        cb_ok = None
+        def xyz123(cmd):
+            os.system(cmd)
+        thread.start_new_thread(xyz123,(cmd,))
+        return [None,None,None]
+    args = {"title":name,"master":0,"width":380,"height":500,"left":L1,"top":TOP}
+    geo = libwin.filter_window_geo(geo_list,name)
+    if geo:
+        args.update(geo)
 
-        c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
-        window_manager.new(None,name,wcb=c)
-        if libwin.split_window_show(geo_list,_filter=name):
-            window_manager.top(name)
-    # =======================================================================
-    if 0:
-        name="FX3"
-        args = {"title":name,"master":0,"width":364,"height":418+30,"left":L1+10+W1,"top":TOP+302,"resize":1}
-        geo = libwin.filter_window_geo(geo_list,name)
-        if geo:
-            args.update(geo)
-        cls = draw_fx_3 #(master,w.tk)
-        data = []
-        cb_ok = None
+    data = []
+    cls = sdl_starter #: None #GUI_CONF
+    cb_ok = None
 
-        c = libtk.window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
-        window_manager.new(None,name,wcb=c)
-        if libwin.split_window_show(geo_list,_filter=name):
-            window_manager.top(name)
+    c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
+    window_manager.new(None,name,wcb=c)
+    if libwin.split_window_show(geo_list,_filter=name):
+        window_manager.top(name)
 
 
     # =======================================================================

+ 5 - 3
lib/meta.py

@@ -15,10 +15,12 @@ def ValueBuffer_create_data(val=2,_min=0,_max=255,_inc=1,cycle=[0,127,255]):
     return data
 
 def Buffer_clean(data,default={}):
-    print( "ValueBuffer_clean(data)" )
+    #print( "ValueBuffer_clean(data)" )
     a = ValueBuffer_create_data()
+    #for k,v in data.items():
+    #    print("  ",id(data),[k,v])
     for k,v in a.items():
-        print("  ",id(data),[k,v])
+        #print("  ",id(data),[k,v])
         if k not in data:
             print("ValueBuffer_clear key does not exist; adding key ",[k]," !")
             data[k] = v
@@ -117,7 +119,7 @@ def ValueBuffer_is(data):
 def ValueBuffer_format(data):
     ValueBuffer_clean(data)
     fm = data["format"]
-    print(fm,data)
+    print("ValueBuffer_format", fm,data)
     try:
         if "{val" in fm and "{state" in fm:
             return fm.format(val=data["value"],state=data["state"])

+ 71 - 414
tkgui/FX3.py

@@ -1,115 +1,30 @@
+#!/usr/bin/python3
 
 import json
 import time
 import sys
-
+import os
 import tkinter as tk
-from tkinter import font
-
 import traceback
 import _thread as thread
 
 sys.path.insert(0,"/opt/LibreLight/Xdesk/")
-import lib.meta as meta
-
-import dialog
-DIALOG = dialog.Dialog()
-
-GLOBAL_old_btn_nr = -1
-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",meta.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",meta.commands.elem)
-
-def dialog_cb_cfg(exec_nr): #DAILOG CONFIG CALLBACK
-    def _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")
-        cmd_client.send(msg)
-
-        thread.start_new_thread(refresh_exec_btn,(exec_nr,))
-    return _Dcb
-
-def dialog_cb_label(exec_nr): #DAILOG CONFIG CALLBACK
-    def _Dcb(*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":"EXEC-LABEL","EXEC":exec_nr,"VALUE":255,"DATA":DATA}]).encode("utf-8")
-        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) # diable LABEL mode
-
-        thread.start_new_thread(refresh_exec_btn,(exec_nr,))
-    return _Dcb
-
-DIALOG._cb = dialog_cb_cfg(-3)
-#d = dialog.Dialog()
-#d.ask_exec_config(str(nr+1),button=button,label=label,cfg=cfg)
 
+INIT_OK = 1
+IS_GUI = 0
 
 import __main__ as MAIN
-
-_file_path = "/opt/LibreLight/Xdesk/"
-sys.path.insert(0,"/opt/LibreLight/Xdesk/")
-
+import lib.meta as meta
 import tool.git as git
-#CAPTION += git.get_all()
 
 CAPTION = "FX3"
 title = CAPTION
 title += git.get_all()
 
-INIT_OK = 1
-IS_GUI = 0
 from lib.cprint import cprint
 
-
 import lib.libtk as libtk
 import lib.libtk2 as libtk2
 import lib.zchat as chat
@@ -118,6 +33,8 @@ import lib.mytklib as mytklib
 import lib.tkevent as tkevent
 
 #import tkgui.draw as draw
+import tool.movewin as movewin
+movewin.check_is_started("FX3","/opt/LibreLight/Xdesk/tkgui/FX3.py")
 
 
 def _add_space(frame,r,c):
@@ -138,20 +55,18 @@ def _draw_fx3(frame,c,r,gui,mode="FX"):
             c=0
             r+=1
             continue
+
         if comm == "\n":
             c=0
             r+=1
             continue
         v=0
-        if "PAN/TILT" in comm: 
-            b = tk.Button(frame,bg="grey", text=str(comm),width=6,height=1)
-        else:
-            b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=1)
-        if 1:#comm not in ct.elem:
-            #comm = comm.replace("\n","")
-            ct.elem[comm] = b
-            ct.val[comm] = 0
+        b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=1)
+
+        ct.elem[comm] = b
+        ct.val[comm] = 0
         b.bind("<Button>",tkevent.tk_event_fx(fix=0,elem=b,attr=comm,data=gui,mode=mode).cb)
+
         if comm == "xREC-FX":
             b["bg"] = "grey"
         elif comm == "xFX OFF":
@@ -159,43 +74,22 @@ def _draw_fx3(frame,c,r,gui,mode="FX"):
         elif comm[:3] == "xFX:" or comm[:3] == "x2D:":
             b["text"] = comm
             b["bg"] = "#ffbf00"
-        elif comm[:3] == "xMO:":
-            b["text"] = comm 
-            b["bg"] = "lightgreen"
-        elif comm.startswith( "xSIZE:"):
-            b["text"] = "SIZE:\n{:0.0f}".format(prm["SIZE"])
-            b["bg"] = "lightgreen"
-        elif comm.startswith( "xSPEED:"):
-            b["text"] = "SPEED:\n{:0.0f}".format(prm["SPEED"])
-            b["bg"] = "lightgreen"
-        elif comm.startswith("xSTART:"):
-            b["bg"] = "lightgreen"
-            b["text"] = "START:\n{:0.0f}".format(prm["START"])
-        elif comm.startswith( "xOFFSET:"):
-            b["bg"] = "lightgreen"
-            b["text"] = "OFFSET:\n{:0.0f}".format(prm["OFFSET"])
-        elif comm[:3] == "xBASE:":
-            b["bg"] = "lightgreen"
-            b["text"] = "BASE:\n{}".format(prm["BASE"])
-        elif comm[0] == "M":
-            b["text"] = comm 
-            b["bg"] = "lightgrey"
-
-        if 1:
-            if comm in MAIN.meta.fx3_grid:
-                fx_func = MAIN.meta.fx3_grid[comm]
-                fx_func.data["wrap"] = 1
-                #fx_func.inc()
-                v=fx_func.val()
-                print(fx_func,v)
-                b["text"] = v
-                if comm.startswith("TYPE:"): 
-                    b["bg"] = "orange"
-                    b.config(activebackground="#dd0")
-                for a in ["SPEED:","SIZE:","START:","OFFSET:"]:
-                    if comm.startswith(a): 
-                        b["bg"] = "lightgreen"
-                        b.config(activebackground="#0d0")
+
+        if comm in MAIN.meta.fx3_grid:
+            fx_func = MAIN.meta.fx3_grid[comm]
+            fx_func.data["wrap"] = 1
+            #fx_func.inc()
+            v=fx_func.val()
+            print(fx_func,v)
+            b["text"] = v
+            if comm.startswith("TYPE:"): 
+                b["bg"] = "orange"
+                b.config(activebackground="#dd0")
+            for a in ["SPEED:","SIZE:","START:","OFFSET:"]:
+                if comm.startswith(a): 
+                    b["bg"] = "lightgreen"
+                    b.config(activebackground="#0d0")
+
         if comm:
             b.grid(row=r, column=c, sticky=tk.W+tk.E)
         c+=1
@@ -207,25 +101,11 @@ def _draw_fx3(frame,c,r,gui,mode="FX"):
     return c,r
 
 def _draw_fx(frame,c,r,gui,mode="FX"):
+    ct  = None
+    prm = None
     if mode=="FX-MAIN":
         ct  = MAIN.meta.fx_main
         prm = MAIN.meta.fx_prm_main
-    elif mode=="FX-MOVE":
-        ct  = MAIN.meta.fx_moves
-        prm = MAIN.meta.fx_prm_move
-    elif mode=="FX":
-        ct  = MAIN.meta.fx_cfg
-        prm = MAIN.meta.fx_prm
-    elif mode=="FX-GENERIC":
-        ct  = MAIN.meta.fx_generic
-        prm = MAIN.meta.fx_prm #_generic
-    elif mode=="FX-COLOR":
-        ct  = MAIN.meta.fx_color
-        prm = MAIN.meta.fx_color #_generic
-    else:
-        ct = Elem_Container()
-        ct.labels =["err"]
-        prm = ["err"]
 
     for comm in ct.labels:
         if comm == "\n\n":
@@ -234,51 +114,25 @@ def _draw_fx(frame,c,r,gui,mode="FX"):
             c=0
             r+=1
             continue
+
         if comm == "\n":
             c=0
             r+=1
             continue
         v=0
-        if "PAN/TILT" in comm: 
-            b = tk.Button(frame,bg="grey", text=str(comm),width=6,height=2)
-        else:
-            b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
-        if 1:#comm not in ct.elem:
-            #comm = comm.replace("\n","")
-            ct.elem[comm] = b
-            ct.val[comm] = 0
+        b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
+
+        ct.elem[comm] = b
+        ct.val[comm] = 0
         b.bind("<Button>",tkevent.tk_event_fx(fix=0,elem=b,attr=comm,data=gui,mode=mode).cb)
+
         if comm == "REC-FX":
             b["bg"] = "grey"
         elif comm == "FX OFF":
             b["bg"] = "magenta"
-        elif comm[:3] == "FX:" or comm[:3] == "2D:":
-            b["text"] = comm
-            b["bg"] = "#ffbf00"
-        elif comm[:3] == "MO:":
-            b["text"] = comm 
-            b["bg"] = "lightgreen"
-        elif comm.startswith( "SIZE:"):
-            b["text"] = "SIZE:\n{:0.0f}".format(prm["SIZE"])
-            b["bg"] = "lightgreen"
-        elif comm.startswith( "SPEED:"):
-            b["text"] = "SPEED:\n{:0.0f}".format(prm["SPEED"])
-            b["bg"] = "lightgreen"
-        elif comm.startswith("START:"):
-            b["bg"] = "lightgreen"
-            b["text"] = "START:\n{:0.0f}".format(prm["START"])
-        elif comm.startswith( "OFFSET:"):
-            b["bg"] = "lightgreen"
-            b["text"] = "OFFSET:\n{:0.0f}".format(prm["OFFSET"])
-        elif comm[:3] == "BASE:":
-            b["bg"] = "lightgreen"
-            b["text"] = "BASE:\n{}".format(prm["BASE"])
-        elif comm[0] == "M":
-            b["text"] = comm 
-            b["bg"] = "lightgrey"
 
-        if comm:
-            b.grid(row=r, column=c, sticky=tk.W+tk.E)
+        b.grid(row=r, column=c, sticky=tk.W+tk.E)
+
         c+=1
         if c >=6:
             c=0
@@ -287,7 +141,7 @@ def _draw_fx(frame,c,r,gui,mode="FX"):
     r+=1
     return c,r
 
-def draw_fx3(gui,xframe,data=[]):
+def draw_fx3(gui,xframe):
     frame_fx=xframe
     i=0
     c=0
@@ -301,21 +155,13 @@ def draw_fx3(gui,xframe,data=[]):
     b.grid(row=r, column=c, sticky=tk.W+tk.E)
     c+=1
 
-    thread.start_new_thread(mytklib.tk_btn_bg_loop,(b,))
-    # ------------------------------
-
-
     _add_space(frame,r,c)
     c,r = _draw_fx(frame,c,r,gui,mode="FX-MAIN")
 
-    #r,c=_add_space(frame,r,c)
-    #c,r = _draw_fx(frame,c,r,gui,mode="FX-COLOR")
-
     r,c=_add_space(frame,r,c)
     c,r = _draw_fx3(frame,c,r,gui,mode="FX-3")
-import tool.movewin as movewin
-#movewin.check_is_started(CAPTION,_file_path)
-movewin.check_is_started("FX3","/opt/LibreLight/Xdesk/tkgui/FX3.py")
+
+
 
 _global_short_key = 1
 root = None
@@ -331,45 +177,23 @@ except:
 
 
 
-class Refresher(): # DUMMY
-    def __init__(self,*arg,**args):
-        print(self,"__init__",arg,args)
-    def reset(*arg,**args):
-        print(self,"reset",arg,args)
-
-class Command():
-    def __init__(self):
-        self.elem = {}
-
 class MANAGER(): # DUMMY
     def __init__(self,*arg,**args):
         print(self,"__init__",arg,args)
-        #self.refresh_fix = Refresher()
-        #self.commands = Command()
-    def refresh_fix(self,*arg,**args):# = Refresher()
-        print(self,"refresh_fix",arg,args)
-    def exec_go(self,nr,*arg,**args): #val=None,xfade=None,event=None,button="",ptfade=None):
+
+    def _go(self,nr,*arg,**args): #val=None,xfade=None,event=None,button="",ptfade=None):
         if _global_key_lock:
             return
-        #def exec_go(nr,xfade=None,val=0):
+
         print(self,"MASTER",nr,arg,args)
         btn_nr = nr
         v = args["val"]
         
         msg=json.dumps([{"event":"EXEC","EXEC":btn_nr+1,"VAL":v,"NR-KEY":btn_nr}]).encode("utf-8")
-        cprint("SEND MASTER.EXEC_GO:",msg,color="green")
+        cprint("SEND MASTER._GO:",msg,color="green")
         cmd_client.send(msg)
 
-def refresh_fix(*arg,**args): # DUMMY
-    print("refresh_fix",arg,args)
 
-class Refresher_fix(): # DUMMY
-    def __init__(self,*arg,**args):
-        print(self,"init",arg,args)
-    def reset(self,*arg,**args):
-        print(self,"reset",arg,args)
-
-refresher_fix =  Refresher_fix()
 
 class Modes(): # DUMMY
     def __init__(self,*arg,**args):
@@ -379,17 +203,7 @@ class Modes(): # DUMMY
         #print("Modes.val",arg,args)
         pass
 
-manager = MANAGER() # MASTER() #{}
-modes = Modes()
 
-import tkinter as tk
-class Exec(): # DUMMY
-    def __init__(self):
-        self.val_exec = {}
-        for i in range(512):
-            k=i #"ABC-{}".format(i+1)
-            self.val_exec[k] = {"NAME":"XX"}
-EXEC = Exec()
 class Gui(): # DUMMY
     def __init__(self):
         self.elem_exec = []
@@ -408,8 +222,7 @@ class Gui(): # DUMMY
             print("  ER1R mc...",e)
         return data 
 
-    def _refresh_exec(self,*arg,**args):
-        #print("EXEC_Gui._refresh_exec",arg,args)
+    def _refresh_data(self,*arg,**args):
         start = time.time()
 
         METAS = []
@@ -420,12 +233,11 @@ class Gui(): # DUMMY
         self.METAS = METAS
 
         for nr,b in enumerate( self.elem_exec): #[nr]
-            self._refresh_exec_single(nr,b,METAS)
-            #time.sleep(0.001)
+            self._refresh_data_single(nr,b,METAS)
 
-        print( "refres_exec:",time.time()-start )
+        print(__file__.split("/")[-1], "_refresh_data:",int((time.time()-start)*10)/10 )
 
-    def _refresh_exec_single(self,nr,b,METAS=None):
+    def _refresh_data_single(self,nr,b,METAS=None):
         start = time.time()
         no_meta = 0
 
@@ -441,179 +253,21 @@ class Gui(): # DUMMY
                 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)
-            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"
-            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
-        #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)
-
-        btn_nr = arg[0]
-        v=args["val"]
-        if "CFG-BTN" in modes.modes:
-            button = self.elem_exec[btn_nr]
-            label = str(btn_nr) #self.elem_meta[nr] = META
-            
-            if v:
-                META = self.elem_meta[btn_nr] 
-                dialog_cfg_open(btn_nr,META)
-            return #STOP
-
-        if "LABEL" in modes.modes:
-            button = self.elem_exec[btn_nr]
-            label = str(btn_nr) #self.elem_meta[nr] = META
-            
-            if v:
-                META = self.elem_meta[btn_nr] 
-                dialog_label_open(btn_nr,META)
-            return #STOP
-
-        #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}
-        if "num" in edata:
-            num = edata["num"]
-            if num == 1:
-                out["MOUSE"]="LEFT"
-            if num == 3:
-                out["MOUSE"]="RIGHT"
-
-        msg=json.dumps([out]).encode("utf-8")
-
-        if not _global_key_lock:
-            cmd_client.send(msg)
-        cprint("SEND GUI.EXEC_GO",msg,color="green")
-
-        if v == 0: # release btn
-            thread.start_new_thread(refresh_exec_btn,(btn_nr,))
 
+manager = MANAGER() 
+modes = Modes()
 gui  = Gui()
  
-
-
-
-import lib.libwin as libwin
-
-if 0:
-    name="FX3"
-    args = {"title":name,"master":0,"width":364,"height":418+30,"left":L1+10+W1,"top":TOP+302,"resize":1}
-    geo = libwin.filter_window_geo(geo_list,name)
-    if geo:
-        args.update(geo)
-    cls = draw_fx3 #(manager,w.tk)
-    data = []
-    cb_ok = None
-
-    c = libtk.window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=manager,scroll=0)
-    window_manager.new(None,name,wcb=c)
-    if libwin.split_window_show(geo_list,_filter=name):
-        window_manager.top(name)
-
-
-name="EXEC"
-pos_list = libwin.read_window_geo()
-geo = libwin.filter_window_geo(pos_list,name)
-args = {"title":name,"master":0,"width":600,"height":113,"left":30+5,"top":30+5+400*2+10}
-if geo:
-   args.update(geo)
-
 root = tk.Tk()
-root.maxsize(830,2000)
+root.maxsize(600,800)
 
 win_title="FX3"
 store = movewin.load_all_sdl(win_title)
 print(store)
-W=850
-H=460
-POS=[10,10]
+W=380
+H=500
+POS=[800,200]
 if store:
     W = store[-4]
     H = store[-3]
@@ -623,20 +277,19 @@ if store:
 root.geometry('%dx%d+%d+%d' % (W, H, POS[0],POS[1]))
 root.tk_setPalette(background='#bbb', foreground='black', activeBackground='#aaa', activeForeground="black")
 defaultFont = tk.font.nametofont("TkDefaultFont")
-defaultFont.configure(family="FreeSans",
-                       size=10,
-                       weight="bold")
+defaultFont.configure(family="FreeSans", size=10, weight="bold")
+
 # MAIN MENUE
 try:
     ico_path = "/opt/LibreLight/Xdesk/icon/"
-    root.iconphoto(False, tk.PhotoImage(file=ico_path+"exec.png"))
+    root.iconphoto(False, tk.PhotoImage(file=ico_path+"scribble.png"))
 except Exception as e:
     print(" Exception GUIWindowContainer.__init__",e)
 
 xframe = libtk.ScrollFrame(root,width=820,height=400,bd=1,bg="black",head=None,foot=None)
-#draw_exec(gui,xframe,EXEC)
-draw_fx3(gui,xframe,EXEC)
-root.title(title) #"TK-EXEC")
+draw_fx3(gui,xframe)
+
+root.title(title) 
 
 root.bind("<Button>",libtk2.tk_event)#
 root.bind("<Key>",libtk2.tk_event)#,self.callback)
@@ -644,7 +297,6 @@ root.bind("<KeyRelease>",libtk2.tk_event)#,self.callback)
 #root.bind("<FocusIn>",libtk2.tk_event)#, on_focus(self.args["title"],"In").cb)
 #root.bind("<FocusOut>",libtk2.tk_event)#, on_focus(self.args["title"],"Out").cb)
 
-import os
 
 _global_key_lock = 0
 def focus_in(event=None):
@@ -673,10 +325,13 @@ root.bind("<FocusOut>", focus_out)
 def _refr_loop():
     time.sleep(3)
     while 1:
-        gui._refresh_exec()
-        time.sleep(3)
-
-thread.start_new_thread(_refr_loop,())
+        try:
+            gui._refresh_data()
+            time.sleep(3)
+        except Exception as e:
+            print("  ER5R refr_loop()...",e)
+            time.sleep(3)
+        time.sleep(0.1)
 
 def _refr_loop2():
     time.sleep(3)
@@ -688,6 +343,7 @@ def _refr_loop2():
             data = json.loads(data)
             #print("MODES",data)
             modes.modes = data
+
             if root:
                 root.title(title2)
             if "S-KEY" in data:
@@ -709,6 +365,7 @@ def _refr_loop2():
             time.sleep(3)
         time.sleep(0.1)
 
+thread.start_new_thread(_refr_loop,())
 thread.start_new_thread(_refr_loop2,())
 
 root.mainloop()

+ 7 - 1
tool/movewin.py

@@ -138,13 +138,14 @@ def get_store_sdl_line():
     lines.extend( winfo2(name="RAY-"))
     lines.extend( winfo2(name="R-"))
     lines.extend( winfo2(name="EXEC-BTN"))
+    lines.extend( winfo2(name="FX3"))
     lines.extend( winfo2(name="EXEC-XWING"))
     out_lines=[]
     for line in lines:
         t=line[2].split()
         for k in t:
             k = k.replace(" ", "_")
-            for j in ["SDL-","RAY-","R-","TK-","EXEC-BTN", "EXEC-XWING"]:
+            for j in ["SDL-","RAY-","R-","TK-","EXEC-BTN","FX3", "EXEC-XWING"]:
                 if not k.startswith(j): 
                     continue
                 s=line[-2]
@@ -257,6 +258,11 @@ def startup_all_sdl():
                 cmd=cmd.format("fix.py")
                 #r=os.popen(cmd)
                 start_sub(cmd,"SDL-FIX",mute=1)
+            elif line[1] == "FX3":
+                cmd = "python3 /opt/LibreLight/Xdesk/tkgui/{}"
+                cmd=cmd.format("FX3.py")
+                #r=os.popen(cmd)
+                start_sub(cmd,"FX3",mute=1)
             elif line[1] == "EXEC-BTN":
                 cmd = "python3 /opt/LibreLight/Xdesk/tkgui/{}"
                 cmd=cmd.format("EXEC-BTN.py")