Эх сурвалжийг харах

cleanup: FIXTURE.fix GUIHandler, extract MENUE

micha 3 сар өмнө
parent
commit
f6f1d197ce
4 өөрчлөгдсөн 156 нэмэгдсэн , 137 устгасан
  1. 2 2
      _LibreLightDesk.py
  2. 0 2
      lib/fixlib.py
  3. 0 133
      tkgui/GUI.py
  4. 154 0
      tkgui/MENUE.py

+ 2 - 2
_LibreLightDesk.py

@@ -1670,6 +1670,7 @@ dialog = dialoglib.Dialog()
 
 from tkgui.draw import *
 from tkgui.GUI import *
+import tkgui.MENUE as MENUE
 
 
 
@@ -1880,7 +1881,6 @@ def refresh_exec_mc():
 thread.start_new_thread(refresh_exec_mc,())
 
 FIXTURES = fixlib.Fixtures()
-FIXTURES.gui = GUIHandler()
 
 def LOAD_SHOW():
     EXEC.load_exec()
@@ -2045,7 +2045,7 @@ if __run_main:
     if geo:
         args.update(geo)
 
-    cls = GUI_menu 
+    cls = MENUE.GUI_menu 
     cb_ok = None
 
     c = libtk.window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)

+ 0 - 2
lib/fixlib.py

@@ -635,8 +635,6 @@ class Fixtures():
         self.base=showlib.Base()
         #self.load()
         self.fixtures = OrderedDict()
-        self.gui = None # GUIHandler()
-
 
     def load_patch(self):
         cprint("Fixtures.load_patch ..")

+ 0 - 133
tkgui/GUI.py

@@ -170,14 +170,6 @@ class _TableFrame():
 
 
 
-class GUIHandler():
-    def __init__(self):
-        pass
-    def update(self,fix,attr,args={}):
-        print("GUIHandler.update()",fix,attr,args)
-        for i,k in enumerate(args):
-            v = args[k] 
-            #print("GUI-H", i,k,v)
 
 
 
@@ -1190,128 +1182,3 @@ class GUI_MasterWingLayout():
             e["text"] = txt
 
 
-class BEvent():
-    def __init__(self,data,cb):
-        self._data = data
-        self._cb = cb
-    def cb(self,event):
-        #print(self,event)
-        self._cb(event,self._data)
-
-
-
-
-
-class GUI_menu():
-    def __init__(self,root,frame ,data,title="tilte"):
-        global tk
-        global INIT_OK
-        self.frame = frame
-        self.data = data
-        self.elem = {}
-        self.root = root
-        self.draw()
-
-    def draw(self):
-        cprint("***",self,"draw")
-        r=0
-        c=0
-        i=1
-        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")
-        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:
-                text = row["name"]
-            else:
-                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)
-            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()
-
-    def start_loop(self):
-        print(self,"--- start_bg_loop ----- xxxx")
-        thread.start_new_thread(mytklib.tk_btn_bg_loop,(self.TITLE,))
-
-    def on_top(self,event,data={}):
-        print("menue.on_top",data)
-        MAIN.window_manager.top(data["text"])
-
-    def update(self,button,text):
-        #print(self,button,text)
-        for k in self.elem:
-            v=self.elem[k]
-            #print(self,k,v)
-            if button == k:
-                v["elem"]["text"] = k+"\n"+text
-
-    def config(self,button,attr,value):
-        #print("config",self,button,attr,value)
-        for k in self.elem:
-            v=self.elem[k]
-            #print(self,k,v)
-            if button == k:
-                #print(dir(v["elem"]))
-                if attr == "bg":
-                    if value == "":
-                        value = "lightgrey"
-                    v["elem"][attr] = str(value)
-                if attr == "activebackground":
-                    if value == "":
-                        value = "lightgrey"
-                    v["elem"][attr] = str(value)
-

+ 154 - 0
tkgui/MENUE.py

@@ -0,0 +1,154 @@
+#!/usr/bin/python3
+
+import _thread as thread
+import time
+import copy
+
+from collections import OrderedDict
+
+import tkinter 
+tk = tkinter 
+
+from idlelib.tooltip import Hovertip
+
+import tkgui.dialog  as dialoglib
+dialog = dialoglib.Dialog()
+
+import __main__ as MAIN
+
+from lib.cprint import *
+
+
+import lib.mytklib as mytklib
+import lib.fixlib  as fixlib
+import lib.showlib as showlib
+import lib.libtk   as libtk
+import lib.tkevent as tkevent
+
+
+
+class BEvent():
+    def __init__(self,data,cb):
+        self._data = data
+        self._cb = cb
+    def cb(self,event):
+        #print(self,event)
+        self._cb(event,self._data)
+
+
+
+
+
+class GUI_menu():
+    def __init__(self,root,frame ,data,title="tilte"):
+        global tk
+        global INIT_OK
+        self.frame = frame
+        self.data = data
+        self.elem = {}
+        self.root = root
+        self.draw()
+
+    def draw(self):
+        cprint("***",self,"draw")
+        r=0
+        c=0
+        i=1
+        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")
+        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:
+                text = row["name"]
+            else:
+                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)
+            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()
+
+    def start_loop(self):
+        print(self,"--- start_bg_loop ----- xxxx")
+        thread.start_new_thread(mytklib.tk_btn_bg_loop,(self.TITLE,))
+
+    def on_top(self,event,data={}):
+        print("menue.on_top",data)
+        MAIN.window_manager.top(data["text"])
+
+    def update(self,button,text):
+        #print(self,button,text)
+        for k in self.elem:
+            v=self.elem[k]
+            #print(self,k,v)
+            if button == k:
+                v["elem"]["text"] = k+"\n"+text
+
+    def config(self,button,attr,value):
+        #print("config",self,button,attr,value)
+        for k in self.elem:
+            v=self.elem[k]
+            #print(self,k,v)
+            if button == k:
+                #print(dir(v["elem"]))
+                if attr == "bg":
+                    if value == "":
+                        value = "lightgrey"
+                    v["elem"][attr] = str(value)
+                if attr == "activebackground":
+                    if value == "":
+                        value = "lightgrey"
+                    v["elem"][attr] = str(value)
+