Forráskód Böngészése

add: ON-Focus bg:aaa od bg:bbb change: blinking window title's

micha 1 éve
szülő
commit
168a631c16
2 módosított fájl, 34 hozzáadás és 11 törlés
  1. 8 3
      _LibreLightDesk.py
  2. 26 8
      lib/mytklib.py

+ 8 - 3
_LibreLightDesk.py

@@ -2419,7 +2419,7 @@ class MASTER():
         self.commands = Elem_Container()
         self.commands.commands =["\n","ESC","CFG-BTN","LABEL","-","DEL","-","\n"
                 ,"SELECT","FLASH","GO","-","MOVE","S-KEY","\n"
-                ,"BLIND","CLEAR","REC","EDIT","COPY","-","\n" 
+                ,"BLIND","CLEAR","REC","EDIT","COPY",".","\n" 
                 ]
         self.elem_presets = {}
         
@@ -4155,14 +4155,19 @@ class on_focus():
         self.mode = mode
     def cb(self,event=None):
         print("on_focus",event,self.name,self.mode)
+        e = master.commands.elem["."]
         if self.mode == "Out":
             cmd="xset -display :0.0 r rate 240 20"
             print(cmd)
             os.system(cmd)
+            e["bg"] = "#aaa"
+            e["activebackground"] = "#aaa"
         if self.mode == "In":
             cmd = "xset -display :0.0 r off"
             print(cmd)
             os.system(cmd)
+            e["bg"] = "#fff"
+            e["activebackground"] = "#fff"
 
 class Window():
     def __init__(self,args): #title="title",master=0,width=100,height=100,left=None,top=None,exit=0,cb=None,resize=1):
@@ -4222,8 +4227,8 @@ class Window():
         self.tk.bind("<Button>",self.callback)
         self.tk.bind("<Key>",self.callback)
         self.tk.bind("<KeyRelease>",self.callback)
-        self.tk.bind("<FocusIn>", on_focus("master","In").cb)
-        self.tk.bind("<FocusOut>", on_focus("master","Out").cb)
+        self.tk.bind("<FocusIn>", on_focus(self.args["title"],"In").cb)
+        self.tk.bind("<FocusOut>", on_focus(self.args["title"],"Out").cb)
 
         self.tk.title(""+str(self.args["title"])+" "+str(lf_nr)+":"+str(rnd_id))
         lf_nr+=1

+ 26 - 8
lib/mytklib.py

@@ -5,20 +5,38 @@ import time
 #import _thread as thread
 
 
-def tk_btn_bg_loop(btn,c1="#00fafa",c2="#0ff"):
+def tk_btn_bg_loop(btn,c1="#00ff00",c2="#00f",stime=time.time()):
+    while time.time() < stime+10:
+        time.sleep(0.1)
+    #time.sleep(10)
     print("tk_btn_loop",btn,c1,c2,"sleep 20")
-    time.sleep(20)
+    flip = 0
+    change = 0
+    t_last = time.time()
     try:
         while 1:
-            #print(self,"----- xxxx")
+            #t = int(time.time()*1000)
+            #if t % 500 == 0: 
+            #    change = 1
+            #    time.sleep(.001)
+            #else: 
+            #    time.sleep(.001)
+            #    continue
+            change = 1
             time.sleep(0.5)
-            btn["bg"] = c1 # "#0ee"
-            time.sleep(0.5)
-            btn["bg"] = c2 #"#0ff"
-            #print(self,"----- xxxx")
+            if change:
+                #print(btn,"change",str(t)[:-3],btn["text"])
+
+                if flip:flip = 0
+                else:flip = 1
+
+                if flip:c = c1
+                else:c = c2
 
+                btn["bg"] = c 
     except Exception as e:
-        print(__file__,"loop() exception",e)
+        print(__file__,"loop() exception")
+        print(e)
         time.sleep(3)
 
 #usage