#!/usr/bin/python3 import os import time import tkinter tk = tkinter import __main__ as MAIN from lib.cprint import * import lib.libwin as libwin class on_focus(): def __init__(self,name,mode): self.name = name self.mode = mode def cb(self,event=None): print("on_focus",event,self.name,self.mode) try: e = master.commands.elem["."] except:pass if self.mode == "Out": cmd="xset -display :0.0 r rate 240 20" print(cmd) os.system(cmd) try: e["bg"] = "#aaa" e["activebackground"] = "#aaa" except:pass if self.mode == "In": cmd = "xset -display :0.0 r off" print(cmd) os.system(cmd) try: e["bg"] = "#fff" e["activebackground"] = "#fff" except:pass class DummyCallback(): def __init__(self,name="name"): self.name = name def cb(self,event=None): cprint("DummyCallback.cb",[self.name,event]) class Window(): def __init__(self,args): #title="title",master=0,width=100,height=100,left=None,top=None,exit=0,cb=None,resize=1): global lf_nr self.args = {"title":"title","master":0,"width":100,"height":100,"left":None,"top":None,"exit":0,"cb":None,"resize":1} self.args.update(args) cprint("Window.init()",id(self.args),color="yellow") cprint(" ",self.args,color="yellow") ico_path="./icon/" self.cb = MAIN.cb if self.args["master"]: self.tk = tkinter.Tk() self.tk.protocol("WM_DELETE_WINDOW", self.close_app_win) self.tk.withdraw() # do not draw self.tk.resizable(self.args["resize"],self.args["resize"]) defaultFont = tkinter.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: cprint("Exception GUIWindow.__init__",e) else: # addtional WINDOW self.tk = tkinter.Toplevel() self.tk.iconify() #self.tk.withdraw() # do not draw self.tk.protocol("WM_DELETE_WINDOW", self.close_app_win) self.tk.resizable(self.args["resize"],self.args["resize"]) try: if "COLORPICKER" in self.args["title"]: self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"picker.png")) elif "ENCODER" in self.args["title"]: self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"enc.png")) elif "EXEC" in self.args["title"]: self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"exec.png")) elif "FX" in self.args["title"]: self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"fx.png")) else: self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"scribble.png")) except Exception as e: cprint("Exception on load window icon",self.args["title"]) cprint("Exception:",e) #time.sleep(3) self.tk.deiconify() self.tk["bg"] = "black" self.tk.bind("