Browse Source

fix: close-win RESTART, fix:main_menue ..

micha 3 months ago
parent
commit
359bd2d318
5 changed files with 96 additions and 11 deletions
  1. 3 0
      lib/libwin.py
  2. 12 4
      lib/tkevent.py
  3. 12 2
      tkgui/EXEC-BTN.py
  4. 44 4
      tkgui/GUI.py
  5. 25 1
      tkray/dmx.py

+ 3 - 0
lib/libwin.py

@@ -42,6 +42,9 @@ def save_window_position(save_as=""):
             if win.tk.winfo_exists():
                 data[2] = win.tk.geometry()
                 data[0] = 1
+                if k == "MAIN":
+                    data[2] = "84x"+data[2].split("x")[-1]
+
                 if k not in  window_list_buffer:
                     cprint("  -- new:win:pos",k.ljust(15," "),data) #,color="yellow")
                 elif window_list_buffer[k][2] != data[2] and data[2]: #geo

+ 12 - 4
lib/tkevent.py

@@ -7,6 +7,7 @@ import traceback
 
 from lib.cprint import cprint
 import __main__ as MAIN
+import _thread as thread
 
 import lib.showlib as showlib
 import lib.fxlib as fxlib
@@ -38,16 +39,18 @@ class tk_event():
             self.elem["bg"] = "red"
             self.elem.config(activebackground="orange")
 
-            MAIN.modes.val(self.attr,1)
-
             MAIN.save_show()
+            MAIN.modes.val(self.attr,1)
 
             self.elem["bg"] = "lightgrey"
             self.elem.config(activebackground="lightgrey")
             b = libtk.BLINKI(self.elem)
             b.blink()
             self.elem["text"] = "SAVE\nSHOW"
-
+            def xxyy():
+                time.sleep(3)
+                MAIN.modes.val(self.attr,0)
+            thread.start_new_thread(xxyy,())
         elif self.attr == "LOAD\nSHOW":
             name = "LOAD-SHOW"
             line1 = "PATH: " + showlib.current_show_path()
@@ -105,13 +108,14 @@ class tk_event():
             self.elem["text"] = "SAVING..."
             self.elem["bg"] = "red"
             self.elem.config(activebackground="orange")
-            MAIN.modes.val(self.attr,1)
 
             MAIN.save_show()
 
             self.elem["text"] = "RESTARTING..."
             self.elem["bg"] = "lightgrey"
             self.elem.config(activebackground="lightgrey")
+
+            MAIN.modes.val(self.attr,1)
             MAIN.LOAD_SHOW_AND_RESTART("").cb(force=1)
 
         elif self.attr == "DRAW\nGUI":
@@ -125,11 +129,15 @@ class tk_event():
 
         elif self.attr == "PRO\nMODE":
             MAIN.save_show()
+            MAIN.modes.val(self.attr,1)
+
             import lib.restart as restart
             restart.pro()
 
         elif self.attr == "EASY\nMODE":
             MAIN.save_show()
+            MAIN.modes.val(self.attr,1)
+
             import lib.restart as restart
             restart.easy()
         else:

+ 12 - 2
tkgui/EXEC-BTN.py

@@ -193,6 +193,7 @@ cmd_client = chat.Client(port=30003)
 try:
     import memcache
     mc = memcache.Client(['127.0.0.1:11211'], debug=0)
+    #data = mc.get("MODES")
 except:
     mc = None
 
@@ -536,12 +537,21 @@ def _refr_loop2():
             data = json.loads(data)
             #print("MODES",data)
             modes.modes = data
+            if root:
+                root.title(title2)
             if "S-KEY" in data:
                 _global_short_key = 0
                 if data["S-KEY"]:
                     _global_short_key = 1
-            if root:
-                root.title(title2)
+
+            for k in data:
+                print("title",k)
+                if "RESTART" in k or "PRO" in k or "EAYS" in k:
+                    print("RESTART !!!")
+                    time.sleep(0.5)
+                    root.quit()
+                    #sys.exit()
+
         except Exception as e:
             print("  ER7R mc...",e)
             time.sleep(3)

+ 44 - 4
tkgui/GUI.py

@@ -1209,6 +1209,7 @@ class GUI_menu():
         self.frame = frame
         self.data = data
         self.elem = {}
