_LibreLightDesk.py 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. (c) 2012 micha@librelight.de
  5. SPDX-License-Identifier: GPL-2.0-only
  6. """
  7. import random
  8. import subprocess
  9. import string
  10. import copy
  11. import traceback
  12. import json
  13. import time
  14. import sys
  15. import os
  16. import _thread as thread
  17. for i in range(30):
  18. print() # boot space
  19. IS_GUI = 0
  20. if __name__ == "__main__":
  21. IS_GUI = 1
  22. import tool.movewin as movewin
  23. import lib.fixlib as fixlib
  24. import lib.libwin as libwin
  25. import lib.libtk as libtk
  26. rnd_id = str(random.randint(100,900))
  27. rnd_id += " beta"
  28. rnd_id2 = ""
  29. rnd_id3 = ""
  30. _ENCODER_WINDOW = None
  31. __run_main = 0
  32. if __name__ == "__main__":
  33. __run_main = 1
  34. else:
  35. import __main__
  36. if "unittest" not in dir(__main__):
  37. __run_main = 1
  38. import tool.git as git
  39. rnd_id += git.get_all()
  40. try:
  41. xtitle = __file__
  42. except:
  43. xtitle = "__file__"
  44. if "/" in xtitle:
  45. xtitle = xtitle.split("/")[-1]
  46. sys.stdout.write("\x1b]2;"+str(xtitle)+" "+str(rnd_id)+"\x07") # terminal title
  47. HOME = os.getenv('HOME')
  48. space_font = None
  49. if IS_GUI:
  50. import tkinter
  51. import tkinter as tk
  52. from tkinter import font
  53. import tkinter.simpledialog
  54. from idlelib.tooltip import Hovertip
  55. INIT_OK = 0
  56. _global_short_key = 1
  57. path = "/home/user/LibreLight/"
  58. #os.chdir(path)
  59. f = open(path+"init.txt","r")
  60. lines=f.readlines()
  61. f.close()
  62. out = []
  63. for line in lines:
  64. if line != "EASY\n":
  65. out.append(line)
  66. f = open(path+"init.txt","w")
  67. f.writelines(out)
  68. f.close()
  69. if "--easy" in sys.argv:
  70. f = open(path+"init.txt","a")
  71. f.write("EASY\n")
  72. f.close()
  73. if not os.path.isdir(path+"show/EASY"):
  74. cmd = "cp -vrf '/opt/LibreLight/Xdesk/home/LibreLight/show/EASY' '{}/show/EASY' ".format(path)
  75. print(cmd)
  76. #input()
  77. os.system(cmd)
  78. # check if EASY show exist !
  79. from lib.cprint import cprint
  80. cprint("________________________________")
  81. def cb(**args):
  82. cprint("MAIN.cb DUMMY",**args,color="red")
  83. import lib.zchat as chat
  84. import lib.motion as motion
  85. from collections import OrderedDict
  86. _FIX_FADE_ATTR = ["PAN","TILT","DIM","RED","GREEN","BLUE","WHITE","CYAN","YELLOW","MAGENTA","FOCUS","ZOOM","FROST"]
  87. CUES = OrderedDict()
  88. groups = OrderedDict()
  89. class Modes():
  90. def __init__(self):
  91. self.modes = {}
  92. self.__cfg = {}
  93. self.__cb = None
  94. def val(self,mode,value=None): #like jquery
  95. if value is not None:
  96. return self.set(mode,value)
  97. elif mode in self.modes:
  98. return self.modes[mode]
  99. def get(self,mode,value=None):
  100. return self.val(mode,value)
  101. def __check(self,mode):
  102. if mode not in self.modes:
  103. self.modes[mode] = 0
  104. self.__cfg[mode] = 0
  105. def cfg(self,mode,data={}):
  106. self.__check(mode)
  107. if type(data) is dict:
  108. for k in data:
  109. v = data[k]
  110. if v not in self.__cfg:
  111. self.__cfg[k] = v
  112. return 1
  113. elif type(data) is str:
  114. if data in self.__cfg:
  115. return self.__cfg[data]
  116. def set(self,mode,value):
  117. protected = ["BLIND","CLEAR","REC-FX"]
  118. self.__check(mode)
  119. if mode == "CLEAR":
  120. return 1
  121. elif mode == "ESC":
  122. for m in self.modes:
  123. cprint("ESC",m)
  124. if m == "COPY":
  125. PRESETS.clear_copy()
  126. if m == "MOVE":
  127. PRESETS.clear_move()
  128. if m != "BLIND":
  129. self.modes[m] = 0
  130. self.callback(m)
  131. return 1
  132. if value:
  133. for m in self.modes:
  134. if m not in protected and mode not in protected and m != mode:
  135. #cprint("-#-# clear mode",mode,m,value,color="red")
  136. if self.modes[m]:
  137. self.modes[m]= 0
  138. self.callback(m)
  139. if self.modes[mode] and value == 1:
  140. if modes == "MOVE":
  141. PRESETS.clear_move()
  142. if modes == "COPY":
  143. PRESETS.clear_copy()
  144. self.modes[mode] = 0 # value
  145. else:
  146. self.modes[mode] = value #1 #value
  147. else:
  148. self.modes[mode] = 0 #value
  149. if modes == "COPY":
  150. PRESETS.clear_copy()
  151. if modes == "MOVE":
  152. PRESETS.clear_move()
  153. self.callback(mode)
  154. return value
  155. def set_cb(self,cb):
  156. if cb:
  157. self.__cb = cb
  158. def callback(self,mode):
  159. if self.__cb is not None and mode in self.modes:
  160. value = self.modes[mode]
  161. self.__cb(mode=mode,value=value)
  162. modes = Modes()
  163. #modes.val("BLIND", 0)
  164. #modes.modes["BLIND"] = 0
  165. modes.modes["ESC"] = 0
  166. modes.modes["REC"] = 0
  167. modes.modes["EDIT"] = 0
  168. modes.modes["MOVE"] = 0
  169. modes.modes["FLASH"] = 0
  170. modes.modes["GO"] = 0
  171. modes.modes["DEL"] = 0
  172. modes.modes["REC-FX"] = 0
  173. modes.modes["SELECT"] = 0
  174. modes.modes["CFG-BTN"] = 0
  175. modes.modes["LABEL"] = 0
  176. def xcb(mode,value=None):
  177. cprint("xcb","MODE CALLBACK",mode,value)
  178. if mode == "REC-FX":
  179. cprint("xcb",modes.val("REC-FX"))
  180. #modes.set_cb(xcb)
  181. POS = ["PAN","TILT","MOTION"]
  182. COLOR = ["RED","GREEN","BLUE","COLOR"]
  183. BEAM = ["GOBO","G-ROT","PRISMA","P-ROT","FOCUS","SPEED"]
  184. INT = ["DIM","SHUTTER","STROBE","FUNC"]
  185. #client = chat.tcp_sender(port=50001)
  186. def set_exec_fader_cfg(nr,val,label="",color=""):
  187. exec_wing = window_manager.get_obj(name="EXEC-WING")
  188. if not exec_wing:
  189. return
  190. try:
  191. if len(exec_wing.fader_elem) > nr:
  192. exec_wing.fader_elem[nr].attr["text"] = label
  193. cfg = get_exec_btn_cfg(nr+80)
  194. if cfg:
  195. exec_wing.fader_elem[nr].attr["bg"] = cfg["bg"]
  196. exec_wing.fader_elem[nr].attr["fg"] = cfg["fg"]
  197. #exec_wing.fader_elem[nr].attr["fx"] = cfg["fx"]
  198. except Exception as e:
  199. cprint(" set_exec_fader_cfg err:",e,color="red")
  200. print(" ",nr,val,label)
  201. raise e
  202. def set_exec_fader(nr,val,label="",color="",info="info",change=0):
  203. exec_wing = window_manager.get_obj(name="EXEC-WING")
  204. if not exec_wing:
  205. return
  206. try:
  207. exec_wing.set_fader(nr,val,color=color,info=info,change=change)
  208. except Exception as e:
  209. cprint(" - set_exec_fader err:",e,color="red")
  210. print(" ",nr,val,label)
  211. raise e
  212. def set_exec_fader_all():
  213. print()
  214. cprint( "set_exec_fader_all()",color="green")
  215. for nr in range(10):
  216. _label = PRESETS.label_presets[nr+80] # = label
  217. print(" set_exec_fader_all._label =",_label)
  218. set_exec_fader(nr,0,label=_label)
  219. set_exec_fader_cfg(nr,0,label=_label)
  220. def refresh_exec_fader_cfg():
  221. cprint( "set_exec_fader_all()",color="green")
  222. for nr in range(10):
  223. _label = PRESETS.label_presets[nr+80] # = label
  224. #print("_label",_label)
  225. set_exec_fader_cfg(nr,0,label=_label)
  226. # remote input - start (memcached)
  227. def JCB(x,sock=None):
  228. for i in x:
  229. jv = x[i]
  230. try:
  231. jv = json.loads(jv)
  232. jv = jv[0]
  233. #print(jv)
  234. v = jv["iVAL"]
  235. #exec_wing.set_fader(0,v)
  236. set_exec_fader(0,v)
  237. set_exec_fader(1,200-v)
  238. set_exec_fader(2,int(v/2+10))
  239. except Exception as e:
  240. cprint("exception",e)
  241. print(sys.exc_info()[2])
  242. #print("remote in:",round(time.time(),0),"x",i,v)
  243. if __name__ == "__main__":
  244. r1_server = chat.Server(port=30002)
  245. def server1_loop():
  246. while 1:
  247. r1_server.poll(cb=JCB)
  248. time.sleep(1/90)
  249. thread.start_new_thread(server1_loop,()) # SERVER
  250. # remote input - end
  251. #chat.dbg=1
  252. class DEVENT():
  253. def __init__(self):
  254. #if "keysym" in dir(event):
  255. #if "Escape" ==
  256. #event.keysym:
  257. #event.num == 1:
  258. self.keysym = ""
  259. self.num = 1
  260. self.type = ""
  261. import lib.jsbc as JSBC
  262. if __name__ == "__main__":
  263. # external GUI
  264. r_server = chat.Server(port=30003,cb=JSBC.JSCB)
  265. def server_loop():
  266. while 1:
  267. r_server.poll(cb=JSBC.JSCB)
  268. #time.sleep(1/90)
  269. thread.start_new_thread(server_loop,()) # SERVER
  270. import lib.fifo as FIFO
  271. if __name__ == "__main__":
  272. # external GUI
  273. f_server = FIFO.read_loop() #chat.Server(port=30003,cb=JSBC.JSCB)
  274. f_server.loop(sleep=1)
  275. def f_server_read_loop():
  276. time.sleep(10)
  277. print("FIFO read_loop() __ ")
  278. while 1:
  279. try:
  280. data = f_server.read()
  281. for jdata in data:
  282. # JSCB [{'event': 'EXEC', 'EXEC': 161, 'VAL': 0, 'NR-KEY': 1}]
  283. print("FIFO:",jdata)
  284. ok=1
  285. for i in ["event","VAL","EXEC"]:
  286. if i not in jdata:
  287. ok=0
  288. if ok:
  289. if jdata["event"] != "EXEC":
  290. continue
  291. if "EXEC" in jdata:
  292. exec_nr = jdata["EXEC"]
  293. if "VAL" in jdata:
  294. val = jdata["VAL"]
  295. master.preset_go(exec_nr-1,xfade=None,val=val)
  296. else:
  297. time.sleep(0.02)
  298. except KeyboardInterrupt as e:
  299. raise e
  300. except Exception as e:
  301. print("FIFO ERR1",e)
  302. thread.start_new_thread(f_server_read_loop,()) # SERVER
  303. # read memcachd
  304. memcache = None
  305. try:
  306. import memcache
  307. except Exception as e:
  308. cprint("Exception IMPORT ERROR",e)
  309. class MC_FIX():
  310. def __init__(self,server="127.0.0.1",port=11211):
  311. cprint("MC.init() ----------" ,server,port,color="red")
  312. try:
  313. #self.mc = memcache.Client(['127.0.0.1:11211'], debug=0)
  314. self.mc = memcache.Client(['{}:{}'.format(server,port)], debug=0)
  315. #self.init()
  316. except Exception as e:
  317. cprint("-- Exception",e)
  318. def set(self,index="fix",data=[]):
  319. #time.sleep(5)
  320. if 1: #while 1:
  321. #print("MC.send",index) #,data)
  322. index = self.mc.get("index")
  323. #if index:
  324. # for i in index:
  325. # print(" key",i)
  326. self.mc.set("fix", data)
  327. #examles
  328. #self.mc.set("some_key", "Some value")
  329. #self.value = mc.get("some_key")
  330. #self.mc.set("another_key", 3)
  331. #self.mc.delete("another_key")
  332. class MC():
  333. def __init__(self,server="127.0.0.1",port=11211):
  334. cprint("MC.init() ----------" ,server,port,color="red")
  335. try:
  336. #self.mc = memcache.Client(['127.0.0.1:11211'], debug=0)
  337. self.mc = memcache.Client(['{}:{}'.format(server,port)], debug=0)
  338. #self.init()
  339. except Exception as e:
  340. cprint("-- Exception",e)
  341. # def init(self):
  342. data = {}
  343. start = time.time()
  344. delta = start
  345. index = self.mc.get("index")
  346. if index:
  347. for i in index:
  348. print(" key",i)
  349. self.last_fader_val = [-1]*512
  350. self.fader_map = []
  351. for i in range(30+1):
  352. self.fader_map.append({"UNIV":0,"DMX":0})
  353. try:
  354. fname = HOME + "/LibreLight/fader.json"
  355. f = open(fname)
  356. lines = f.readlines()
  357. cprint("FADER MAP",fname)
  358. for i,line in enumerate(lines):
  359. jdata = json.loads(line)
  360. print(" fader_map ->>",i,jdata)
  361. self.fader_map[i] = jdata
  362. except Exception as e:
  363. cprint("-- Except Fader_map",e)
  364. #exit()
  365. def ok(self):
  366. if self.mc:
  367. return 1
  368. return 0
  369. def test(self):
  370. if not self.ok():
  371. return
  372. self.mc.set("some_key", "Some value")
  373. self.value = mc.get("some_key")
  374. self.mc.set("another_key", 3)
  375. self.mc.delete("another_key")
  376. def loop(self):
  377. thread.start_new_thread(self._loop,())
  378. if not self.ok():
  379. return
  380. def _loop(self):
  381. cprint("++++++++++ start.memcachd read loop",self )
  382. while 1:
  383. send = 0
  384. #print("+")
  385. try:
  386. ip="10.10.10.13:0"
  387. #ip="ltp-out:0"
  388. #print(ip)
  389. x=self.mc.get(ip)
  390. if x:
  391. #print(ip,x)
  392. #val = x[501-1]
  393. #val = x[141-1]
  394. for i, line in enumerate(self.fader_map):
  395. try:
  396. #print(i,line)
  397. dmx = int(line["DMX"])
  398. if dmx > 0:
  399. val = x[dmx-1]
  400. #print("mc val",val)
  401. #print("dmx_in change:",[i,val])
  402. change = 0
  403. if i < len(self.last_fader_val):
  404. if self.last_fader_val[i] != val:
  405. self.last_fader_val[i] = val
  406. print("dmx_in change:",[i,val])
  407. change = 1
  408. set_exec_fader(nr=i,val=val,color="#aaa",info="dmx_in",change=change)
  409. except Exception as e:
  410. cprint("MC exc:",e,color="red")
  411. traceback.print_exc()
  412. pass
  413. time.sleep(1/10)
  414. except Exception as e:
  415. cprint("exc", e)
  416. time.sleep(1)
  417. _mc=MC()
  418. _mc.loop()
  419. console = chat.Client() #port=50001)
  420. def jclient_send(data):
  421. t_start = time.time()
  422. jtxt = data
  423. jdatas = []
  424. for jdata in data:
  425. if "CMD" in jdata:
  426. try:
  427. jdatas.append(jdata)
  428. except Exception as e:
  429. cprint("jclient_send, Exception DMX ",color="red")
  430. cprint("",jdata,color="red")
  431. cprint("-----",color="red")
  432. elif "DMX" in jdata:
  433. try:
  434. jdata["DMX"] = int(jdata["DMX"])
  435. dmx = jdata["DMX"]
  436. if "ATTR" not in jdata:
  437. # for fx off
  438. jdatas.append(jdata)
  439. else:
  440. fix = "00000"
  441. attr = "00000"
  442. if "FIX" in jdata:
  443. fix = jdata["FIX"]
  444. if "ATTR" in jdata:
  445. attr = jdata["ATTR"]
  446. dmx_fine = FIXTURES.get_dmx(fix,attr+"-FINE")
  447. if jdata["DMX"] != dmx_fine and dmx > 0 and dmx_fine > 0:
  448. jdata["DMX-FINE"] = dmx_fine
  449. if "DMX-FINE" in jdata:
  450. if jdata["DMX-FINE"] <= 0:
  451. del jdata["DMX-FINE"]
  452. if jdata["ATTR"].startswith("_"):
  453. pass # ignore attr._ACTIVE
  454. else:#
  455. jdata["time"] = t_start
  456. jdatas.append(jdata)
  457. #cprint("-- ",jdata,color="red")
  458. except Exception as e:
  459. cprint("jclient_send, Exception DMX ",color="red")
  460. cprint("",jdata,color="red")
  461. cprint(e,color="red")
  462. cprint("-----",color="red")
  463. jtxt = jdatas
  464. jtxt = json.dumps(jtxt)
  465. jtxt = jtxt.encode()
  466. console.send( jtxt ) #b"\00 ")
  467. cprint("{:0.04} sec.".format(time.time()-t_start),color="yellow")
  468. cprint("{:0.04} tick".format(time.time()),color="yellow")
  469. def _highlight(fix,_attr="DIM"):
  470. " patch test button "
  471. cprint("highlight",fix,"1")
  472. if fix not in FIXTURES.fixtures:
  473. return None
  474. d = FIXTURES.fixtures[fix]
  475. #for k,v in d.items():
  476. # cprint("-",k,v)
  477. DMX = d["DMX"] + d["UNIVERS"]*512
  478. if "ATTRIBUT" in d:
  479. ATTR= d["ATTRIBUT"]
  480. data = {"VALUE":200,"DMX":1}
  481. attr = ""
  482. if _attr in ATTR:
  483. attr = _attr
  484. else:
  485. return #stop
  486. cprint(attr,ATTR[attr])
  487. old_val = ATTR[attr]["VALUE"]
  488. data["DMX"] = DMX + ATTR[attr]["NR"]-1
  489. cprint(attr,ATTR[attr])
  490. cprint(data)
  491. for i in range(3):
  492. cprint("highlight",fix,"0")
  493. data["VALUE"] = 100
  494. jclient_send([data])
  495. time.sleep(0.1)
  496. cprint("highlight",fix,"1")
  497. data["VALUE"] = 234
  498. jclient_send([data])
  499. time.sleep(0.3)
  500. cprint("highlight",fix,"0")
  501. data["VALUE"] = old_val
  502. jclient_send([data])
  503. def highlight2(fix,attr="DIM"):
  504. def x():
  505. highlight(fix,attr=attr)
  506. return x
  507. def highlight(fix):
  508. cprint("highlight",fix)
  509. thread.start_new_thread(_highlight,(fix,"DIM"))
  510. thread.start_new_thread(_highlight,(fix,"RED"))
  511. thread.start_new_thread(_highlight,(fix,"GREEN"))
  512. thread.start_new_thread(_highlight,(fix,"BLUE"))
  513. class ValueBuffer():
  514. def __init__(self,_min=0,_max=255):
  515. self._value = 2
  516. self._on = 1
  517. self._min=_min
  518. self._max=_max
  519. def check(self):
  520. if self._value < self._min:
  521. self._value = self._min
  522. elif self._value > self._max:
  523. self._value = self._max
  524. def inc(self,value=None):
  525. if value is not None:
  526. if type(value) is float:
  527. self._value += round(value,4)
  528. else:
  529. self._value += value
  530. self.check()
  531. return self._value
  532. def val(self,value=None):
  533. if value is not None:
  534. if type(value) is float:
  535. self._value = round(value,4)
  536. else:
  537. self._value = value
  538. self.check()
  539. return self._value
  540. def on(self):
  541. self._on = 1
  542. def off(self):
  543. self._on = 0
  544. def _is(self):
  545. if self._on:
  546. return 1
  547. return 0
  548. FADE = ValueBuffer() #2 #0.1 #1.13
  549. FADE.val(2.0)
  550. FADE_move = ValueBuffer() #2 #0.1 #1.13
  551. FADE_move.val(4.0)
  552. DELAY = ValueBuffer() #2 #0.1 #1.13
  553. DELAY.off()
  554. DELAY.val(0.2)
  555. fx_prm_main = {}
  556. fx_prm_move = {"SIZE":40,"SPEED":8,"OFFSET":100,"BASE":"0","START":0,"MODE":0,"MO":0,"DIR":1,"INVERT":0,"WING":2,"WIDTH":100}
  557. fx_color = {"A":"red","B":"blue"}
  558. fx_prm = {"SIZE":255,"SPEED":10,"OFFSET":100,"BASE":"-","START":0,"MODE":0,"MO":0,"DIR":1,"INVERT":1,"SHUFFLE":0,"WING":2,"WIDTH":25,"2D-X":1,"2D:MODE":0}
  559. fx_x_modes = ["spiral","left","right","up","down","left_right","up_down"]
  560. fx_modes = ["RED","GREEN","BLUE","MAG","YELLOW","CYAN"]
  561. fx_mo = ["fade","on","rnd","ramp","ramp2","cosinus","sinus","static"]
  562. class FX_handler():
  563. def __init__():
  564. pass
  565. class dummy_event():
  566. def __init__(self):
  567. self.num =0
  568. self.type = 4 #press 5 release
  569. self.set_value=-1
  570. from lib import matrix
  571. import lib.fxlib as fxlib
  572. def process_matrix(xfixtures):
  573. fx_x = fx_prm["2D-X"]
  574. fx_mod = fx_x_modes[fx_prm["2D:MODE"]]
  575. r = _process_matrix(xfixtures,fx_x,fx_mod)
  576. return r
  577. def _process_matrix(xfixtures,fx_x,fx_mod):
  578. fix_count = len(xfixtures)
  579. cprint("----",fx_x,fx_mod)
  580. if fx_x > 1 and fix_count > fx_x:
  581. try:
  582. w=fx_x
  583. h=int(fix_count/fx_x)
  584. if fx_mod == "spiral":
  585. _map = matrix.spiral(w,h)
  586. elif fx_mod == "up_down":
  587. _map = matrix.up_down(w,h)
  588. elif fx_mod == "left_right":
  589. _map = matrix.left_right(w,h)
  590. elif fx_mod == "left":
  591. _map = matrix.left(w,h)
  592. elif fx_mod == "right":
  593. _map = matrix.right(w,h)
  594. elif fx_mod == "up":
  595. _map = matrix.up(w,h)
  596. elif fx_mod == "down":
  597. _map = matrix.down(w,h)
  598. else:
  599. return xfixtures # do nothing
  600. matrix.mprint(xfixtures,w,h)
  601. out = ["0"]*(w*h)
  602. for i,f in enumerate(xfixtures):
  603. if i < w*h:
  604. j = int(_map[i])
  605. cprint(["i:",i,"f:",f,"j:",j])
  606. out[j] = f
  607. matrix.mprint(out,w,h)
  608. xfixtures = out
  609. except Exception as e:
  610. cprint("matrix exception",e)
  611. return xfixtures
  612. def save_show(fpath=None,new=0):
  613. if fpath:
  614. a=PRESETS.backup_presets(save_as=fpath,new=new)
  615. b=FIXTURES.backup_patch(save_as=fpath,new=new)
  616. c=libwin.save_window_position(save_as=fpath)
  617. d=movewin.store_all_sdl()
  618. else:
  619. print()
  620. print()
  621. cprint("SAVE SHOW ..",color="yellow")
  622. a=PRESETS.backup_presets()
  623. b=FIXTURES.backup_patch()
  624. c=libwin.save_window_position()
  625. d=movewin.store_all_sdl()
  626. if a and b and d: # and c
  627. cprint("SAVE SHOW OK",[fpath,new],[a,b,c,d],color="green")
  628. print()
  629. print()
  630. print()
  631. return 1
  632. cprint("SAVE SHOW FAIL",[fpath,new],[a,b,c,d],color="red")
  633. print()
  634. print()
  635. print()
  636. def save_show_as(fname,new=0):
  637. print()
  638. print()
  639. fpath = baselib.generate_show_path(fname)
  640. info = "SAVE SHOW AS"
  641. if new:
  642. info = "SAVE (NEW) SHOW AS"
  643. cprint(info,fpath,fname,color="green")
  644. if baselib.create_new_show_path(fpath):
  645. return save_show(fpath,new)
  646. def wheel(event,d=None):
  647. cprint("wheel",event,d)
  648. class Element():
  649. def __init__(self):
  650. self.__data = {}
  651. def set(self,key,val):
  652. self.__data[key] = val
  653. import lib.baselib as baselib
  654. def hex_to_rgb(hex):
  655. return tuple(int(hex[i:i+2], 16) for i in (0, 2, 4))
  656. class cb():
  657. def __init__(self,win):
  658. self.win = win
  659. def _callback(self,event):
  660. clobj=event.widget
  661. ## undermouse=find_withtag(master.CURRENT)
  662. undermouse=self.win.find_closest(self.win.CURRENT)
  663. cprint( repr(undermouse))
  664. def callback(self,event):
  665. cprint(__file__,self,"callback",event)
  666. cnv = self.win
  667. item = cnv.find_closest(cnv.canvasx(event.x), cnv.canvasy(event.y))[0]
  668. tags = cnv.gettags(item)
  669. #cnv.itemconfigure(self.tag, text=tags[0])
  670. cprint(tags,item)
  671. color = cnv.itemcget(item, "fill")
  672. cnv.itemconfig("all", width=1)#filla="green")
  673. cnv.itemconfig(item, width=3)#filla="green")
  674. cprint(color)
  675. cprint( hex_to_rgb(color[1:]))
  676. def get_exec_btn_cfg(nr):
  677. k = nr
  678. if 1:
  679. _bg = "grey"
  680. _ba = "grey"
  681. _fg = "lightgrey"
  682. _text = "N/V"
  683. if nr >= 0:
  684. if nr != k:
  685. return #continue
  686. label = ""
  687. if k in PRESETS.label_presets:
  688. label = PRESETS.label_presets[k]
  689. ifval = 0
  690. fx_only = 0
  691. fx_color = 0
  692. if k in PRESETS.val_presets and len(PRESETS.val_presets[k]) :
  693. sdata = PRESETS.val_presets[k]
  694. BTN="go"
  695. if "CFG" in sdata:#["BUTTON"] = "GO"
  696. if "BUTTON" in sdata["CFG"]:
  697. BTN = sdata["CFG"]["BUTTON"]
  698. txt="{} {} {}\n{}".format(k+1,BTN,len(sdata)-1,label)
  699. _text = txt
  700. if len(sdata) > 1:
  701. ifval = 1
  702. val_color = 0
  703. for fix in sdata:
  704. if fix == "CFG":
  705. continue
  706. for attr in sdata[fix]:
  707. if "FX2" in sdata[fix][attr]:
  708. if sdata[fix][attr]["FX2"]:
  709. fx_color = 1
  710. if "FX" in sdata[fix][attr]:
  711. if sdata[fix][attr]["FX"]:
  712. fx_color = 1
  713. if "VALUE" in sdata[fix][attr]:
  714. if sdata[fix][attr]["VALUE"] is not None:
  715. val_color = 1
  716. if val_color:
  717. _bg = "gold"
  718. _ba = "#ffaa55"
  719. if fx_color:
  720. _fg = "blue"
  721. else:
  722. if fx_color:
  723. fx_only = 1
  724. else:
  725. _bg = "grey"
  726. _ba = "#aaa"
  727. if "\n" in txt:
  728. txt1 = txt.split("\n")[0]
  729. _fg = "black"
  730. if ifval:
  731. if fx_only:
  732. _bg = "cyan"
  733. _ba = "#55d4ff"
  734. if "SEL" in txt1:
  735. _bg = "#77f"
  736. else:
  737. _bg = "grey"
  738. _fg = "darkgrey"
  739. if "SEL" in txt1:
  740. _fg = "blue"
  741. elif "ON" in txt1:
  742. _fg = "#040"
  743. elif "GO" in txt1:
  744. _fg = "#555"
  745. if "FL" in txt1:
  746. _fg = "#00e"
  747. out = {}
  748. out["fx"] = fx_color
  749. out["bg"] = _bg
  750. out["ba"] = _ba
  751. out["fg"] = _fg
  752. out["text"] = _text
  753. return out
  754. class Elem_Container():
  755. def __init__(self):
  756. self.commands = []
  757. self.val = {}
  758. self.elem = {}
  759. import lib.execlib as execlib
  760. class MASTER():
  761. def __init__(self):
  762. self.base = baselib.Base ()
  763. self.load()
  764. self._XX = 0
  765. self.all_attr =["DIM","PAN","TILT"]
  766. self.elem_attr = {}
  767. self.setup_elem = {} # Elem_Container()
  768. self.setup_cmd = ["SAVE\nSHOW","LOAD\nSHOW","NEW\nSHOW","SAVE\nSHOW AS","SAVE &\nRESTART","DRAW\nGUI","PRO\nMODE"]
  769. self.setup_cmd = ["SAVE\nSHOW","LOAD\nSHOW","NEW\nSHOW","SAVE\nSHOW AS","SAVE &\nRESTART","PRO\nMODE"]
  770. self.fx_main = Elem_Container()
  771. self.fx_main.commands =["REC-FX","FX OFF","\n"]
  772. self.fx_moves = Elem_Container()
  773. self.fx_moves.commands =[
  774. "FX:CIR","FX:PAN","FX:TILT", "WIDTH:\n100","DIR:\n0","INVERT:\n0","\n",
  775. "SHUFFLE:\n0","SIZE:\n","SPEED:\n","START:\n","OFFSET:\n","\n"
  776. ]
  777. #, "FX:SIN","FX:COS","FX:RAMP","FX:RAMP2","FX:FD","FX:ON","BASE:\n-"] #,"FX:RND" ]
  778. self.fx = Elem_Container()
  779. self.fx.commands =[
  780. "FX:DIM"," ", "WIDTH:\n25","WING:\n2","DIR:\n1","INVERT:\n1","\n","SHUFFLE:\n0"
  781. ,"SIZE:\n","SPEED:\n","START:\n","OFFSET:\n","BASE:\n-","2D-X:\n-","2D:MODE"
  782. ]
  783. self.fx_generic = Elem_Container()
  784. self.fx_generic.commands =["FX:SIN","FX:COS","FX:RAMP","FX:RAMP2","FX:FD","FX:ON","FX:STATIC"]
  785. self.fx_color = Elem_Container()
  786. self.fx_color.commands =["FX:RED","FX-C:A","FX-C:B"]
  787. self.commands = Elem_Container()
  788. self.commands.commands =["\n","ESC","CFG-BTN","LABEL","-","DEL","-","\n"
  789. ,"SELECT","FLASH","GO","-","MOVE","S-KEY","\n"
  790. ,"BLIND","CLEAR","REC","EDIT","COPY",".","\n"
  791. ]
  792. self.elem_presets = {}
  793. for i in range(8*8*8):
  794. if i not in PRESETS.val_presets:
  795. name = "Preset:"+str(i+1)+":\nXYZ"
  796. #self.presets[i] = [i]
  797. PRESETS.val_presets[i] = OrderedDict() # FIX
  798. PRESETS.val_presets[i]["CFG"] = OrderedDict() # CONFIG
  799. PRESETS.label_presets[i] = "-"
  800. modes.set_cb(self.xcb)
  801. def jclient_send(self,data):
  802. # namespace wraper
  803. if not modes.val("BLIND"):
  804. jclient_send(data)
  805. def button_refresh(self,name,color,color2=None,text="",fg=None):
  806. cprint("button_refresh",name,color)
  807. try:
  808. if color2 is None:
  809. color2 = color
  810. if text:
  811. text = "\n"+str(text)
  812. if name in self.commands.elem:
  813. self.commands.elem[name]["bg"] = color
  814. self.commands.elem[name]["text"] = name+ text
  815. self.commands.elem[name].config(activebackground=color2)
  816. if fg:
  817. self.commands.elem[name]["fg"] = fg
  818. elif name in self.fx.elem:
  819. #todo
  820. self.fx.elem[name]["bg"] = color
  821. self.fx.elem[name].config(activebackground=color2)
  822. if fg:
  823. self.fx.elem[name]["fg"] = fg
  824. # new version
  825. for elems in [self.fx_moves]:
  826. if name in elems.elem:
  827. elem = elems.elem[name]
  828. cprint("elem",elem)
  829. elem.config(bg = color)
  830. elem.config(text = name+text)
  831. elem.config(activebackground=color2)
  832. if fg and "fg" in elem:
  833. elem["fg"] = fg
  834. except Exception as e:cprint("exc",self,e)
  835. def btn_cfg(self,nr,testing=0):
  836. cfg = PRESETS._btn_cfg(nr)
  837. button = PRESETS.btn_cfg(nr)
  838. label = PRESETS.label(nr)
  839. def _cb(data):
  840. if not data:
  841. cprint("err443",self,"_cb",data)
  842. return None
  843. cprint("btn_cfg._cb()",data)
  844. if data:
  845. if "Button" in data and type(data["Button"]) is str:
  846. txt = data["Button"]
  847. PRESETS.btn_cfg(nr,txt)
  848. self.elem_presets[nr].configure(text= PRESETS.get_btn_txt(nr))
  849. if "Label" in data and type(data["Label"]) is str:
  850. txt = data["Label"]
  851. PRESETS.label(nr,txt)
  852. self.elem_presets[nr].configure(text= PRESETS.get_btn_txt(nr))
  853. if "Delay" in data and type(data["Delay"]) is str:
  854. txt = data["Delay"]
  855. try:
  856. txt = float(txt)
  857. if "DELAY" in cfg:
  858. cfg["DELAY"] = round(txt,2)
  859. except e as Exception:
  860. print("DELAY Exception",e)
  861. if "in-Fade" in data and type(data["in-Fade"]) is str:
  862. txt = data["in-Fade"]
  863. try:
  864. txt = float(txt)
  865. if "FADE" in cfg:
  866. cfg["FADE"] = round(txt,2)
  867. except e as Exception:
  868. print("in-Fade Exception",e)
  869. if "out-Fade" in data and type(data["out-Fade"]) is str:
  870. txt = data["out-Fade"]
  871. try:
  872. txt = float(txt)
  873. cfg["OUT-FADE"] = round(txt,2)
  874. except e as Exception:
  875. print("out-Fade Exception",e)
  876. modes.val("CFG-BTN",0)
  877. master._refresh_exec(nr=nr)
  878. dialog._cb = _cb
  879. if 1: # testing:
  880. dialog.ask_exec_config(str(nr+1),button=button,label=label,cfg=cfg)
  881. else:
  882. dialog.askstring("CFG-BTN","GO=GO FL=FLASH\nSEL=SELECT EXE:"+str(nr+1),initialvalue=txt)
  883. def label(self,nr):
  884. txt = PRESETS.label(nr)
  885. def _cb(data):
  886. if not data:
  887. cprint("err443",self,"_cb",data)
  888. return None
  889. txt = data["Value"]
  890. cprint("label._cb()",nr,txt)
  891. if txt:
  892. PRESETS.label(nr,txt)
  893. self.elem_presets[nr].configure(text = PRESETS.get_btn_txt(nr))
  894. modes.val("LABEL", 0)
  895. master._refresh_exec(nr=nr)
  896. dialog._cb= _cb #_x(nr)
  897. dialog.askstring("LABEL","EXE:"+str(nr+1),initialvalue=txt)
  898. def xcb(self,mode,value=None):
  899. cprint("MODE CALLBACK",mode,value,color="green",end="")
  900. if value:
  901. cprint("===== ON ======",color="red")
  902. txt = ""
  903. if mode == "REC-FX":
  904. modes.val("REC",0)
  905. modes.val("REC",1)
  906. if value == 2:
  907. if mode in ["MOVE","COPY"]:
  908. txt="to"
  909. self.button_refresh(mode,color="orange",text=txt)#,fg="blue")
  910. else:
  911. if mode in ["MOVE","COPY"]:
  912. txt="from"
  913. self.button_refresh(mode,color="red",text=txt)#,fg="blue",text="from")
  914. else:
  915. cprint("===== OFF ======",color="red")
  916. if mode == "REC-FX":
  917. modes.val("REC",0)
  918. self.button_refresh(mode,color="lightgrey")#,fg="black")
  919. def load(self,fname=""):
  920. pass
  921. def exit(self):
  922. cprint("__del__",self)
  923. def refresh_exec(self):
  924. refresher_exec.reset() # = Refresher()
  925. def _refresh_exec(self,nr=-1):
  926. s = time.time()
  927. cprint("PRESET.refresh_exec()")
  928. refresher_exec.reset() # = Refresher()
  929. self._XX +=1
  930. self._nr_ok = 0
  931. for nr in PRESETS.val_presets:
  932. cfg = get_exec_btn_cfg(nr)
  933. if not cfg:
  934. out = {}
  935. out["bg"] = "lightgrey"
  936. out["ba"] = "grey"
  937. out["fg"] = "grey"
  938. out["text"] = "?"
  939. cfg = out
  940. b = self.elem_presets[nr]
  941. b.configure(fg=cfg["fg"],bg=cfg["bg"],activebackground=cfg["ba"],text=cfg["text"],fx=cfg["fx"])
  942. time.sleep(0.01)
  943. def refresh_fix(self):
  944. refresher_fix.reset() # = Refresher()
  945. def _refresh_fix(self):
  946. cprint("_refresh_fix")
  947. s=time.time(); _XXX=0
  948. menu_buff = {"DIM":0,"DIM-SUB":0,"FIX":0,"FIX-SUB":0}
  949. elem_buffer = []
  950. for fix in FIXTURES.fixtures:
  951. sdata = FIXTURES.fixtures[fix]
  952. elem_attr_fix = None
  953. if fix in self.elem_attr:
  954. elem_attr_fix = self.elem_attr[fix]
  955. if "DIM" in sdata["ATTRIBUT"] and "_ACTIVE" in sdata["ATTRIBUT"] and len(sdata["ATTRIBUT"]) == 2:
  956. KEY = "DIM-SUB"
  957. else:
  958. KEY = "FIX-SUB"
  959. FIX = 0
  960. DIM = 0
  961. for attr in sdata["ATTRIBUT"]:
  962. _buff = {}
  963. row = sdata["ATTRIBUT"][attr]
  964. if attr.endswith("-FINE"):
  965. continue
  966. b_attr = attr
  967. if b_attr == "_ACTIVE":
  968. b_attr = "S"
  969. elem = None
  970. if elem_attr_fix:
  971. if b_attr not in elem_attr_fix:
  972. continue
  973. elem = elem_attr_fix[b_attr]
  974. if not elem:
  975. continue
  976. if "elem" not in _buff:
  977. _buff["elem"] = elem
  978. if not attr.startswith("_"):
  979. v2 = row["VALUE"]
  980. #_text = "{} {}".format(str(attr).rjust(4,"0"),str(v2).rjust(4,"0")) # ~0.2 sec
  981. _text = "{} {}".format(attr,v2)
  982. _buff["text"] = _text
  983. if row["ACTIVE"]:
  984. _buff["bg"] = "yellow"
  985. _buff["abg"] = "yellow"
  986. menu_buff[KEY] += 1
  987. if b_attr == "S":
  988. if KEY == "DIM-SUB":
  989. DIM =1
  990. else:
  991. FIX =1
  992. else:
  993. _buff["bg"] = "grey"
  994. _buff["abg"] = "grey"
  995. if "FX" not in row: # insert FX2 excetption
  996. row["FX"] = "" #OrderedDict()
  997. if "FX2" not in row: # insert FX2 excetption
  998. row["FX2"] = {} #OrderedDict()
  999. #print("row",fix,row)
  1000. if row["FX"]:
  1001. _buff["fg"] = "blue"
  1002. elif row["FX2"]:
  1003. _buff["fg"] = "red"
  1004. else:
  1005. _buff["fg"] = "black"
  1006. elem_buffer.append(_buff)
  1007. menu_buff["FIX"] += FIX
  1008. menu_buff["DIM"] += DIM
  1009. try:
  1010. for row in elem_buffer:
  1011. elem = row["elem"]
  1012. if not elem:
  1013. continue
  1014. for e in row:
  1015. if e == "elem":
  1016. continue
  1017. v = row[e]
  1018. if e == "abg":
  1019. elem.config(activebackground=v)
  1020. else:
  1021. elem[e] = v
  1022. w = window_manager.get_win("FIXTURES")
  1023. if w:
  1024. w.update_idle_task()
  1025. except Exception as e:
  1026. cprint("exc434",e,color="red")
  1027. cprint("fix:",_XXX,round(time.time()-s,2),color="red");_XXX += 1
  1028. cprint(gui_menu)
  1029. menu_buff["FIX-SUB"] -= menu_buff["FIX"]
  1030. if menu_buff["FIX-SUB"]:
  1031. gui_menu.config("FIXTURES","bg","yellow")
  1032. gui_menu.config("FIXTURES","activebackground","yellow")
  1033. elif menu_buff["FIX"]:
  1034. gui_menu.config("FIXTURES","bg","orange")
  1035. gui_menu.config("FIXTURES","activebackground","orange")
  1036. else:
  1037. gui_menu.config("FIXTURES","bg","")
  1038. gui_menu.config("FIXTURES","activebackground","")
  1039. gui_menu.update("FIXTURES","{} : {}".format(menu_buff["FIX"],menu_buff["FIX-SUB"]))
  1040. menu_buff["DIM-SUB"] -= menu_buff["DIM"]
  1041. if menu_buff["DIM-SUB"]:
  1042. gui_menu.config("DIMMER","bg","yellow")
  1043. gui_menu.config("DIMMER","activebackground","yellow")
  1044. elif menu_buff["DIM"]:
  1045. gui_menu.config("DIMMER","bg","orange")
  1046. gui_menu.config("DIMMER","activebackground","orange")
  1047. else:
  1048. gui_menu.config("DIMMER","bg","")
  1049. gui_menu.config("DIMMER","activebackground","")
  1050. gui_menu.update("DIMMER","{} : {}".format(menu_buff["DIM"],menu_buff["DIM-SUB"]))
  1051. cprint("fix:",_XXX,round(time.time()-s),color="red"); _XXX += 1
  1052. def preset_rec(self,nr):
  1053. cprint("------- STORE PRESET")
  1054. data = FIXTURES.get_active()
  1055. if modes.val("REC-FX"):
  1056. PRESETS.rec(nr,data,"REC-FX")
  1057. modes.val("REC-FX",0)
  1058. else:
  1059. PRESETS.rec(nr,data)
  1060. sdata=data
  1061. PRESETS.val_presets[nr] = sdata
  1062. master._refresh_exec()
  1063. return 1
  1064. def preset_select(self,nr):
  1065. cprint("SELECT PRESET")
  1066. sdata = PRESETS.val_presets[nr]
  1067. cmd = ""
  1068. for fix in sdata:
  1069. if fix == "CFG":
  1070. continue
  1071. for attr in sdata[fix]:
  1072. #v2 = sdata[fix][attr]["VALUE"]
  1073. #v2_fx = sdata[fix][attr]["FX"]
  1074. #print( self.data.elem_attr)
  1075. #if fix in self.elem_attr:
  1076. # if attr in self.elem_attr[fix]:
  1077. # elem = self.elem_attr[fix][attr]
  1078. FIXTURES.fixtures[fix]["ATTRIBUT"][attr]["ACTIVE"] = 1
  1079. FIXTURES.fixtures[fix]["ATTRIBUT"]["_ACTIVE"]["ACTIVE"] = 1
  1080. #elem["bg"] = "yellow"
  1081. def preset_go(self,nr,val=None,xfade=None,event=None,button="",ptfade=None):
  1082. s=time.time()
  1083. t_start = time.time()
  1084. if xfade is None and FADE._is():
  1085. xfade = FADE.val()
  1086. if ptfade is None and FADE_move._is():
  1087. ptfade = FADE_move.val()
  1088. cprint("GO PRESET FADE",nr,val)
  1089. rdata = PRESETS.get_raw_map(nr)
  1090. if not rdata:
  1091. return 0
  1092. cprint("???????")
  1093. cfg = PRESETS.get_cfg(nr)
  1094. cprint("''''''''")
  1095. #virtcmd = FIXTURES.get_virtual(rdata)
  1096. if not cfg:
  1097. cprint("NO CFG",cfg,nr)
  1098. return 0
  1099. xFLASH = 0
  1100. value=None
  1101. cprint("preset_go",nr,cfg)
  1102. if modes.val("SELECT") or ( "BUTTON" in cfg and cfg["BUTTON"] == "SEL") and val and not button: #FLASH
  1103. self.preset_select(nr)
  1104. elif modes.val("FLASH") or ( "BUTTON" in cfg and cfg["BUTTON"] == "FL") and not button: #FLASH
  1105. xFLASH = 1
  1106. xfade = 0
  1107. if type(val) is not type(None) and val == 0 :
  1108. value = "off"
  1109. xfade=0
  1110. if "OUT-FADE" in cfg:
  1111. xfade=cfg["OUT-FADE"]
  1112. if event:
  1113. if str(event.type) == "ButtonRelease" or event.type == '5' :
  1114. value = "off"
  1115. xfade=0
  1116. if "OUT-FADE" in cfg:
  1117. xfade=cfg["OUT-FADE"]
  1118. cprint("preset_go() FLUSH",value,color="red")
  1119. #print(";",rdata)
  1120. print(";",cfg)
  1121. fcmd = FIXTURES.update_raw(rdata,update=0)
  1122. #print(":",fcmd) # raw dmx
  1123. self._preset_go(rdata,cfg,fcmd,value,xfade=xfade,xFLASH=xFLASH,nr=nr)
  1124. elif not val:
  1125. cprint("preset_go() STOP",value,color="red")
  1126. elif button == "on" or ( modes.val("ON") or ( "BUTTON" in cfg and cfg["BUTTON"] in ["on","ON"])):
  1127. fcmd = FIXTURES.update_raw(rdata)
  1128. self._preset_go(rdata,cfg,fcmd,value,xfade=0,xFLASH=xFLASH)
  1129. elif button == "go" or ( modes.val("GO") or ( "BUTTON" in cfg and cfg["BUTTON"] in ["go","GO"])):
  1130. fcmd = FIXTURES.update_raw(rdata)
  1131. e=time.time()
  1132. print("_GO TIME:","{:0.02f}".format(e-s),int(e*10)/10)
  1133. self._preset_go(rdata,cfg,fcmd,value,xfade=xfade,xFLASH=xFLASH,ptfade=ptfade,nr=nr)
  1134. e=time.time()
  1135. print("GO TIME:","{:0.02f}".format(e-s),int(e*10)/10)
  1136. return
  1137. if not (modes.val("FLASH") or ( "BUTTON" in cfg and cfg["BUTTON"] == "FL")): #FLASH
  1138. self.refresh_exec()
  1139. self.refresh_fix()
  1140. #print("IIIIIIIIIIIiiiiiiiiiiiiiiiiiii",nr,val)
  1141. #print(len(self.elem_presets) )
  1142. if len(self.elem_presets) > nr: # RED BUTTON IF PRESSED
  1143. #print("IIIIIIIIIIIiiiiiiiiiiiiiiiiiii",nr,val)
  1144. if val:# or value:
  1145. #self.elem_presets[nr].config(borderwidth=1)
  1146. self.elem_presets[nr].config(bg="red")
  1147. else:
  1148. self._refresh_exec()
  1149. cprint("preset_go",time.time()-t_start)
  1150. def _preset_go(self,rdata,cfg,fcmd,value=None,xfade=None,event=None,xFLASH=0,ptfade=0,nr=None):
  1151. if xfade is None and FADE._is():
  1152. xfade = FADE.val()
  1153. if ptfade is None and FADE_move._is():
  1154. ptfade = FADE_move.val()
  1155. cprint("PRESETS._preset_go() len=",len(rdata),cfg)
  1156. if xfade is None:
  1157. xfade = cfg["FADE"]
  1158. if ptfade is None:
  1159. ptfade = cfg["FADE"]
  1160. #vcmd = reshape_preset( rdata ,value,[],xfade=xfade,fx=1)
  1161. #cprint(rdata,color="red")
  1162. vcmd = execlib.reshape_preset( rdata ,value,xfade=xfade,ptfade=ptfade)
  1163. cmd = []
  1164. delay=0
  1165. for i,v in enumerate(fcmd):
  1166. #print("go",i,v)
  1167. if xFLASH:
  1168. vcmd[i]["FLASH"] = 1
  1169. DMX = fcmd[i]["DMX"]
  1170. if "VALUE" in vcmd[i] and type(vcmd[i]["VALUE"]) is type(float):
  1171. vcmd[i]["VALUE"] = round(vcmd[i]["VALUE"],3)
  1172. if value is not None:
  1173. vcmd[i]["VALUE"] = value
  1174. if value == "off":
  1175. if "FX2" in vcmd:
  1176. vcmd[i]["FX2"]["TYPE"] = value
  1177. if "FIX" in fcmd:
  1178. vcmd[i]["FIX"] = fcmd["FIX"]
  1179. if DMX and vcmd[i]:
  1180. vcmd[i]["DMX"] = DMX
  1181. if type(nr) is not type(None):
  1182. vcmd[i]["EXEC"] = str(int(nr)+1)
  1183. cmd.append(vcmd[i])
  1184. if cmd and not modes.val("BLIND"):
  1185. jclient_send(cmd)
  1186. def render(self):
  1187. #Xroot.bind("<Key>",tk_event(fix=0,elem=None,attr="ROOT",data=self,mode="ROOT").cb)
  1188. #self.draw_input()
  1189. pass
  1190. ##draw_sub_dim
  1191. import tkgui.dialog as dialoglib
  1192. dialog = dialoglib.Dialog()
  1193. from tkgui.draw import *
  1194. from tkgui.GUI import *
  1195. class LOAD_SHOW_AND_RESTART():
  1196. def __init__(self,fname=""):
  1197. self.fname=fname
  1198. self.base = baselib.Base()
  1199. def cb(self,event=None,force=0):
  1200. print()
  1201. print()
  1202. print()
  1203. cprint("LOAD_SHOW_AND_RESTART.cb force={} name={}".format(force,self.fname),color="red" )
  1204. if not self.fname and not force:
  1205. return 0
  1206. if self.base.show_name == self.fname and not force:
  1207. cprint("filename is the same",self.fname)
  1208. return 0
  1209. if not force:
  1210. self.base._set(self.fname)
  1211. cprint("LOAD SHOW:",event,self.fname)
  1212. BASE_PATH = "/opt/LibreLight/Xdesk/"
  1213. cmd="_LibreLightDesk.py"
  1214. arg = ""
  1215. print("fork",[BASE_PATH,cmd,arg])
  1216. if "--easy" in sys.argv:
  1217. arg = "--easy"
  1218. movewin.process_kill(BASE_PATH+"tksdl/")
  1219. os.execl("/usr/bin/python3", BASE_PATH, cmd,arg)
  1220. sys.exit()
  1221. class BaseCallback():
  1222. def __init__(self,cb=None,args={}):
  1223. self._cb=cb
  1224. self.args = args
  1225. def cb(self,**args):
  1226. print("BaseCallback.cb()")
  1227. print(" ",self.args)
  1228. print(" ",self._cb)
  1229. if self._cb:
  1230. if self.args:
  1231. self._cb(args=self.args)
  1232. else:
  1233. self._cb()
  1234. def PRESET_CFG_CHECKER(sdata):
  1235. "repair CFG "
  1236. ok = 0
  1237. if "CFG" not in sdata:
  1238. sdata["CFG"] = OrderedDict()
  1239. ok += 1
  1240. if "FADE" not in sdata["CFG"]:
  1241. sdata["CFG"]["FADE"] = 4
  1242. ok += 1
  1243. if "DELAY" not in sdata["CFG"]:
  1244. sdata["CFG"]["DELAY"] = 0
  1245. ok += 1
  1246. if "BUTTON" not in sdata["CFG"]:
  1247. sdata["CFG"]["BUTTON"] = "GO"
  1248. ok += 1
  1249. if "HTP-MASTER" not in sdata["CFG"]:
  1250. sdata["CFG"]["HTP-MASTER"] = 100 #%
  1251. ok += 1
  1252. if "SIZE-MASTER" not in sdata["CFG"]:
  1253. sdata["CFG"]["SIZE-MASTER"] = 100 #%
  1254. ok += 1
  1255. if "SPEED-MASTER" not in sdata["CFG"]:
  1256. sdata["CFG"]["SPEED-MASTER"] = 100 #%
  1257. ok += 1
  1258. if "OFFSET-MASTER" not in sdata["CFG"]:
  1259. sdata["CFG"]["OFFSET-MASTER"] = 100 #%
  1260. ok += 1
  1261. #try:del sdata["CFG"]["SPEED-MASTER"] #= 100 #%
  1262. #except:pass
  1263. return ok
  1264. class Presets():
  1265. def __init__(self):
  1266. self.base = baselib.Base()
  1267. self._last_copy = None
  1268. self._last_move = None
  1269. self.fx_buffer = {}
  1270. def load_presets(self):
  1271. filename="presets"
  1272. d,l = self.base._load(filename)
  1273. for i in d:
  1274. sdata = d[i]
  1275. ok = PRESET_CFG_CHECKER(sdata)
  1276. self.val_presets = d
  1277. self.label_presets = l
  1278. def check_cfg(self,nr=None):
  1279. cprint("PRESETS.check_cfg()",nr)#,color="red")
  1280. ok = 0
  1281. if nr is not None:
  1282. if nr in self.val_presets:
  1283. sdata = self.val_presets[nr]
  1284. ok += self._check_cfg(sdata)
  1285. else:
  1286. cprint("nr not in data ",nr,color="red")
  1287. else:
  1288. for nr in self.val_presets:
  1289. sdata = self.val_presets[nr]
  1290. ok += self._check_cfg(sdata)
  1291. return ok
  1292. def _check_cfg(self,sdata):
  1293. cprint("PRESETS._check_cfg()")#,color="red")
  1294. ok = PRESET_CFG_CHECKER(sdata)
  1295. if ok:
  1296. cprint("REPAIR CFG's",ok,sdata["CFG"],color="red")
  1297. return ok
  1298. def backup_presets(self,save_as="",new=0):
  1299. filename = "presets"
  1300. data = self.val_presets
  1301. labels = self.label_presets
  1302. if new:
  1303. data = [] #*512
  1304. labls = [""]*512
  1305. r=self.base._backup(filename,data,labels,save_as)
  1306. return r
  1307. def get_cfg(self,nr):
  1308. cprint("PRESETS.get_cfg()",nr)
  1309. self.check_cfg(nr)
  1310. if nr not in self.val_presets:
  1311. cprint("get_cfg",self,"error get_cfg no nr:",nr,color="red")
  1312. return {}
  1313. if "CFG" in self.val_presets[nr]:
  1314. return self.val_presets[nr]["CFG"]
  1315. def clean(self,nr):
  1316. if nr not in self.val_presets:
  1317. self.val_presets[nr] = OrderedDict()
  1318. #self.val_presets[nr]["VALUE"] = 0
  1319. #self.val_presets[nr]["FX"] = ""
  1320. sdata = self.val_presets[nr]
  1321. for fix in sdata:
  1322. #print("exec.clear()",nr,fix,sdata[fix])
  1323. for attr in sdata[fix]:
  1324. row = sdata[fix][attr]
  1325. if fix == "CFG":
  1326. continue
  1327. if "VALUE" not in row:
  1328. row["VALUE"] = None
  1329. if "FX" not in row:
  1330. row["FX"] = ""
  1331. if "FX2" not in row:
  1332. row["FX2"] = OrderedDict()
  1333. elif row["FX2"]:
  1334. for k in ["SIZE","SPEED","START","OFFSET"]:
  1335. row["FX2"][k] = int( row["FX2"][k] )
  1336. row["FX"] = ""
  1337. if "FX" in row and row["FX"] and not row["FX2"]: # rebuild old FX to Dict-FX2
  1338. #"off:0:0:0:16909:-:"
  1339. x = row["FX"].split(":")
  1340. cprint("-fx",x,len(x))
  1341. #'FX2': {'TYPE': 'sinus', 'SIZE': 200, 'SPEED': 30, 'START': 0, 'OFFSET': 2805, 'BASE': '-'}}
  1342. if len(x) >= 6:
  1343. row["FX2"]["TYPE"] = x[0]
  1344. row["FX2"]["SIZE"] = int(x[1])
  1345. row["FX2"]["SPEED"] = int(x[2])
  1346. row["FX2"]["START"] = int(x[3])
  1347. row["FX2"]["OFFSET"] = int(x[4])
  1348. row["FX2"]["BASE"] = x[5]
  1349. row["FXOLD"] = row["FX"]
  1350. row["FX"] = ""
  1351. #cprint("exec.clear()",nr,fix,row)
  1352. def get_raw_map(self,nr):
  1353. self.clean(nr)
  1354. cprint("get_raw_map",nr)
  1355. sdata = self.val_presets[nr]
  1356. cmd = ""
  1357. out = []
  1358. dmx=-1
  1359. for fix in sdata:
  1360. if fix == "CFG":
  1361. #print("CFG",nr,sdata[fix])
  1362. continue
  1363. for attr in sdata[fix]:
  1364. x = {}
  1365. #print("RAW",attr)
  1366. x["FIX"] = fix
  1367. x["ATTR"] = attr
  1368. x["VALUE"] = sdata[fix][attr]["VALUE"]
  1369. x["FX"] = sdata[fix][attr]["FX"]
  1370. x["FX2"] = sdata[fix][attr]["FX2"]
  1371. #x["DMX"] = sdata[fix][attr]["NR"]
  1372. out.append(x)
  1373. return out
  1374. def get_btn_txt(self,nr):
  1375. sdata=self.val_presets[nr]
  1376. BTN="go"
  1377. if "CFG" in sdata:
  1378. if "BUTTON" in sdata["CFG"]:
  1379. BTN = sdata["CFG"]["BUTTON"]
  1380. _label = self.label_presets[nr] # = label
  1381. #txt=str(nr+1)+":"+str(BTN)+":"+str(len(sdata)-1)+"\n"+_label
  1382. #txt=str(nr+1)+" "+str(BTN)+" "+str(len(sdata)-1)+"\n"+_label
  1383. txt="{} {} {}\n{}".format(nr+1,BTN,len(sdata)-1,_label)
  1384. cprint("get_btn_txt",nr,[txt])
  1385. return txt
  1386. def _btn_cfg(self,nr,txt=None):
  1387. if nr not in self.val_presets:
  1388. return ""
  1389. if "CFG" not in self.val_presets[nr]:
  1390. self.val_presets[nr]["CFG"] = OrderedDict()
  1391. return self.val_presets[nr]["CFG"]
  1392. def btn_cfg(self,nr,txt=None):
  1393. if nr not in self.val_presets:
  1394. return ""
  1395. if "CFG" not in self.val_presets[nr]:
  1396. self.val_presets[nr]["CFG"] = OrderedDict()
  1397. if "BUTTON" not in self.val_presets[nr]["CFG"]:
  1398. self.val_presets[nr]["CFG"]["BUTTON"] = ""
  1399. if type(txt) is str:
  1400. self.val_presets[nr]["CFG"]["BUTTON"] = txt
  1401. if self.val_presets[nr]["CFG"]["BUTTON"] is None:
  1402. self.val_presets[nr]["CFG"]["BUTTON"] = ""
  1403. master._refresh_exec(nr=nr)
  1404. cprint("EEE", self.val_presets[nr]["CFG"]["BUTTON"] )
  1405. return self.val_presets[nr]["CFG"]["BUTTON"]
  1406. def label(self,nr,txt=None):
  1407. if nr not in self.label_presets:
  1408. return ""
  1409. if type(txt) is str:
  1410. self.label_presets[nr] = txt
  1411. cprint("set label",nr,[txt])
  1412. cprint("??? ?? set label",nr,[txt])
  1413. return self.label_presets[nr]
  1414. def clear_move(self):
  1415. cprint("PRESETS.clear_move()",end=" ")
  1416. self.clear_copy()
  1417. def clear_copy(self):
  1418. cprint("PRESETS.clear_copy()",end=" ")
  1419. if self._last_copy is not None:
  1420. cprint("=OK=",color="red")
  1421. self._last_copy = None
  1422. else:
  1423. cprint("=NONE=",color="green")
  1424. def copy(self,nr,overwrite=1):
  1425. cprint("PRESETS._copy",nr,"last",self._last_copy)
  1426. if nr >= 0:
  1427. if self._last_copy is not None:
  1428. if modes.val("COPY"):
  1429. modes.val("COPY",3)
  1430. ok = self._copy(self._last_copy,nr,overwrite=overwrite)
  1431. return ok #ok
  1432. else:
  1433. if modes.val("COPY"):
  1434. modes.val("COPY",2)
  1435. self._last_copy = nr
  1436. cprint("PRESETS.copy START ",color="red")
  1437. return 0
  1438. return 1 # on error reset move
  1439. def _copy(self,nr_from,nr_to,overwrite=1):
  1440. cprint("PRESETS._copy",nr_from,"to",nr_to)
  1441. self.check_cfg(nr_from)
  1442. if type(self._last_copy) is None:
  1443. cprint("PRESETS._copy last nr is None",color="red")
  1444. return 0
  1445. cprint("------ PRESETS._copy", nr_from in self.val_presets , nr_to in self.val_presets)
  1446. if nr_from in self.val_presets and nr_to in self.val_presets:
  1447. fdata = self.val_presets[nr_from]
  1448. tdata = self.val_presets[nr_to]
  1449. #cprint(fdata)
  1450. flabel = self.label_presets[nr_from]
  1451. tlabel = self.label_presets[nr_to]
  1452. self.val_presets[nr_to] = copy.deepcopy(fdata)
  1453. self.label_presets[nr_to] = flabel
  1454. if not overwrite: #default
  1455. cprint("overwrite",overwrite)
  1456. self.val_presets[nr_from] = copy.deepcopy(tdata)
  1457. self.label_presets[nr_from] = tlabel
  1458. #self.label_presets[nr_from] = "MOVE"
  1459. self.clear_copy()
  1460. cprint("PRESETS.copy OK",color="green")
  1461. return 1
  1462. def move(self,nr):
  1463. cprint("PRESETS.move",self._last_copy,"to",nr)
  1464. if nr >= 0:
  1465. last = self._last_copy
  1466. if modes.val("MOVE"):
  1467. modes.val("MOVE",2)
  1468. ok= self.copy(nr,overwrite=0)
  1469. if ok and last >= 0:
  1470. if modes.val("MOVE"):
  1471. modes.val("MOVE",3)
  1472. cprint("PRESETS.move OK",color="red")
  1473. #self.delete(last)
  1474. return ok,nr,last #ok
  1475. return 0,nr,last # on error reset move
  1476. def delete(self,nr):
  1477. cprint("PRESETS.delete",nr)
  1478. ok=0
  1479. if nr in self.val_presets:
  1480. self.val_presets[nr] = OrderedDict()
  1481. self.label_presets[nr] = "-"
  1482. ok = 1
  1483. self.check_cfg(nr)
  1484. return ok
  1485. def rec(self,nr,data,arg=""):
  1486. cprint("rec",self,"rec()",len(data),arg)
  1487. self.check_cfg(nr)
  1488. self._check_cfg(data) #by ref
  1489. odata=self.val_presets[nr]
  1490. #print("odata",odata)
  1491. if "CFG" in odata:
  1492. if "BUTTON" in odata["CFG"]:
  1493. data["CFG"]["BUTTON"] = odata["CFG"]["BUTTON"]
  1494. self.val_presets[nr] = data
  1495. return 1
  1496. class FixtureEditor():
  1497. def __init__(self,dmx=1):
  1498. pass
  1499. self.elem=[]
  1500. self.dmx=dmx
  1501. cprint("init FixtureEditor",dmx)
  1502. def event(self,a1="",a2=""):
  1503. cprint([self.dmx,a1,a2])
  1504. j=[]
  1505. jdata = {'VALUE': int(a1), 'args': [] , 'FADE': 0,'DMX': str(self.dmx)}
  1506. j.append(jdata)
  1507. jclient_send(j)
  1508. class MasterWingX():
  1509. def __init__(self,dmx=1):
  1510. pass
  1511. self.elem=[]
  1512. self.dmx=dmx
  1513. cprint("init MasterWing",dmx)
  1514. def event(self,a1="",a2=""):
  1515. cprint([self.dmx,a1,a2])
  1516. jdata = {'CMD': "MASTER", 'NAME': str(a1),'VALUE':str(a2) }
  1517. j=[]
  1518. j.append(jdata)
  1519. jclient_send(j)
  1520. class BufferVar():
  1521. def __init__(self,elem):
  1522. self.elem = elem
  1523. def change_dmx(self,event=""):
  1524. nr=1
  1525. txt=""
  1526. def cb(data):
  1527. txt = data["Value"]
  1528. dialog._cb = _cb
  1529. dialog.askstring("FADER-DMX-START",""+str(nr+1),initialvalue=txt)
  1530. cprint("change_dmx",[event,self])
  1531. lf_nr = 0
  1532. from tkinter import PhotoImage
  1533. _shift_key = 0
  1534. class WindowManager():
  1535. def __init__(self):
  1536. self.windows = {}
  1537. self.obj = {}
  1538. self.nr= 0
  1539. self.first=""
  1540. self.window_init_buffer = {}
  1541. def update(self,w,name="",obj=None):
  1542. name = str(name)
  1543. for k in self.windows:
  1544. if k == name:
  1545. self.windows[str(name)] = w
  1546. self.obj[str(name)] = obj
  1547. def new(self,w,name="",obj=None,wcb=None):
  1548. name = str(name)
  1549. if wcb and name:
  1550. self.window_init_buffer[name] = wcb
  1551. if not self.first:
  1552. if name:
  1553. self.first = name
  1554. else:
  1555. self.first = str(self.nr)
  1556. if w:
  1557. w.tk.state(newstate='normal')
  1558. w.tk.attributes('-topmost',True)
  1559. if name:
  1560. self.windows[str(name)] = w
  1561. self.obj[str(name)] = obj
  1562. else:
  1563. self.windows[str(self.nr)] = w
  1564. self.obj[str(self.nr)] = obj
  1565. self.nr+=1
  1566. def mainloop(self):
  1567. self.windows[self.first].mainloop()
  1568. def get_win(self,name):
  1569. #cprint(".get_win(name) =",name)
  1570. name = str(name)
  1571. if name in self.windows:
  1572. out = self.windows[name]
  1573. #cprint(out)
  1574. return out
  1575. def get(self,name):
  1576. return get_win(name)
  1577. def get_obj(self,name):
  1578. name = str(name)
  1579. if name in self.windows:
  1580. out = self.obj[name]
  1581. return out
  1582. def create(self,name):
  1583. #cprint( "create Window",name)
  1584. if name in self.window_init_buffer:
  1585. c = self.window_init_buffer[name]
  1586. w,obj,cb_ok = c.create()
  1587. window_manager.update(w,name,obj)
  1588. if cb_ok:
  1589. cb_ok()
  1590. resize = 1
  1591. if "resize" in c.args:
  1592. if not c.args["resize"]:
  1593. resize = 0
  1594. #if resize:
  1595. libwin.get_window_position(_filter=name,win=w)
  1596. if name in ["ENCODER"]:
  1597. global _ENCODER_WINDOW
  1598. _ENCODER_WINDOW = w
  1599. if name in ["DIMMER","FIXTURES"]:
  1600. refresher_fix.reset() # = Refresher()
  1601. def _check_window_is_open(self,name):
  1602. try:
  1603. win = self.windows[name]
  1604. if "tk" not in dir(win):
  1605. return 0
  1606. return win.tk.winfo_exists()
  1607. except Exception as e:
  1608. cprint("_check_window_is_open err",e,color="red")
  1609. def top(self,name):
  1610. name = str(name)
  1611. if name not in self.windows:
  1612. cprint(name," not in self.windows",self.windows.keys())
  1613. return
  1614. if not self._check_window_is_open(name):
  1615. cprint(" ",name," window is closed ! ")
  1616. self.create(name)
  1617. w = self.windows[name]
  1618. if not str(type(w)).startswith("<class 'function'>"):
  1619. w.tk.attributes('-topmost',True)
  1620. w.tk.attributes('-topmost',False)
  1621. w.tk.update_idletasks()
  1622. else:
  1623. print(" 2.2-",w)
  1624. w()
  1625. class Console():
  1626. def __init__(self):
  1627. pass
  1628. def flash_off(self,fix):
  1629. pass
  1630. def fx_off(self,fix):
  1631. cprint("Console.fx_off()",fix)
  1632. if not fix or fix == "all":
  1633. j = []
  1634. if 0:
  1635. jdata = {'VALUE': None, 'args': [], 'FX': 'alloff::::', 'FADE': 2, 'DMX': '0'}
  1636. j.append(jdata)
  1637. jdata = {'VALUE': None, 'args': [], 'FX': 'alloff::::', 'FADE': 2,'FLASH':1, 'DMX': '0'}
  1638. j.append(jdata)
  1639. else:
  1640. jdata = {'VALUE': None, 'args': [], 'FX2': {"TYPE":"alloff"}, 'FADE': 2,'FLASH':1, 'DMX': '1'}
  1641. j.append(jdata)
  1642. if not modes.val("BLIND"):
  1643. jclient_send(j)
  1644. return 0
  1645. window_manager = WindowManager()
  1646. CONSOLE = Console()
  1647. PRESETS = Presets()
  1648. FIXTURES = fixlib.Fixtures()
  1649. FIXTURES.gui = GUIHandler()
  1650. def LOAD_SHOW():
  1651. PRESETS.load_presets()
  1652. FIXTURES.load_patch()
  1653. LOAD_SHOW()
  1654. master = MASTER()
  1655. class Refresher():
  1656. def __init__(self):
  1657. self.time = time.time()
  1658. self.time_max = time.time()
  1659. self.time_delta = 15
  1660. self.update = 1
  1661. self.name = "name" # exec
  1662. self.cb = None #self.dummy_cb
  1663. def dummy_cb(self):
  1664. cprint("dummy_cd()",time.time()-self.time)
  1665. def reset(self):
  1666. self.time = time.time()
  1667. self.update = 1
  1668. def refresh(self):
  1669. if self.update:
  1670. if self.time+self.time_delta < time.time():
  1671. self._refresh()
  1672. else:
  1673. self.time = time.time()
  1674. def _refresh(self):
  1675. cprint("_refresh()",self.name,self)
  1676. if not INIT_OK:
  1677. return
  1678. self.time_max = time.time()
  1679. self.time = time.time()
  1680. self.update = 0
  1681. try:
  1682. if self.cb:
  1683. self.cb()
  1684. else:
  1685. self.dummy_cb()
  1686. except Exception as e:
  1687. cprint("_refresh except:",e,"cb:",self.cb)
  1688. traceback.print_exc()
  1689. cprint()
  1690. cprint("t=",self.time_max- time.time())
  1691. def loop(self,args={}):
  1692. while 1:
  1693. try:
  1694. if INIT_OK:
  1695. self.refresh()
  1696. #tkinter.Tk.update_idletasks(gui_menu_gui.tk)
  1697. except Exception as e:
  1698. cprint("loop exc",e)
  1699. traceback.print_exc()
  1700. cprint("== cb EXCEPT",e,color="red")
  1701. cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
  1702. cprint(''.join(traceback.format_exception(None, e, e.__traceback__)),color="red")
  1703. time.sleep(0.2)
  1704. print("main",__name__)
  1705. refresher_fix = Refresher()
  1706. refresher_fix.time_delta = 0.50
  1707. refresher_fix.name = "fix"
  1708. refresher_fix.reset()
  1709. refresher_fix.cb = master._refresh_fix
  1710. refresher_exec = Refresher()
  1711. refresher_exec.time_delta = 10 #0
  1712. refresher_exec.name = "exec"
  1713. refresher_exec.reset()
  1714. refresher_exec.cb = master._refresh_exec
  1715. refresher_exec = Refresher()
  1716. refresher_exec.time_delta = 10 #0
  1717. refresher_exec.name = "exec-fader"
  1718. refresher_exec.reset()
  1719. refresher_exec.cb = refresh_exec_fader_cfg
  1720. def loops(**args):
  1721. time.sleep(5) # wait until draw all window's
  1722. cprint("-> run loops")
  1723. thread.start_new_thread(refresher_fix.loop,())
  1724. thread.start_new_thread(refresher_exec.loop,())
  1725. class window_create_sdl_buffer():
  1726. def __init__(self,args,cls,data,cb_ok=None,scroll=0,gui=None):
  1727. self.args = args.copy()
  1728. self.cls = cls
  1729. self.cb_ok = cb_ok
  1730. self.data = data
  1731. self.scroll = scroll
  1732. self.gui = gui
  1733. def create(self,hidde=0):
  1734. cprint()
  1735. return [self.cls,self.cls,None] #w,obj,cb_ok
  1736. class window_create_buffer():
  1737. def __init__(self,args,cls,data,cb_ok=None,scroll=0,gui=None):
  1738. self.args = args.copy()
  1739. self.cls = cls
  1740. self.cb_ok = cb_ok
  1741. self.data = data
  1742. self.scroll = scroll
  1743. self.gui = gui
  1744. def create(self,hidde=0):
  1745. obj = None
  1746. w = libtk.Window(self.args)
  1747. out = []
  1748. f = None
  1749. h = None
  1750. if self.scroll:
  1751. head = None
  1752. foot = None
  1753. if "head" in self.args:
  1754. head = self.args["head"]
  1755. if "foot" in self.args:
  1756. foot = self.args["foot"]
  1757. w1 = ScrollFrame(w.tk,width=self.args["width"],height=self.args["height"],foot=foot,head=head)
  1758. if type(w1) is list:
  1759. try:
  1760. h = w1[0]
  1761. f = w1[2]
  1762. except:pass
  1763. w1 = w1[1]
  1764. else:
  1765. w1 = tk.Frame(w.tk,width=self.args["width"],height=self.args["height"])
  1766. w1.pack()
  1767. try:
  1768. obj=self.cls(self.gui,w1,self.data,foot=f,head=h)
  1769. except:
  1770. obj=self.cls(self.gui,w1,self.data)
  1771. return w,obj,self.cb_ok
  1772. def open_sdl_window():
  1773. cprint("open_sdl_window ... delay 1sec",color="yellow")
  1774. time.sleep(1)
  1775. if "--easy" not in sys.argv:
  1776. movewin.startup_all_sdl()
  1777. thread.start_new_thread(loops,())
  1778. mc_fix = MC_FIX()
  1779. def mc_fix_loop():
  1780. time.sleep(5)
  1781. while 1:
  1782. try:
  1783. #print(1)
  1784. data = FIXTURES.fixtures
  1785. mc_fix.set(index="fix",data=data)
  1786. except Exception as e:
  1787. print("MC_FIX EXCEPTION",e)
  1788. time.sleep(1/10)
  1789. thread.start_new_thread(mc_fix_loop,())
  1790. thread.start_new_thread(open_sdl_window,())
  1791. #while 1:
  1792. # time.sleep(1)
  1793. # if not __run_main:
  1794. # break
  1795. if __run_main:
  1796. cprint("main")
  1797. TOP = libtk._POS_TOP + 15
  1798. L0 = libtk._POS_LEFT
  1799. L1 = libtk._POS_LEFT + 95
  1800. L2 = libtk._POS_LEFT + 920
  1801. W1 = 810
  1802. H1 = 550
  1803. HTB = 23 # hight of the titlebar from window manager
  1804. pos_list = libwin.read_window_position()
  1805. data = []
  1806. #data.append({"text":"COMMAND"})
  1807. #data.append({"text":"CONFIG"})
  1808. data.append({"text":"PATCH"})
  1809. data.append({"text":"DIMMER"})
  1810. data.append({"text":"FIXTURES"})
  1811. data.append({"text":"FIX-LIST"})
  1812. data.append({"text":"EXEC","name":"EXEC-BTN"})
  1813. data.append({"text":"EXEC-WING"})
  1814. data.append({"text":"---"})
  1815. data.append({"text":"SETUP"})
  1816. data.append({"text":"COMMAND"})
  1817. data.append({"text":"LIVE"})
  1818. data.append({"text":"FX"})
  1819. data.append({"text":"ENCODER"})
  1820. data.append({"text":"COLORPICKER","name":"COLOR"})
  1821. data.append({"text":"---"})
  1822. data.append({"text":"FIXTURE-EDITOR","name":"FIX-EDIT"})
  1823. data.append({"text":"CONFIG"})
  1824. data.append({"text":"SDL-MIDI"})
  1825. data.append({"text":"CLOCK"})
  1826. data.append({"text":"RAY-DMX"})
  1827. data.append({"text":"SDL-DMX"})
  1828. data.append({"text":"SDL-VPU"})
  1829. data.append({"text":"SDL-OSZI"})
  1830. data.append({"text":"---"})
  1831. data.append({"text":"---"})
  1832. data.append({"text":"- DEMO -"})
  1833. data.append({"text":"---"})
  1834. data.append({"text":"SDL-STAGE"})
  1835. data.append({"text":"SDL-Shader"})
  1836. #data.append({"text":"MASTER-WING"})
  1837. name="MAIN"
  1838. args = {"title":"MAIN","master":1,"width":80,"height":H1,"left":L0,"top":TOP,"resize":1}
  1839. geo = libwin.split_window_position(pos_list,name)
  1840. if geo:
  1841. args.update(geo)
  1842. cls = GUI_menu
  1843. cb_ok = None
  1844. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  1845. window_manager.new(None,name,wcb=c)
  1846. window_manager.top(name)
  1847. gui_menu_gui = window_manager.get_win(name)
  1848. gui_menu = window_manager.get_obj(name)
  1849. master._refresh_fix()
  1850. # =======================================================================
  1851. name="EXEC"
  1852. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  1853. geo = libwin.split_window_position(pos_list,name)
  1854. if geo:
  1855. args.update(geo)
  1856. data = PRESETS
  1857. cls = draw_exec #GUI_ExecWingLayout
  1858. cb_ok = None #set_exec_fader_all
  1859. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  1860. window_manager.new(None,name,wcb=c)
  1861. if libwin.split_window_show(pos_list,_filter=name):
  1862. window_manager.top(name)
  1863. #print(dir(cls))
  1864. #print(cls)
  1865. #sys.exit()
  1866. # =======================================================================
  1867. name="SDL-MIDI"
  1868. def sdl_config():
  1869. cmd="nohup /usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/midi.py &"
  1870. cmd="/usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/midi.py " #&"
  1871. print(cmd)
  1872. #os.popen(cmd)
  1873. def xyz123(cmd):
  1874. os.system(cmd)
  1875. thread.start_new_thread(xyz123,(cmd,))
  1876. return [None,None,None]
  1877. #class window_create_sdl_buffer():
  1878. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  1879. geo = libwin.split_window_position(pos_list,name)
  1880. if geo:
  1881. args.update(geo)
  1882. data = []
  1883. cls = sdl_config #: None #GUI_CONF
  1884. cb_ok = None
  1885. c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  1886. window_manager.new(None,name,wcb=c)
  1887. if libwin.split_window_show(pos_list,_filter=name):
  1888. window_manager.top(name)
  1889. # =======================================================================
  1890. name="SDL-VPU"
  1891. def sdl_config():
  1892. cmd="nohup /usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/config.py &"
  1893. cmd="/usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/dmx.py " #&"
  1894. cmd="python3 /opt/LibreLight/Xdesk/vpu/watchdog_vpu.py -single"
  1895. print(cmd)
  1896. #os.popen(cmd)
  1897. def xyz123(cmd):
  1898. os.system(cmd)
  1899. thread.start_new_thread(xyz123,(cmd,))
  1900. return [None,None,None]
  1901. #class window_create_sdl_buffer():
  1902. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  1903. geo = libwin.split_window_position(pos_list,name)
  1904. if geo:
  1905. args.update(geo)
  1906. data = []
  1907. cls = sdl_config #: None #GUI_CONF
  1908. cb_ok = None
  1909. c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  1910. window_manager.new(None,name,wcb=c)
  1911. if libwin.split_window_show(pos_list,_filter=name):
  1912. window_manager.top(name)
  1913. # =======================================================================
  1914. #python3 /opt/LibreLight/Xdesk/vpu/watchdog_vpu.py -single
  1915. name="SDL-OSZI"
  1916. def sdl_config():
  1917. cmd="python3 /opt/LibreLight/ASP/monitor/oszi_grid.py"
  1918. print(cmd)
  1919. def xyz123(cmd):
  1920. os.system(cmd)
  1921. thread.start_new_thread(xyz123,(cmd,))
  1922. return [None,None,None]
  1923. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  1924. geo = libwin.split_window_position(pos_list,name)
  1925. if geo:
  1926. args.update(geo)
  1927. data = []
  1928. cls = sdl_config #: None #GUI_CONF
  1929. cb_ok = None
  1930. c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  1931. window_manager.new(None,name,wcb=c)
  1932. if libwin.split_window_show(pos_list,_filter=name):
  1933. window_manager.top(name)
  1934. # =======================================================================
  1935. #python3 /opt/LibreLight/Xdesk/vpu/watchdog_vpu.py -single
  1936. name="SDL-DMX"
  1937. def sdl_config():
  1938. cmd="nohup /usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/config.py &"
  1939. cmd="/usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/dmx.py " #&"
  1940. print(cmd)
  1941. #os.popen(cmd)
  1942. def xyz123(cmd):
  1943. os.system(cmd)
  1944. thread.start_new_thread(xyz123,(cmd,))
  1945. return [None,None,None]
  1946. #class window_create_sdl_buffer():
  1947. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  1948. geo = libwin.split_window_position(pos_list,name)
  1949. if geo:
  1950. args.update(geo)
  1951. data = []
  1952. cls = sdl_config #: None #GUI_CONF
  1953. cb_ok = None
  1954. c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  1955. window_manager.new(None,name,wcb=c)
  1956. if libwin.split_window_show(pos_list,_filter=name):
  1957. window_manager.top(name)
  1958. # =======================================================================
  1959. #python3 /opt/LibreLight/Xdesk/vpu/watchdog_vpu.py -single
  1960. name="RAY-DMX"
  1961. def sdl_config():
  1962. cmd="nohup /usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/config.py &"
  1963. cmd="/usr/bin/python3 /opt/LibreLight/Xdesk/tkray/dmx.py " #&"
  1964. print(cmd)
  1965. #os.popen(cmd)
  1966. def xyz123(cmd):
  1967. os.system(cmd)
  1968. thread.start_new_thread(xyz123,(cmd,))
  1969. return [None,None,None]
  1970. #class window_create_sdl_buffer():
  1971. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  1972. geo = libwin.split_window_position(pos_list,name)
  1973. if geo:
  1974. args.update(geo)
  1975. data = []
  1976. cls = sdl_config #: None #GUI_CONF
  1977. cb_ok = None
  1978. c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  1979. window_manager.new(None,name,wcb=c)
  1980. if libwin.split_window_show(pos_list,_filter=name):
  1981. window_manager.top(name)
  1982. # =======================================================================
  1983. name="SDL-STAGE"
  1984. def sdl_config():
  1985. cmd="/usr/bin/python3 /opt/LibreLight/Xdesk//3d/stage_3d.py " #&"
  1986. print(cmd)
  1987. #os.popen(cmd)
  1988. def xyz123(cmd):
  1989. os.system(cmd)
  1990. thread.start_new_thread(xyz123,(cmd,))
  1991. return [None,None,None]
  1992. #class window_create_sdl_buffer():
  1993. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  1994. geo = libwin.split_window_position(pos_list,name)
  1995. if geo:
  1996. args.update(geo)
  1997. data = []
  1998. cls = sdl_config #: None #GUI_CONF
  1999. cb_ok = None
  2000. c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  2001. window_manager.new(None,name,wcb=c)
  2002. if libwin.split_window_show(pos_list,_filter=name):
  2003. window_manager.top(name)
  2004. # =======================================================================
  2005. name="SDL-Shader"
  2006. def sdl_config():
  2007. cmd="/usr/bin/python3 /opt/LibreLight/Xdesk//3d/demo_shaders.py " #&"
  2008. print(cmd)
  2009. #os.popen(cmd)
  2010. def xyz123(cmd):
  2011. os.system(cmd)
  2012. thread.start_new_thread(xyz123,(cmd,))
  2013. return [None,None,None]
  2014. #class window_create_sdl_buffer():
  2015. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  2016. geo = libwin.split_window_position(pos_list,name)
  2017. if geo:
  2018. args.update(geo)
  2019. data = []
  2020. cls = sdl_config #: None #GUI_CONF
  2021. cb_ok = None
  2022. c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  2023. window_manager.new(None,name,wcb=c)
  2024. if libwin.split_window_show(pos_list,_filter=name):
  2025. window_manager.top(name)
  2026. # =======================================================================
  2027. name="FIX-LIST"
  2028. def sdl_config():
  2029. cmd="/usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/fix.py " #&"
  2030. print(cmd)
  2031. #os.popen(cmd)
  2032. def xyz123(cmd):
  2033. os.system(cmd)
  2034. thread.start_new_thread(xyz123,(cmd,))
  2035. return [None,None,None]
  2036. #class window_create_sdl_buffer():
  2037. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  2038. geo = libwin.split_window_position(pos_list,name)
  2039. if geo:
  2040. args.update(geo)
  2041. data = []
  2042. cls = sdl_config #: None #GUI_CONF
  2043. cb_ok = None
  2044. c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  2045. window_manager.new(None,name,wcb=c)
  2046. if libwin.split_window_show(pos_list,_filter=name):
  2047. window_manager.top(name)
  2048. # =======================================================================
  2049. name="CONFIG"
  2050. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  2051. geo = libwin.split_window_position(pos_list,name)
  2052. if geo:
  2053. args.update(geo)
  2054. data = []
  2055. cls = GUI_CONF
  2056. cb_ok = None
  2057. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  2058. window_manager.new(None,name,wcb=c)
  2059. if libwin.split_window_show(pos_list,_filter=name):
  2060. window_manager.top(name)
  2061. # =======================================================================
  2062. name="DIMMER"
  2063. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  2064. geo = libwin.split_window_position(pos_list,name)
  2065. if geo:
  2066. args.update(geo)
  2067. cls = GUI_DIM
  2068. data = FIXTURES
  2069. ok_cb=None
  2070. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  2071. window_manager.new(None,name,wcb=c)
  2072. if libwin.split_window_show(pos_list,_filter=name):
  2073. window_manager.top(name)
  2074. # =======================================================================
  2075. name="FIXTURES"
  2076. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  2077. geo = libwin.split_window_position(pos_list,name)
  2078. if geo:
  2079. args.update(geo)
  2080. cls = GUI_FIX
  2081. ok_cb=None
  2082. data = FIXTURES
  2083. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  2084. window_manager.new(None,name,wcb=c)
  2085. if libwin.split_window_show(pos_list,_filter=name):
  2086. window_manager.top(name)
  2087. # =======================================================================
  2088. name="FIXTURE-EDITOR"
  2089. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
  2090. geo = libwin.split_window_position(pos_list,name)
  2091. if geo:
  2092. args.update(geo)
  2093. data=[]
  2094. for i in range(12*6):
  2095. data.append({"text"+str(i):"test"})
  2096. cls = GUI_FixtureEditor
  2097. #cls = GUI_FaderLayout
  2098. cb_ok = None
  2099. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2100. window_manager.new(None,name,wcb=c)
  2101. #window_manager.top(name)
  2102. # =======================================================================
  2103. name="MASTER-WING"
  2104. args = {"title":name,"master":0,"width":75,"height":405,"left":L0,"top":TOP+H1-220,"resize":0}
  2105. geo = libwin.split_window_position(pos_list,name)
  2106. if geo:
  2107. args.update(geo)
  2108. data=[]
  2109. for i in range(2):
  2110. data.append({"MASTER"+str(i):"MASTER"})
  2111. cls = GUI_MasterWingLayout #(w1,data)
  2112. cb_ok = None
  2113. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2114. window_manager.new(None,name,wcb=c)
  2115. if libwin.split_window_show(pos_list,_filter=name):
  2116. window_manager.top(name)
  2117. # =======================================================================
  2118. name="EXEC-WING"
  2119. args = {"title":name,"master":0,"width":600,"height":415,"left":L1,"top":TOP+H1+HTB*2,"H1":H1,"W1":W1}
  2120. geo = libwin.split_window_position(pos_list,name)
  2121. if geo:
  2122. args.update(geo)
  2123. data=[]
  2124. for i in range(10*3):
  2125. data.append({"EXEC"+str(i):"EXEC"})
  2126. cls = GUI_ExecWingLayout
  2127. cb_ok = set_exec_fader_all
  2128. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  2129. window_manager.new(None,name,wcb=c)
  2130. if libwin.split_window_show(pos_list,_filter=name):
  2131. window_manager.top(name)
  2132. # =======================================================================
  2133. name="ENCODER"
  2134. args = {"title":name,"master":0,"width":620,"height":113,"left":L0+710,"top":TOP+H1+15+HTB*2}
  2135. geo = libwin.split_window_position(pos_list,name)
  2136. if geo:
  2137. args.update(geo)
  2138. cls = draw_enc #(master,w.tk)#Xroot)
  2139. cb_ok = None
  2140. data = FIXTURES #master
  2141. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2142. window_manager.new(None,name,wcb=c)
  2143. if libwin.split_window_show(pos_list,_filter=name):
  2144. window_manager.top(name)
  2145. # =======================================================================
  2146. name = "SETUP"
  2147. args = {"title":name +" SHOW:"+master.base.show_name,
  2148. "master":0,"width":445,"height":42,"left":L1+10+W1,"top":TOP,"resize":10}
  2149. args["title"] = "SETUP SHOW:"+master.base.show_name
  2150. geo = libwin.split_window_position(pos_list,name)
  2151. try:
  2152. geo["width"] = args["width"]
  2153. geo["height"] = args["height"]
  2154. except:pass
  2155. if geo:
  2156. args.update(geo)
  2157. cls = draw_setup #(master,w.tk)
  2158. data = []
  2159. cb_ok = None
  2160. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2161. window_manager.new(None,name,wcb=c)
  2162. if libwin.split_window_show(pos_list,_filter=name):
  2163. window_manager.top(name)
  2164. # =======================================================================
  2165. name = "COMMAND"
  2166. args = {"title":name,"master":0,"width":415,"height":130,"left":L1+10+W1,"top":TOP+81,"resize":10}
  2167. geo = libwin.split_window_position(pos_list,name)
  2168. if geo:
  2169. args.update(geo)
  2170. cls = draw_command #(master,w.tk)
  2171. data = []
  2172. cb_ok = None
  2173. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2174. window_manager.new(None,name,wcb=c)
  2175. if libwin.split_window_show(pos_list,_filter=name):
  2176. window_manager.top(name)
  2177. # =======================================================================
  2178. name = "LIVE"
  2179. args = {"title":name,"master":0,"width":415,"height":42,"left":L1+10+W1,"top":TOP+235,"resize":10}
  2180. geo = libwin.split_window_position(pos_list,name)
  2181. if geo:
  2182. args.update(geo)
  2183. cls = draw_live #(master,w.tk)
  2184. data = []
  2185. cb_ok = None
  2186. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2187. window_manager.new(None,name,wcb=c)
  2188. if libwin.split_window_show(pos_list,_filter=name):
  2189. window_manager.top(name)
  2190. # =======================================================================
  2191. name = "CLOCK"
  2192. args = {"title":name,"master":0,"width":335,"height":102,"left":L1+10+W1+80,"top":TOP+H1+HTB+160,"resize":0}
  2193. geo = libwin.split_window_position(pos_list,name)
  2194. if geo:
  2195. args.update(geo)
  2196. cclock = X_CLOCK()
  2197. cls = cclock.draw_clock
  2198. data = []
  2199. cb_ok = None
  2200. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2201. window_manager.new(None,name,wcb=c)
  2202. if libwin.split_window_show(pos_list,_filter=name):
  2203. window_manager.top(name)
  2204. # =======================================================================
  2205. name="FX"
  2206. args = {"title":name,"master":0,"width":415,"height":297+30,"left":L1+10+W1,"top":TOP+302,"resize":1}
  2207. geo = libwin.split_window_position(pos_list,name)
  2208. if geo:
  2209. args.update(geo)
  2210. cls = draw_fx #(master,w.tk)
  2211. data = []
  2212. cb_ok = None
  2213. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2214. window_manager.new(None,name,wcb=c)
  2215. if libwin.split_window_show(pos_list,_filter=name):
  2216. window_manager.top(name)
  2217. # =======================================================================
  2218. name="PATCH"
  2219. args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP,"foot":1,"head":1}
  2220. geo = libwin.split_window_position(pos_list,name)
  2221. if geo:
  2222. args.update(geo)
  2223. cls = GUI_PATCH
  2224. data = FIXTURES
  2225. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
  2226. window_manager.new(None,name,wcb=c) #,obj)
  2227. if libwin.split_window_show(pos_list,_filter=name):
  2228. window_manager.top(name)
  2229. # =======================================================================
  2230. name="COLORPICKER"
  2231. args = {"title":name,"master":0,"width":600,"height":113,"left":L1+5,"top":TOP+5+HTB*2+H1}
  2232. geo = libwin.split_window_position(pos_list,name)
  2233. if geo:
  2234. args.update(geo)
  2235. #w = libtk.Window(args)
  2236. #draw_colorpicker(master,w.tk,FIXTURES,master)
  2237. cls = draw_colorpicker #(master,w.tk,FIXTURES,master)
  2238. data = [FIXTURES,master]
  2239. cb_ok = None #FIXTURES
  2240. c = window_create_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=0)
  2241. window_manager.new(None,name,wcb=c)
  2242. if libwin.split_window_show(pos_list,_filter=name):
  2243. window_manager.top(name)
  2244. # =======================================================================
  2245. name="TableA"
  2246. #w = libtk.Window(name,master=0,width=W1,height=H1,left=L1,top=TOP)
  2247. #space_font = tk.font.Font(family="FreeSans", size=1 ) #, weight="bold")
  2248. #x=TableFrame(root=w.tk)#,left=80,top=620)
  2249. #w.show()
  2250. #data =[]
  2251. #for a in range(40):
  2252. # data.append(["E","E{}".format(a+1)])
  2253. #x.draw(data=data,head=["E","C"],config=[12,5,5])
  2254. #w=x.bframe
  2255. #window_manager.new(w,name)
  2256. master.render()
  2257. window_manager.top("Table")
  2258. #w = frame_fix #Window("OLD",master=0,width=W1,height=500,left=130,top=TOP)
  2259. #window_manager.new(w,name)
  2260. #if "--easy" in sys.argv:
  2261. #load_window_position()
  2262. try:
  2263. window_manager.mainloop()
  2264. finally:
  2265. print()
  2266. print()
  2267. cprint(" - EXIT -",color="red")
  2268. BASE_PATH = "/opt/LibreLight/Xdesk/"
  2269. movewin.process_kill(BASE_PATH+"tksdl/")
  2270. master.exit()