_LibreLightDesk.py 83 KB

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