浏览代码

add: new independent EXEC window (not refreshing)

micha 8 月之前
父节点
当前提交
e42753de4b
共有 3 个文件被更改,包括 174 次插入0 次删除
  1. 3 0
      lib/execlib.py
  2. 2 0
      lib/mytklib.py
  3. 169 0
      tkgui/EXEC.py

+ 3 - 0
lib/execlib.py

@@ -142,6 +142,9 @@ class EXEC(): #Presets():
                 key="EXEC-"+str(i) 
                 mc.set(key,json.dumps(d[v]))
                 index.append(key)
+
+                key2="EXEC-LABEL-"+str(i) 
+                mc.set(key2,l[i] )
             mc.set("EXEC-INDEX",json.dumps(index))
             print("---------------------------------------",start - time.time())
 

+ 2 - 0
lib/mytklib.py

@@ -1,6 +1,8 @@
 #!/usr/bin/python3
 
 import tkinter as tk
+from tkinter import font
+
 import time
 #import _thread as thread
 import os

+ 169 - 0
tkgui/EXEC.py

@@ -0,0 +1,169 @@
+
+import json
+import time
+import sys
+
+import tkinter as tk
+import traceback
+import _thread as thread
+
+
+
+import __main__ as MAIN
+
+sys.path.insert(0,"/opt/LibreLight/Xdesk/")
+
+
+IS_GUI = 0
+import tkgui.draw as draw
+
+#import lib.mytklib as mytklib
+import lib.libtk as libtk
+#import lib.tkevent as tkevent
+#import lib.fixlib as fixlib
+
+from lib.cprint import cprint
+
+
+try:
+    import memcache
+    mc = memcache.Client(['127.0.0.1:11211'], debug=0)
+except:
+    mc = None
+
+
+
+
+
+
+class Refresher():
+    def __init__(self,*arg,**args):
+        print(self,"__init__",arg,args)
+    def reset(*arg,**args):
+        print(self,"reset",arg,args)
+    
+class MASTER():
+    def __init__(self,*arg,**args):
+        print(self,"__init__",arg,args)
+        #self.refresh_fix = Refresher()
+    def refresh_fix(self,*arg,**args):# = Refresher()
+        print(self,"refresh_fix",arg,args)
+
+def refresh_fix(*arg,**args):
+    print("refresh_fix",arg,args)
+
+class Refresher_fix():
+    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():
+    def __init__(self,*arg,**args):
+        print("refresh_fix",arg,args)
+    def val(self,*arg,**args):
+        print("val",arg,args)
+
+master = MASTER() #{}
+modes = Modes()
+
+import tkinter as tk
+class Exec():
+    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():
+    def __init__(self):
+        self.elem_exec = []
+    def _refresh_exec(self,*arg,**args):
+        print("Gui",arg,args)
+        #_XX +=1
+        # _nr_ok = 0
+
+        nr = 14-1
+        jdata = {}
+        keys = []
+        
+        labels = []
+        if 10:
+            nr = 0
+            for i in range(512):
+                nr = i #+1
+                label = "err-{}".format(nr)
+                try:
+                    label = mc.get("EXEC-LABEL-"+str(nr)) #,json.dumps(index))
+                except Exception as e:
+                    print("  ER1R mc...",e)
+                labels.append(label)
+
+            try:
+                y = mc.get("EXEC-"+str(nr)) #,json.dumps(index))
+                jdata = json.loads(y)
+                keys  = jdata.keys()
+            except Exception as e:
+                print("  ER2R mc...",e,nr)
+        
+        #for nr in EXEC.val_exec: 
+        #for nr in range(200):
+        for nr,b in enumerate( self.elem_exec): #[nr]
+            out = {} # default
+            out["fx"] = ""
+            out["bg"] = "grey"
+            out["ba"] = "grey"
+            out["fg"] = "#999" #black" #grey"
+            out["text"] = "? "+str(nr+1)
+            
+        
+            try: 
+                out["text"] = "GO\n"+str(labels[nr])
+                if len(labels[nr]) >= 3:
+                    out["bg"] = "orange" #yellow"
+                    out["fg"] = "black" #grey"
+            except Exception as e:
+                print("  ER4R",e,nr)
+                time.sleep(0.001)
+            #xout["fx"] = fx_color
+            #xout["bg"] = _bg
+            #xout["ba"] = _ba
+            #xout["fg"] = _fg
+            #out["text"] = _text
+            
+            #return out
+            cfg = out #get_exec_btn_cfg(nr)
+
+            b = self.elem_exec[nr]
+            b.configure(fg=cfg["fg"],bg=cfg["bg"],activebackground=cfg["ba"],text=cfg["text"],fx=cfg["fx"])
+    def exec_go(*arg,**args):
+        print("Gui",arg,args)
+
+gui  = Gui()
+
+
+root = tk.Tk()
+
+#root.withdraw() # do not draw
+#root.resizable(1,1)
+root.tk_setPalette(background='#bbb', foreground='black', activeBackground='#aaa', activeForeground="black")
+
+defaultFont = tk.font.nametofont("TkDefaultFont")
+#cprint(defaultFont)
+defaultFont.configure(family="FreeSans",
+                       size=10,
+                       weight="bold")
+# MAIN MENUE
+#try:
+#    self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"main.png"))
+#except Exception as e:
+#    print(" Exception GUIWindowContainer.__init__",e)
+
+#xframe=root
+xframe = libtk.ScrollFrame(root,width=820,height=400,bd=1,bg="black",head=None,foot=None)
+draw.draw_exec(gui,xframe,EXEC)
+#xframe.pack()
+
+root.mainloop()