import json import time import sys import tkinter as tk from tkinter import font import traceback import _thread as thread import dialog DIALOG = dialog.Dialog() gui=None GLOBAL_old_btn_nr = -1 def Dcb(exec_nr): #DAILOG CONFIG CALLBACK def _Dcb(*args): print("Dcb:",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) def _X_refresh(): global GLOBAL_old_btn_nr if 1:#REFRESH: btn_nr = exec_nr time.sleep(1.2) print() print("CFG CB REFRESH !?",btn_nr) nr = btn_nr-1 b = gui.elem_exec[nr] gui._refresh_exec_single(nr,b) #,METAS): time.sleep(0.2) nr2= GLOBAL_old_btn_nr if nr2 >= 0 and nr2 != nr: gui._refresh_exec_single(nr2,b) #,METAS): print("CFG CB2 REFRESH ",nr,nr2) if 1: GLOBAL_old_btn_nr = nr thread.start_new_thread(_X_refresh,()) return _Dcb DIALOG._cb = Dcb(-3) #d = dialog.Dialog() #d.ask_exec_config(str(nr+1),button=button,label=label,cfg=cfg) import __main__ as MAIN _file_path = "/opt/LibreLight/Xdesk/" sys.path.insert(0,"/opt/LibreLight/Xdesk/") import tool.git as git #CAPTION += git.get_all() CAPTION = "TK-EXEC" title = CAPTION title += git.get_all() INIT_OK = 1 IS_GUI = 0 from lib.cprint import cprint import lib.libtk as libtk import lib.zchat as chat import lib.mytklib as mytklib import lib.tkevent as tkevent #import tkgui.draw as draw def draw_exec(gui,xframe,EXEC): i=0 c=0 r=0 root = xframe frame = tk.Frame(root,bg="black") frame.pack(fill=tk.X, side=tk.TOP) gui.elem_exec = {} i=0 for k in EXEC.val_exec: if i%(10*8)==0 or i ==0: c=0 b = tk.Canvas(frame,bg="black", height=4,bd=0,width=6,highlightthickness=0) #,bd="black") b.grid(row=r, column=c, sticky=tk.W+tk.E) r+=1 c=0 b = tk.Button(frame,bg="lightblue", text="EXEC " ) b.grid(row=r, column=c, sticky=tk.W+tk.E) c+=1 b = tk.Button(frame,bg="lightblue", text="BANK " + str(int(i/(8*8))+1) ) b.grid(row=r, column=c, sticky=tk.W+tk.E) c+=1 b = tk.Button(frame,bg="lightblue", text="NAME" ) b.grid(row=r, column=c, sticky=tk.W+tk.E) c+=7 if i == 0: b = tk.Button(frame,bg="darkgrey", text="HELP",command=libtk.online_help("librelight:20-exec")) #"0&do=index")) b.grid(row=r, column=c, sticky=tk.W+tk.E) r+=1 c=0 i+=1 v=0 label = "" sdata=EXEC.val_exec[k] BTN="go" if "CFG" in sdata:#["BUTTON"] = "GO" if "BUTTON" in sdata["CFG"]: BTN = sdata["CFG"]["BUTTON"] txt=str(k+1)+":"+str(BTN)+":"+str(len(sdata)-1)+"\n"+label b = mytklib.ExecButton(frame,text=txt) b.bind("