_LibreLightDesk.py 69 KB

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