+        self.root = root
         self.draw()
 
     def draw(self):
@@ -1219,26 +1220,65 @@ class GUI_menu():
         self.b = tk.Label(self.frame,bg="lightblue", text="MAIN:MENU",width=8,height=1)
         self.TITLE = self.b
         self.b.grid(row=r, column=c, sticky=tk.W+tk.E)#,anchor="w")
-        r+=1
+        BUF = []
+        for j in range(3):
+            BUF.append([""]*40)
+        print(BUF)
+        r=0
         h = 2
         for row in self.data:
             print("  draw",row)
+            text="<TXT>"
+
             #row = data[i]
             if row["text"] == "---":
                 h=1
+
             if "name" in row:
-                self.b = tk.Button(self.frame,bg="lightgrey", text=row["name"],width=8,height=h)
+                text = row["name"]
             else:
-                self.b = tk.Button(self.frame,bg="lightgrey", text=row["text"],width=8,height=h)
+                text = row["text"]
+
+            if "- DEMO -"  == text:
+                c=2
+                r=1
+            b = tk.Button(self.frame,bg="lightgrey", text=text,width=8,height=h)
+            self.b = b
+
             if "tip" in row:
                 from idlelib.tooltip import Hovertip
                 myTip = Hovertip(self.b,row["tip"])
+
             self.b.bind("<Button>",BEvent({"NR":i,"text":row["text"]},self.on_top).cb)
-            self.b.grid(row=r, column=c, sticky=tk.W+tk.E)#,anchor="w")
+            BUF[c][r] = b
+            #self.b.grid(row=r, column=c, sticky=tk.W+tk.E)#,anchor="w")
             row["elem"] = self.b
             self.elem[row["text"]] = row
+
             r+=1
             i+=1
+    
+        r=1
+        c=0
+        for rows in BUF:
+            h=2
+            for b in rows:
+                print("b",type(b))
+                text=""
+                if r > 6:
+                    h=1
+                if type(b) is str:
+                    b = tk.Button(self.frame,bg="lightgrey", text=text,width=8,height=h)
+                    b.grid(row=r, column=c, sticky=tk.W+tk.E)#,anchor="w")
+                else:
+                    b["height"] = h
+                    b.grid(row=r, column=c, sticky=tk.W+tk.E)#,anchor="w")
+
+                r+=1
+            c+=1
+            r=1
+        
+        self.BUF = BUF
         self.frame.pack()
         INIT_OK = 1
         self.start_loop()

+ 25 - 1
tkray/dmx.py

@@ -15,10 +15,20 @@ import tool.movewin as movewin
 
 import pathlib
 
+
+try:
+    import memcache
+    mc = memcache.Client(['127.0.0.1:11211'], debug=0)
+    #data = mc.get("MODES")
+except:
+    mc = None
+
+
 _file_path=pathlib.Path(__file__)
 print("file:",_file_path)
 movewin.check_is_started(CAPTION,_file_path)
 
+
 win_title =CAPTION.strip().split()[-1]
 store = movewin.load_all_sdl(win_title)
 print(store)
@@ -304,6 +314,9 @@ spectrum_btn.btn.btn1.color    = pyray.YELLOW # [127,127,127,255]
 spectrum_btn.btn.btn1.color_on = pyray.YELLOW # [127,127,127,255]
 
 add=0
+modes_data = {}
+modes_time = time.time()
+
 while not pyray.window_should_close():
     pyray.begin_drawing()
 
@@ -311,7 +324,18 @@ while not pyray.window_should_close():
     pyray.Color(255,0,0,0)
     pyray.rl_enable_smooth_lines()
 
-
+    try:
+        if modes_time+1 < time.time():
+            modes_time = time.time()
+            modes_data = mc.get("MODES")
+            pyray.set_window_title("RAY-DMX "+str(modes_data))
+            if "RESTART" in str(modes_data) or "PRO" in str(modes_data) or "EASY" in str(modes_data):
+                pyray.close_window()
+    except Exception as e:# KeyInterupt
+        print("err",e)
+        import traceback
+        print(traceback.format_exc())
+        time.sleep(1)
 
     font_size = font10.baseSize
     try: