_LibreLightDesk.py 176 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. This file is part of LibreLight.
  5. LibreLight is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, version 2 of the License.
  8. LibreLight is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with LibreLight. If not, see <http://www.gnu.org/licenses/>.
  14. (c) 2012 micha@uxsrv.de
  15. """
  16. import random
  17. rnd_id = str(random.randint(1000,9000))
  18. rnd_id += " Beta 22.10 "
  19. import subprocess
  20. import string
  21. _gcmd=['git', 'rev-parse', '--short', 'HEAD']
  22. try:
  23. r = subprocess.check_output(_gcmd)
  24. rnd_id += r.decode('ascii').strip()
  25. except Exception as e:
  26. rnd_id += " no git"
  27. #rnd_id += " ".join(_gcmd) +str(e)
  28. try:
  29. xtitle = __file__
  30. except:
  31. xtitle = "__file__"
  32. if "/" in xtitle:
  33. xtitle = xtitle.split("/")[-1]
  34. import sys
  35. sys.stdout.write("\x1b]2;"+str(xtitle)+" "+str(rnd_id)+"\x07") # terminal title
  36. import json
  37. import time
  38. import sys
  39. import os
  40. import _thread as thread
  41. import traceback
  42. import tkinter
  43. import tkinter as tk
  44. from tkinter import font
  45. space_font = None
  46. import tkinter.simpledialog
  47. import lib.zchat as chat
  48. import lib.motion as motion
  49. from collections import OrderedDict
  50. _POS_LEFT = 0
  51. _POS_TOP = 15
  52. _config = []
  53. try:
  54. h = os.environ["HOME"]
  55. lines = [{}]
  56. try:
  57. f = open(h +"/LibreLight/config.json")
  58. lines = f.readlines()
  59. except FileNotFoundError as e: #Exception as e:
  60. f = open(h +"/LibreLight/config.json","w")
  61. f.write('{"POS_TOP":0}\n{"POS_LEFT":0}')
  62. f.close()
  63. print("Exception:",e)
  64. for line in lines:
  65. line=line.strip()
  66. print("config read",line)
  67. row = json.loads(line)
  68. _config.append(row)
  69. except Exception as e:
  70. print("Exception:",e)
  71. try:
  72. for row in _config:
  73. print("config:",row)
  74. if "POS_LEFT" in row:
  75. _POS_LEFT = int(row["POS_LEFT"])
  76. if "POS_TOP" in row:
  77. _POS_TOP = int(row["POS_TOP"])
  78. except Exception as e:
  79. print("Exception:",e)
  80. def showwarning(msg="<ERROR>",title="<TITLE>"):
  81. _main = tkinter.Tk()
  82. defaultFont = tkinter.font.nametofont("TkDefaultFont")
  83. print(defaultFont)
  84. defaultFont.configure(family="FreeSans",
  85. size=10,
  86. weight="normal")
  87. geo ="{}x{}".format(20,20)
  88. _main.geometry(geo)
  89. def _quit():
  90. time.sleep(.02)
  91. _main.quit()
  92. thread.start_new_thread(_main.mainloop,())
  93. #_main.quit()
  94. #msg="'{}'\n Show Does Not Exist\n\n".format(show_name)
  95. #msg += "please check\n"
  96. #msg += "-{}init.txt\n".format(self.show_path0)
  97. #msg += "-{}".format(self.show_path1)
  98. r=tkinter.messagebox.showwarning(message=msg,title=title,parent=None)
  99. CUES = OrderedDict()
  100. groups = OrderedDict()
  101. class Modes():
  102. def __init__(self):
  103. self.modes = {}
  104. self.__cfg = {}
  105. self.__cb = None
  106. def val(self,mode,value=None): #like jquery
  107. if value is not None:
  108. return self.set(mode,value)
  109. elif mode in self.modes:
  110. return self.modes[mode]
  111. def get(self,mode,value=None):
  112. return self.val(mode,value)
  113. def __check(self,mode):
  114. if mode not in self.modes:
  115. self.modes[mode] = 0
  116. self.__cfg[mode] = 0
  117. def cfg(self,mode,data={}):
  118. self.__check(mode)
  119. if type(data) is dict:
  120. for k in data:
  121. v = data[k]
  122. if v not in self.__cfg:
  123. self.__cfg[k] = v
  124. return 1
  125. elif type(data) is str:
  126. if data in self.__cfg:
  127. return self.__cfg[data]
  128. def set(self,mode,value):
  129. protected = ["BLIND","CLEAR","REC-FX"]
  130. self.__check(mode)
  131. if mode == "CLEAR":
  132. return 1
  133. elif mode == "ESC":
  134. for m in self.modes:
  135. print("ESC",m)
  136. if m == "COPY":
  137. PRESETS.clear_copy()
  138. if m == "MOVE":
  139. PRESETS.clear_move()
  140. if m != "BLIND":
  141. self.modes[m] = 0
  142. self.callback(m)
  143. return 1
  144. if value:
  145. for m in self.modes:
  146. if m not in protected and mode not in protected and m != mode:
  147. #cprint("-#-# clear mode",mode,m,value,color="red")
  148. if self.modes[m]:
  149. self.modes[m]= 0
  150. self.callback(m)
  151. if self.modes[mode] and value == 1:
  152. if modes == "MOVE":
  153. PRESETS.clear_move()
  154. if modes == "COPY":
  155. PRESETS.clear_copy()
  156. self.modes[mode] = 0 # value
  157. else:
  158. self.modes[mode] = value #1 #value
  159. else:
  160. self.modes[mode] = 0 #value
  161. if modes == "COPY":
  162. PRESETS.clear_copy()
  163. if modes == "MOVE":
  164. PRESETS.clear_move()
  165. self.callback(mode)
  166. return value
  167. def set_cb(self,cb):
  168. if cb:
  169. self.__cb = cb
  170. def callback(self,mode):
  171. if self.__cb is not None and mode in self.modes:
  172. value = self.modes[mode]
  173. self.__cb(mode=mode,value=value)
  174. modes = Modes()
  175. #modes.val("BLIND", 0)
  176. #modes.modes["BLIND"] = 0
  177. modes.modes["ESC"] = 0
  178. modes.modes["REC"] = 0
  179. modes.modes["EDIT"] = 0
  180. modes.modes["MOVE"] = 0
  181. modes.modes["FLASH"] = 0
  182. modes.modes["GO"] = 0
  183. modes.modes["DEL"] = 0
  184. modes.modes["REC-FX"] = 0
  185. modes.modes["SELECT"] = 0
  186. modes.modes["CFG-BTN"] = 0
  187. modes.modes["LABEL"] = 0
  188. def xcb(mode,value=None):
  189. print("xcb","MODE CALLBACK",mode,value)
  190. if mode == "REC-FX":
  191. print("xcb",modes.val("REC-FX"))
  192. #modes.set_cb(xcb)
  193. POS = ["PAN","TILT","MOTION"]
  194. COLOR = ["RED","GREEN","BLUE","COLOR"]
  195. BEAM = ["GOBO","G-ROT","PRISMA","P-ROT","FOCUS","SPEED"]
  196. INT = ["DIM","SHUTTER","STROBE","FUNC"]
  197. #client = chat.tcp_sender(port=50001)
  198. # remote input - start
  199. def JCB(x):
  200. exec_wing = window_manager.get_obj(name="EXEC-WING") #= WindowManager()
  201. if not exec_wing:
  202. return
  203. for i in x:
  204. jv = x[i]
  205. try:
  206. jv = json.loads(jv)
  207. jv = jv[0]
  208. print(jv)
  209. v = jv["iVAL"]
  210. exec_wing.set_fader(v)
  211. except Exception as e:
  212. print("exception",e)
  213. #print("remote in:",round(time.time(),0),"x",i,v)
  214. #chat.cmd(JCB,port=30002) # SERVER
  215. thread.start_new_thread(chat.cmd,(JCB,30002)) # SERVER
  216. # remote input - end
  217. jclient = chat.tcp_sender()#port=50001)
  218. import zlib
  219. def jclient_send(data):
  220. t_start = time.time()
  221. jtxt = data
  222. jdatas = []
  223. for jdata in data:
  224. if "CMD" in jdata:
  225. try:
  226. jdatas.append(jdata)
  227. except Exception as e:
  228. cprint("jclient_send, Exception DMX ",color="red")
  229. cprint("",jdata,color="red")
  230. cprint("-----",color="red")
  231. elif "DMX" in jdata:
  232. try:
  233. if int(jdata["DMX"]) >= 1: # ignore DMX lower one
  234. jdatas.append(jdata)
  235. else:
  236. cprint("jclient_send, ignore DMX ",jdata["DMX"],color="red")
  237. except Exception as e:
  238. cprint("jclient_send, Exception DMX ",color="red")
  239. cprint("",jdata,color="red")
  240. cprint("-----",color="red")
  241. jtxt = jdatas
  242. jtxt = json.dumps(jtxt)
  243. jtxt = jtxt.encode()
  244. #jtxt = zlib.compress(jtxt)
  245. jclient.send( jtxt ) #b"\00 ")
  246. #print(round((time.time()-t_start)*1000,4),"milis")
  247. cprint("{:0.04} sec.".format(time.time()-t_start),color="yellow")
  248. cprint("{:0.04} tick".format(time.time()),color="yellow")
  249. class ValueBuffer():
  250. def __init__(self,_min=0,_max=255):
  251. self._value = 2
  252. self._on = 1
  253. self._min=_min
  254. self._max=_max
  255. def check(self):
  256. if self._value < self._min:
  257. self._value = self._min
  258. elif self._value > self._max:
  259. self._value = self._max
  260. def inc(self,value=None):
  261. if value is not None:
  262. if type(value) is float:
  263. self._value += round(value,4)
  264. else:
  265. self._value += value
  266. self.check()
  267. return self._value
  268. def val(self,value=None):
  269. if value is not None:
  270. if type(value) is float:
  271. self._value = round(value,4)
  272. else:
  273. self._value = value
  274. self.check()
  275. return self._value
  276. def on(self):
  277. self._on = 1
  278. def off(self):
  279. self._on = 0
  280. def _is(self):
  281. if self._on:
  282. return 1
  283. return 0
  284. FADE = ValueBuffer() #2 #0.1 #1.13
  285. FADE.val(2.0)
  286. FADE_move = ValueBuffer() #2 #0.1 #1.13
  287. FADE_move.val(4.0)
  288. DELAY = ValueBuffer() #2 #0.1 #1.13
  289. DELAY.off()
  290. DELAY.val(0.2)
  291. 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}
  292. 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}
  293. fx_modes = ["RED","GREEN","BLUE","MAG","YELLOW","CYAN"]
  294. fx_mo = ["fade","on","rnd","ramp","ramp2","cosinus","sinus"]
  295. class FX_handler():
  296. def __init__():
  297. pass
  298. def reshape_preset(data ,value=None,xfade=0,flash=0,ptfade=0):
  299. f=0 #fade
  300. out = []
  301. delay=0
  302. for row in data:
  303. cprint("reshape_preset",row)
  304. line = {}
  305. line["DELAY"]=delay
  306. if type(value) is float:
  307. line["VALUE"] = value #round(value,3)
  308. else:
  309. line["VALUE"] = value
  310. if value is not None:
  311. line["FX"] = row["FX"].split(":",1)[-1]
  312. else:
  313. line["FX"] = row["FX"]
  314. if row["FX2"]:
  315. line["FX2"] = row["FX2"]
  316. if row["VALUE"] is not None:
  317. if value is None:
  318. v=row["VALUE"]
  319. if type(v) is float:
  320. line["VALUE"] = v #round(v,3)
  321. else:
  322. line["VALUE"] = v
  323. if row["ATTR"] in ["PAN","TILT"]:
  324. f = ptfade
  325. for a in ["DIM","ZOOM","FOCUS","RED","GREEN","BLUE","WHITE","AMBER","IRIS","BLADE"]:
  326. #FADE ATTRIBUTES
  327. if a in row["ATTR"]:
  328. f = xfade
  329. break
  330. if flash:
  331. xfade = 0
  332. if type( f ) is float:
  333. line["FADE"] = round(f,4)
  334. else:
  335. line["FADE"] = f
  336. if 0:
  337. cprint("reshape_preset j",line,color="red")
  338. cprint("reshape_preset",line)
  339. out.append(line)
  340. if DELAY._is():
  341. delay+=DELAY.val()/100 #0.02
  342. return out
  343. class dummy_event():
  344. def __init__(self):
  345. self.num =0
  346. self.type = 4 #press 5 release
  347. self.set_value=-1
  348. gcolor = 1
  349. def cprint(*text,color="blue",space=" ",end="\n"):
  350. #return 0 #disable print dbg
  351. if not gcolor:
  352. print(text)
  353. return 0
  354. if color == "green":
  355. txt = '\033[92m'
  356. elif color == "red":
  357. txt = '\033[0;31m\033[1m'
  358. elif color == "yellow":
  359. txt = '\033[93m\033[1m'
  360. elif color == "cyan":
  361. txt = '\033[96m'
  362. else:
  363. txt = '\033[94m'
  364. for t in text:
  365. txt += str(t ) +" "
  366. #HEADER = '\033[95m'
  367. #OKBLUE = '\033[94m'
  368. #OKCYAN = '\033[96m'
  369. #OKGREEN = '\033[92m'
  370. #WARNING = '\033[93m'
  371. #FAIL = '\033[91m'
  372. #ENDC = '\033[0m'
  373. #BOLD = '\033[1m'
  374. #UNDERLINE = '\033[4m'
  375. txt += '\033[0m'
  376. print(txt,end=end)
  377. #return txt
  378. cprint("________________________________")
  379. def process_wings(xfixtures):
  380. """process the wing's of selected fixtures
  381. input: [1,2,3,4,10,12,13,14]
  382. if WING = 2 return: [[1,2,3,4][14,13,12,10]]
  383. """
  384. wing_buffer = []
  385. fix_count = len(xfixtures)
  386. prm = fx_prm # ToDo: global WING for PAN/TILE !? ATTRIBUT is not availible in this moment
  387. if prm["WING"] > 1 and fix_count > 1:
  388. wing_count = fix_count // prm["WING"]
  389. number_of_fix_in_wing = fix_count // wing_count
  390. if number_of_fix_in_wing < 2:
  391. number_of_fix_in_wing = 2
  392. for i in range(number_of_fix_in_wing):
  393. j = i*wing_count
  394. wing = xfixtures[j:j+wing_count]
  395. if i%2!=0:
  396. wing = wing[::-1]
  397. print("wing",i,"j",j,"wing_count:",wing_count,"wing",wing)
  398. wing_buffer.append(wing)
  399. if fix_count > j+wing_count: # append Fixtures Left over
  400. wing = xfixtures[j+wing_count:]
  401. wing_buffer.append(wing)
  402. else:
  403. wing_buffer.append(xfixtures)
  404. if prm["SHUFFLE"]:
  405. _wing_buffer = []
  406. for wing in wing_buffer:
  407. wing = wing[:]
  408. random.shuffle(wing)
  409. _wing_buffer.append(wing)
  410. wing_buffer = _wing_buffer
  411. return wing_buffer
  412. def process_effect(wing_buffer,fx_name=""):
  413. jdatas = []
  414. offset = 0
  415. offset_move = 0
  416. start = fx_prm["START"]
  417. base = fx_prm["BASE"]
  418. for wing in wing_buffer:
  419. count_of_fix_in_wing = len(wing)
  420. coffset= 0 # 1024/count_of_fix_in_wing * (offset/255)
  421. coffset_move=0
  422. for fix in wing:
  423. data = FIXTURES.fixtures[fix]
  424. for attr in data["ATTRIBUT"]:
  425. jdata = {"MODE":"FX"}
  426. jdata["VALUE"] = None
  427. jdata["FIX"] = fix
  428. jdata["DMX"] = FIXTURES.get_dmx(fix,attr)
  429. jdata["ATTR"] =attr
  430. if attr.endswith("-FINE"):
  431. continue
  432. if attr in ["PAN","TILT"]:
  433. csize = fx_prm_move["SIZE"]
  434. cspeed = fx_prm_move["SPEED"]
  435. cstart = fx_prm_move["START"]
  436. cbase = fx_prm_move["BASE"]
  437. width = fx_prm_move["WIDTH"]
  438. invert = fx_prm_move["INVERT"]
  439. coffset_move= round(offset_move,1)
  440. else:
  441. csize = fx_prm["SIZE"]
  442. cspeed = fx_prm["SPEED"]
  443. cstart = fx_prm["START"]
  444. cbase = fx_prm["BASE"]
  445. width = fx_prm["WIDTH"]
  446. invert = fx_prm["INVERT"]
  447. coffset= round(offset,1)
  448. fx=""
  449. if "SIN" in fx_name:
  450. fx = "sinus"
  451. elif "FD" in fx_name:
  452. fx = "fade"
  453. elif "RND" in fx_name:
  454. fx = "rnd"
  455. elif "ON" in fx_name:
  456. fx = "on"
  457. elif "RAMP2" in fx_name:
  458. fx = "bump2"
  459. fx = "ramp2"
  460. elif "RAMP" in fx_name:
  461. fx = "ramp"
  462. elif "COS" in fx_name:
  463. fx = "cosinus"
  464. if fx:
  465. if attr in ["PAN","TILT"]:
  466. cprint("SKIP FX attr:{} fix:{} " .format(attr,fix) )
  467. continue
  468. if fx:
  469. if fx_prm["SPEED"] < 0:
  470. fx = "off"
  471. else:
  472. if ":DIM" in fx_name:
  473. base=""
  474. ffxb=fx_mo[fx_prm["MO"]]
  475. #ffxb= "cosinus"
  476. if attr == "DIM":
  477. if fx_prm["SPEED"] < 0:
  478. fx = "off"
  479. else:
  480. fx = ffxb #"fade"
  481. elif ":TILT" in fx_name:
  482. base=""
  483. if attr == "PAN":
  484. fx = "off"
  485. if attr == "TILT":
  486. if fx_prm["SPEED"] < 0:
  487. fx = "off"
  488. else:
  489. fx = "sinus"
  490. elif ":PAN" in fx_name:
  491. base=""
  492. if attr == "PAN":
  493. if fx_prm_move["SPEED"] < 0:
  494. fx = "off"
  495. else:
  496. fx = "cosinus"
  497. if attr == "TILT":
  498. fx = "off"
  499. elif ":CIR" in fx_name:
  500. base=""
  501. if attr == "PAN":
  502. if fx_prm_move["SPEED"] < 0:
  503. fx = "off"
  504. else:
  505. fx = "cosinus"
  506. if attr == "TILT":
  507. if fx_prm["SPEED"] < 0:
  508. fx = "off"
  509. else:
  510. fx = "sinus"
  511. elif ":RED" in fx_name:
  512. ffxb= fx_mo[fx_prm["MO"]]
  513. ffx= "off" #fx_mo[fx_prm["MO"]]
  514. if "RED" in fx_modes[fx_prm["MODE"]]:#
  515. base="-"
  516. if attr == "RED":
  517. fx=ffx
  518. if attr == "GREEN":
  519. fx = ffxb# "off"
  520. if attr == "BLUE":
  521. fx = ffxb#"off"
  522. elif "GREEN" in fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#in fx_name:
  523. base="-"
  524. if attr == "RED":
  525. fx = ffxb#"off"
  526. elif "GREEN" in fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#in fx_name:
  527. if attr == "GREEN":
  528. fx = ffxb# "off"
  529. fx=ffx
  530. if attr == "BLUE":
  531. fx = ffxb#"off"
  532. elif "BLUE" in fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#fx_name:
  533. base="-"
  534. if attr == "RED":
  535. fx = ffxb# "off"
  536. if attr == "GREEN":
  537. fx = ffxb# "off"
  538. if attr == "BLUE":
  539. fx = ffxb# "off"
  540. fx=ffx
  541. elif "YELLOW" in fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#fx_name:
  542. base="-"
  543. if attr == "RED":
  544. fx = ffxb# "off"
  545. fx=ffx
  546. if attr == "GREEN":
  547. fx = ffxb# "off"
  548. fx=ffx
  549. if attr == "BLUE":
  550. fx = "off"
  551. elif "CYAN" in fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#fx_name:
  552. base="-"
  553. if attr == "RED":
  554. fx = ffxb# "off"
  555. if attr == "GREEN":
  556. fx = ffxb# "off"
  557. fx=ffx
  558. if attr == "BLUE":
  559. fx = ffxb# "off"
  560. fx=ffx
  561. elif "MAG" in fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#fx_name:
  562. base="-"
  563. if attr == "RED":
  564. fx = ffxb# "off"
  565. fx=ffx
  566. if attr == "GREEN":
  567. fx = ffxb# "off"
  568. if attr == "BLUE":
  569. fx = ffxb# "off"
  570. fx=ffx
  571. else:
  572. cprint("FX: unbekant",fx_modes[fx_prm["MODE"]],color="red")
  573. fxtype = fx
  574. fxtype = fx
  575. if "FX" not in data["ATTRIBUT"][attr]:
  576. data["ATTRIBUT"][attr]["FX"] =""
  577. if "FX2" not in data["ATTRIBUT"][attr]:
  578. data["ATTRIBUT"][attr]["FX2"] ={}
  579. if data["ATTRIBUT"][attr]["ACTIVE"] and fxtype:
  580. #print("++ADD FX",fix,attr,fx)
  581. #data["ATTRIBUT"][attr]["FX"] = fx #"sinus:40:100:10"
  582. fjdata = {}
  583. if cspeed < 0.1:
  584. fjdata["TYPE"] = "off"
  585. else:
  586. fjdata["TYPE"] = fxtype
  587. fjdata["SIZE"] = round(csize,2)
  588. fjdata["SPEED"] = round(cspeed,2)
  589. fjdata["WIDTH"] = int(width)
  590. fjdata["START"] = cstart
  591. if attr in ["PAN","TILT"]:
  592. fjdata["OFFSET"]= round(coffset_move,2)
  593. else:
  594. fjdata["OFFSET"]= round(coffset,2)
  595. fjdata["INVERT"]= int(invert)
  596. fjdata["BASE"] = cbase
  597. jdata["FX2"] = fjdata
  598. data["ATTRIBUT"][attr]["FX2"] = fjdata
  599. jdatas.append(jdata)
  600. if fx_prm_move["OFFSET"] > 0.5: # and
  601. aoffset_move = (100/count_of_fix_in_wing) * (fx_prm_move["OFFSET"]/100)
  602. if fx_prm_move["DIR"] <= 0:
  603. offset_move -= aoffset_move
  604. else:
  605. offset_move += aoffset_move
  606. offset_move = round(offset_move,2)
  607. if fx_prm["OFFSET"] > 0.5: # and
  608. aoffset = (100/count_of_fix_in_wing) * (fx_prm["OFFSET"]/100)
  609. if fx_prm["DIR"] <= 0:
  610. offset -= aoffset
  611. else:
  612. offset += aoffset
  613. offset = round(offset,2)
  614. if jdatas and not modes.val("BLIND"):
  615. jclient_send(jdatas)
  616. master.refresh_fix()
  617. return jdatas
  618. class Xevent_fx():
  619. """ global input event Handeler for short cut's ... etc
  620. """
  621. def __init__(self,fix,elem,attr=None,data=None,mode=None):
  622. self.fix = fix
  623. self.data = data
  624. self.attr = attr
  625. self.elem = elem
  626. self.mode = mode
  627. def fx(self,event):
  628. cprint("Xevent.fx",self.attr,self.fix,event)
  629. fx2 = {}
  630. if event.num == 4:
  631. cprint("FX:COLOR CHANGE",fx_prm,color="red")
  632. txt = "FX:RED"
  633. fx_prm["MODE"] += 1
  634. if fx_prm["MODE"] > len(fx_modes):
  635. fx_prm["MODE"]=0
  636. txt = "FX:\n"+fx_modes[fx_prm["MODE"]]
  637. master.fx.elem["FX:RED"]["text"] = txt
  638. elif event.num == 5:
  639. cprint("FX:COLOR CHANGE",fx_prm,color="red")
  640. txt = "FX:RED"
  641. fx_prm["MODE"] -= 1
  642. if fx_prm["MODE"] < 0:
  643. fx_prm["MODE"]= len(fx_modes)-1
  644. txt = "FX:\n"+fx_modes[fx_prm["MODE"]]
  645. master.fx.elem["FX:RED"]["text"] = txt
  646. elif event.num == 1:
  647. xfixtures = []
  648. fix_active =FIXTURES.get_active()
  649. for fix in fix_active:
  650. if fix == "CFG":
  651. continue
  652. xfixtures.append(fix)
  653. if not xfixtures:
  654. cprint("470 fx() ... init no fixture selected",color="red")
  655. return 0
  656. wing_buffer = process_wings(xfixtures)
  657. process_effect(wing_buffer,fx_name=self.attr)
  658. def command(self,event,mode=""):
  659. cprint("fx_command",self.mode)
  660. if self.mode == "FX":
  661. prm = fx_prm
  662. ct = self.data.fx
  663. if self.mode == "FX-MOVE":
  664. prm = fx_prm_move
  665. ct = self.data.fx_moves
  666. if 1:
  667. if self.attr.startswith("SIZE:"):#SIN":
  668. #global fx_prm
  669. k = "SIZE"
  670. if event.num == 1:
  671. prm[k] =30
  672. elif event.num == 3:
  673. prm[k] =100
  674. elif event.num == 4:
  675. if prm[k] <= 0:
  676. prm[k] = 1
  677. prm[k] +=5
  678. elif event.num == 5:
  679. prm[k] -=5
  680. #prm[k] =int(prm[k])
  681. if prm[k] > 4000:
  682. prm[k] = 4000
  683. if prm[k] < 0:
  684. prm[k] =0
  685. if prm[k] == 6: #bug
  686. prm[k] =5
  687. ct.elem[self.attr]["text"] = "SIZE:\n{:0.0f}".format(prm[k])
  688. cprint(prm)
  689. elif self.attr.startswith("SPEED:"):#SIN":
  690. #global prm
  691. k = "SPEED"
  692. if event.num == 1:
  693. prm[k] = 6
  694. elif event.num == 3:
  695. prm[k] = 60
  696. elif event.num == 4:
  697. if prm[k] <= 0:
  698. prm[k] = 0.06
  699. elif prm[k] < 5:
  700. prm[k] *=1.2
  701. else:
  702. prm[k] +=5 #1.1
  703. elif event.num == 5:
  704. if prm[k] <= 5:
  705. prm[k] *=0.8
  706. else:
  707. prm[k] -= 5 #1.1
  708. #prm[k] =int(prm[k])
  709. if prm[k] > 4000:
  710. prm[k] = 4000
  711. if prm[k] < 0.05:
  712. prm[k] =0
  713. if prm[k] > 5 and prm[k] < 10: #bug
  714. prm[k] =5
  715. if prm[k] < 0:
  716. ct.elem[self.attr]["text"] = "SPEED:\noff".format(prm[k])
  717. else:
  718. ct.elem[self.attr]["text"] = "SPEED:\n{:0.02f}".format(prm[k])
  719. cprint(prm)
  720. elif self.attr.startswith("START:"):#SIN":
  721. #global prm
  722. k = "START"
  723. if event.num == 1:
  724. pass
  725. elif event.num == 2:
  726. pass
  727. elif event.num == 4:
  728. if prm[k] <= 0:
  729. prm[k] = 1
  730. prm[k] += 5 #1.1
  731. elif event.num == 5:
  732. prm[k] -= 5 #1.1
  733. #prm[k] =int(prm[k])
  734. if prm[k] > 4000:
  735. prm[k] = 4000
  736. if prm[k] < 5:
  737. prm[k] =0
  738. if prm[k] == 6: #bug
  739. prm[k] =5
  740. ct.elem[self.attr]["text"] = "START:\n{:0.0f}".format(prm[k])
  741. cprint(prm)
  742. elif self.attr.startswith("WIDTH:"):#SIN":
  743. #global prm
  744. k = "WIDTH"
  745. if event.num == 1:
  746. prm[k] = 25
  747. elif event.num == 2:
  748. prm[k] = 50
  749. elif event.num == 3:
  750. prm[k] = 100
  751. elif event.num == 4:
  752. if prm[k] <= 0:
  753. prm[k] = 1
  754. elif prm[k] == 50:
  755. prm[k] = 100
  756. elif prm[k] == 5:
  757. prm[k] = 25
  758. elif prm[k] == 25:
  759. prm[k] = 50
  760. else:
  761. prm[k] += 5 #*=1.1
  762. elif event.num == 5:
  763. if prm[k] == 10:
  764. prm[k] = 5
  765. elif prm[k] == 25:
  766. prm[k] = 10
  767. elif prm[k] == 50:
  768. prm[k] = 25
  769. elif prm[k] == 100:
  770. prm[k] = 50
  771. #else:
  772. # prm[k] -=5 #/=1.1
  773. #prm[k] =int(prm[k])
  774. if prm[k] < 0:
  775. prm[k] = 0
  776. if prm[k] > 100:
  777. prm[k] = 100
  778. if prm[k] == 6: #bug
  779. prm[k] =5
  780. if prm[k] > 25 and prm[k] < 50: #bug
  781. prm[k] =50
  782. if prm[k] > 50 and prm[k] < 100: #bug
  783. prm[k] =100
  784. ct.elem[self.attr]["text"] = "WIDTH:\n{:0.0f}".format(prm[k])
  785. cprint(prm)
  786. elif self.attr.startswith("DIR:"):#SIN":
  787. #global prm
  788. k = "DIR"
  789. if event.num == 1:
  790. prm[k] = 1
  791. elif event.num == 3:
  792. prm[k] = -1
  793. elif event.num == 4:
  794. prm[k] = 1
  795. elif event.num == 5:
  796. prm[k] =-1
  797. txt = prm[k]
  798. ct.elem[self.attr]["text"] = "DIR:\n{}".format(prm[k])
  799. cprint(prm)
  800. elif self.attr.startswith("SHUFFLE:"):#SIN":
  801. #global prm
  802. k = "SHUFFLE"
  803. if event.num == 1:
  804. prm[k] = 0
  805. elif event.num == 3:
  806. prm[k] = 1
  807. elif event.num == 4:
  808. prm[k] = 1
  809. elif event.num == 5:
  810. prm[k] =0
  811. if prm[k] == 6: #bug ?
  812. prm[k] =5
  813. ct.elem[self.attr]["text"] = k+":\n{}".format(prm[k])
  814. cprint(prm)
  815. elif self.attr.startswith("INVERT:"):#SIN":
  816. #global prm
  817. k = "INVERT"
  818. if event.num == 1:
  819. prm[k] = 0
  820. elif event.num == 3:
  821. prm[k] = 1
  822. elif event.num == 4:
  823. prm[k] = 1
  824. elif event.num == 5:
  825. prm[k] =0
  826. if prm[k] == 6: #bug ?
  827. prm[k] =5
  828. ct.elem[self.attr]["text"] = k+":\n{}".format(prm[k])
  829. cprint(prm)
  830. elif self.attr.startswith("WING:"):#SIN":
  831. #global prm
  832. k = "WING"
  833. if event.num == 1:
  834. prm[k] = 1
  835. elif event.num == 3:
  836. prm[k] = 2
  837. elif event.num == 4:
  838. prm[k] += 1
  839. elif event.num == 5:
  840. prm[k] -=1
  841. if prm[k] > 100:
  842. prm[k] = 100
  843. if prm[k] < 1:
  844. prm[k] =1
  845. txt = prm[k]
  846. ct.elem[self.attr]["text"] = "WING:\n{}".format(prm[k])
  847. cprint(prm)
  848. elif self.attr.startswith("OFFSET:"):#SIN":
  849. #global prm
  850. k = "OFFSET"
  851. if event.num == 1:
  852. prm[k] = 50
  853. elif event.num == 2:
  854. prm[k] *= 2
  855. elif event.num == 3:
  856. prm[k] = 100
  857. elif event.num == 4:
  858. if prm[k] <= 0:
  859. prm[k] = 1
  860. prm[k] +=5 #*=1.1
  861. elif event.num == 5:
  862. prm[k] -=5 #/=1.1
  863. #prm[k] =int(prm[k])
  864. #if prm[k] > 512:
  865. # prm[k] = 512
  866. if prm[k] < 5:
  867. prm[k] =0
  868. if prm[k] == 6: #bug
  869. prm[k] =5
  870. ct.elem[self.attr]["text"] = "OFFSET:\n{:0.0f}".format(prm[k])
  871. cprint(prm)
  872. elif self.attr.startswith("BASE:"):
  873. k = "BASE"
  874. if event.num == 1:
  875. prm[k] = "-"
  876. elif event.num == 3:
  877. prm[k] = "0"
  878. elif event.num == 4:
  879. prm[k] = "+"
  880. elif event.num == 5:
  881. prm[k] = "0"
  882. ct.elem[self.attr]["text"] = "BASE:\n{}".format(prm[k])
  883. elif self.attr.startswith("FX:"):#SIN":
  884. self.fx(event)
  885. elif self.attr == "FX OFF":
  886. if event.num == 1:
  887. FIXTURES.fx_off("all")
  888. CONSOLE.fx_off("all")
  889. CONSOLE.flash_off("all")
  890. master.refresh_fix()
  891. return 0
  892. #if event.num == 1:
  893. elif self.attr == "REC-FX":
  894. print("ELSE",self.attr)
  895. modes.val(self.attr,1)
  896. return 0
  897. def cb(self,event):
  898. cprint("EVENT_fx cb",self.attr,self.mode,event,color='yellow')
  899. print(["type",event.type,"num",event.num])
  900. try:
  901. change = 0
  902. if self.mode.startswith("FX"):
  903. self.command(event)
  904. return 0
  905. except Exception as e:
  906. cprint("== cb EXCEPT",e,color="red")
  907. cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
  908. cprint(''.join(traceback.format_exception(None, e, e.__traceback__)),color="red")
  909. return 1
  910. class Xevent():
  911. """ global input event Handeler for short cut's ... etc
  912. """
  913. def __init__(self,fix,elem,attr=None,data=None,mode=None):
  914. self.fix = fix
  915. self.data=data
  916. self.attr = attr
  917. self.elem = elem
  918. self.mode = mode
  919. def setup(self,event):
  920. cprint("xevent.SETUP",[self.mode,self.attr],color="red")
  921. if self.mode == "SETUP":
  922. if self.attr == "SAVE\nSHOW":
  923. self.elem["bg"] = "orange"
  924. self.elem["text"] = "SAVING..."
  925. self.elem["bg"] = "red"
  926. tkinter.Tk.update_idletasks(gui_menu_gui.tk)
  927. #self.elem["fg"] = "orange"
  928. self.elem.config(activebackground="orange")
  929. modes.val(self.attr,1)
  930. PRESETS.backup_presets()
  931. FIXTURES.backup_patch()
  932. #time.sleep(1)
  933. #modes.val(self.attr,0)
  934. self.elem["bg"] = "lightgrey"
  935. #self.elem["fg"] = "lightgrey"
  936. self.elem.config(activebackground="lightgrey")
  937. elif self.attr == "LOAD\nSHOW":
  938. name = "LOAD-SHOW"
  939. base = Base()
  940. line1 = "PATH: "+base.show_path1 +base.show_name
  941. line2 = "DATE: "+ time.strftime("%Y-%m-%d %X", time.localtime(time.time()))
  942. class cb():
  943. def __init__(self,name=""):
  944. self.name=name
  945. print("cb",name)
  946. def cb(self,event=None,**args):
  947. print("cdb",self.name,event,args)
  948. if self.name != "<exit>":
  949. print("-----------------------:")
  950. LOAD_SHOW_AND_RESTAT(self.name).cb()
  951. #self.elem["bg"] = "lightgrey"
  952. #self.elem.config(activebackground="lightgrey")
  953. pw = PopupList(name,cb=cb)
  954. frame = pw.sframe(line1=line1,line2=line2)
  955. r = _load_show_list(frame,cb=cb)
  956. #self.elem["bg"] = "red"# "lightgrey"
  957. #self.elem.config(activebackground="red")
  958. #self.elem.config(activebackground="lightgrey")
  959. #w.tk.attributes('-topmost',False)
  960. elif self.attr == "SAVE\nSHOW AS":
  961. base = Base()
  962. fname = tkinter.simpledialog.askstring("SAVE SHOW AS","SAVE SHOW AS:")
  963. fpath,fname = base.build_path(fname)
  964. cprint("SAVE AS",fpath,fname)
  965. if base._create_path(fpath):
  966. a=PRESETS.backup_presets(save_as=fpath)
  967. b=FIXTURES.backup_patch(save_as=fpath)
  968. #base._set(fname)
  969. LOAD_SHOW_AND_RESTAT(fname).cb()
  970. elif self.attr == "SAVE &\nRESTART":
  971. self.elem["bg"] = "orange"
  972. self.elem["text"] = "SAVING..."
  973. self.elem["bg"] = "red"
  974. tkinter.Tk.update_idletasks(gui_menu_gui.tk)
  975. #self.elem["fg"] = "orange"
  976. self.elem.config(activebackground="orange")
  977. modes.val(self.attr,1)
  978. PRESETS.backup_presets()
  979. FIXTURES.backup_patch()
  980. self.elem["text"] = "RESTARTING..."
  981. #time.sleep(1)
  982. #modes.val(self.attr,0)
  983. self.elem["bg"] = "lightgrey"
  984. #self.elem["fg"] = "lightgrey"
  985. self.elem.config(activebackground="lightgrey")
  986. LOAD_SHOW_AND_RESTAT("").cb(force=1)
  987. elif self.attr == "DRAW\nGUI":
  988. #self.elem["bg"] = "orange"
  989. old_text = self.elem["text"]
  990. self.elem["text"] = "DRAWING..."
  991. #self.elem["bg"] = "red"
  992. #time.sleep(0.05)
  993. #print("redraw",name)
  994. #if name == "PATCH":
  995. # gui_patch.draw()
  996. #if name == "DIMMER":
  997. # gui_fix.draw()
  998. self.elem["text"] = "PATCH..."
  999. window_manager.top("PATCH")
  1000. gui_patch.draw()
  1001. self.elem["text"] = "FIX..."
  1002. gui_fix.draw()
  1003. window_manager.top("FIXTURES")
  1004. master._refresh_exec()
  1005. self.elem["text"] = old_text
  1006. else:
  1007. r=tkinter.messagebox.showwarning(message="{}\nnot implemented".format(self.attr.replace("\n"," ")),parent=None)
  1008. return 1
  1009. def live(self,event):
  1010. if self.mode == "LIVE":
  1011. if "FADE" in self.attr or "DELAY" in self.attr:
  1012. if self.attr == "FADE":
  1013. ct = FADE
  1014. if self.attr == "DELAY":
  1015. ct = DELAY
  1016. if "PAN/TILT\nFADE" in self.attr:
  1017. ct = FADE_move
  1018. value = ct.val()
  1019. #print("EVENT CHANGE ",[self.attr])
  1020. print("EVENT CHANGE:",self.mode,value,self.attr)
  1021. if value < 0.01:
  1022. ct.val(0.01)
  1023. elif value > 100.0:
  1024. pass #value = 100
  1025. if event.num == 4:
  1026. value *= 1.1
  1027. elif event.num == 5:
  1028. value /= 1.1
  1029. elif event.num == 1:
  1030. if ct._is():
  1031. ct.off()# = 0
  1032. self.data.commands.elem[self.attr]["bg"] = "grey"
  1033. self.elem.config(activebackground="grey")
  1034. else:
  1035. ct.on()# = 1
  1036. self.data.commands.elem[self.attr]["bg"] = "green"
  1037. self.elem.config(activebackground="lightgreen")
  1038. elif event.num == 2:
  1039. if value > 1 and value < 4:
  1040. value = 4
  1041. elif value > 3 and value < 6:
  1042. value = 6
  1043. elif value > 5 and value < 7:
  1044. value = 8
  1045. elif value > 7 and value < 9:
  1046. value = 10
  1047. elif value > 9:
  1048. value = 0.01
  1049. elif value < 1:
  1050. value = 1.1
  1051. value = round(value,3)
  1052. value = ct.val(value)
  1053. if self.attr == "FADE":
  1054. self.data.commands.elem[self.attr]["text"] = "FADE:\n{:0.2f}".format(value)
  1055. if self.attr == "DELAY":
  1056. self.data.commands.elem[self.attr]["text"] = "DELAY:\n{:0.3f}".format(value)
  1057. if "PAN/TILT\nFADE" in self.attr:
  1058. self.data.commands.elem[self.attr]["text"] = "PAN/TILT\nFADE:{:0.2f}".format(value)
  1059. def command(self,event):
  1060. if self.mode == "COMMAND":
  1061. if self.attr == "CLEAR":
  1062. if event.num == 1:
  1063. ok = FIXTURES.clear()
  1064. if ok:
  1065. master.refresh_fix()
  1066. modes.val(self.attr,0)
  1067. elif self.attr == "SAVE":
  1068. modes.val(self.attr,1)
  1069. PRESETS.backup_presets()
  1070. FIXTURES.backup_patch()
  1071. #time.sleep(1)
  1072. modes.val(self.attr,0)
  1073. else:
  1074. if event.num == 1:
  1075. print("ELSE",self.attr)
  1076. modes.val(self.attr,1)
  1077. return 0
  1078. def encoder(self,event):
  1079. global _shift_key
  1080. if self.mode == "ENCODER":
  1081. cprint("Xevent","ENC",self.fix,self.attr,self.mode)
  1082. cprint("SHIFT_KEY",_shift_key,"??????????")
  1083. #cprint(self.data)
  1084. val=""
  1085. if event.num == 1:
  1086. val ="click"
  1087. elif event.num == 4:
  1088. val ="++"
  1089. if _shift_key:
  1090. val = "+"
  1091. elif event.num == 5:
  1092. val ="--"
  1093. if _shift_key:
  1094. val = "-"
  1095. print("SHIFT",val,_shift_key)
  1096. if val:
  1097. if self.attr == "DIM" and self.fix == 0 and val == "click":
  1098. pass
  1099. else:
  1100. FIXTURES.encoder(fix=self.fix,attr=self.attr,xval=val)
  1101. master.refresh_fix()
  1102. def cb(self,event):
  1103. cprint("EVENT cb",self.attr,self.mode,event,color='yellow')
  1104. print(["type",event.type,"num",event.num])
  1105. try:
  1106. change = 0
  1107. if "keysym" in dir(event):
  1108. if "Escape" == event.keysym:
  1109. ok = FIXTURES.clear()
  1110. master.refresh_fix()
  1111. return 0
  1112. if self.mode == "SETUP":
  1113. self.setup(event)
  1114. elif self.mode == "COMMAND":
  1115. self.command(event)
  1116. elif self.mode == "LIVE":
  1117. self.live(event)
  1118. elif self.mode == "ENCODER":
  1119. self.encoder(event)
  1120. elif self.mode == "FX":
  1121. cprint("Xevent CALLING FX WRONG EVENT OBJECT !!",color="red")
  1122. elif self.mode == "ROOT":
  1123. if event.keysym=="Escape":
  1124. pass
  1125. elif self.mode == "INPUT":
  1126. print("INP",self.data.entry.get())
  1127. if event.keycode == 36:
  1128. x=self.data.entry.get()
  1129. #client.send(x)
  1130. elif self.mode == "INPUT2":
  1131. print("INP2",self.data.entry2.get())
  1132. if event.keycode == 36:
  1133. x=self.data.entry2.get()
  1134. #client.send(x)
  1135. elif self.mode == "INPUT3":
  1136. print("INP3",self.data.entry3.get())
  1137. if event.keycode == 36:
  1138. x=self.data.entry3.get()
  1139. #client.send(x)
  1140. elif self.mode == "PRESET":
  1141. nr = self.attr #int(self.attr.split(":")[1])-1
  1142. if event.num == 1:
  1143. if str(event.type) == '4': #4 ButtonPress
  1144. if modes.val("REC"):
  1145. self.data.preset_rec(nr)
  1146. modes.val("REC",0)
  1147. elif modes.val("DEL"):
  1148. ok=PRESETS.delete(nr)
  1149. if ok:
  1150. modes.val("DEL",0)
  1151. master.refresh_exec()
  1152. elif modes.val("COPY"):
  1153. ok=PRESETS.copy(nr)
  1154. if ok:
  1155. modes.val("COPY",0)
  1156. master.refresh_exec()
  1157. elif modes.val("MOVE"):
  1158. ok=PRESETS.move(nr)
  1159. if ok:
  1160. #modes.val("MOVE",0) # keep MOVE on
  1161. master.refresh_exec()
  1162. elif modes.val("CFG-BTN"):
  1163. master.btn_cfg(nr)
  1164. elif modes.val("LABEL"):#else:
  1165. master.label(nr)
  1166. elif modes.val("EDIT"):
  1167. FIXTURES.clear()
  1168. self.data.preset_select(nr)
  1169. self.data.preset_go(nr,xfade=0,event=event,val=255,button="go")
  1170. modes.val("EDIT", 0)
  1171. master.refresh_fix()
  1172. elif modes.val("SELECT"):
  1173. self.data.preset_select(nr)
  1174. else:
  1175. self.data.preset_go(nr,event=event,val=255)
  1176. else:
  1177. self.data.preset_go(nr,xfade=0,event=event,val=0)
  1178. if event.num == 3:
  1179. if not modes.val("REC"):
  1180. self.data.preset_go(nr,xfade=0,ptfade=0,event=event,val=255)
  1181. return 0
  1182. elif self.mode == "INPUT":
  1183. return 0
  1184. except Exception as e:
  1185. cprint("== cb EXCEPT",e,color="red")
  1186. cprint("Error on line {}".format(sys.exc_info()[-1].tb_lineno),color="red")
  1187. cprint(''.join(traceback.format_exception(None, e, e.__traceback__)),color="red")
  1188. return 1
  1189. def wheel(event,d=None):
  1190. print("wheel",event,d)
  1191. import copy
  1192. class Element():
  1193. def __init__(self):
  1194. self.__data = {}
  1195. def set(self,key,val):
  1196. self.__data[key] = val
  1197. class Base():
  1198. def __init__(self):
  1199. cprint("Base.init()",color="red")
  1200. self._init()
  1201. def _init(self):
  1202. show_name = "DemoShow"
  1203. self.home = os.environ['HOME']
  1204. self.show_path0 = self.home +"/LibreLight/"
  1205. self.show_path = self.show_path0
  1206. self.show_path1 = self.show_path0 + "show/"
  1207. try:
  1208. f = open(self.show_path+"init.txt","r")
  1209. for line in f.readlines():
  1210. #cprint(line)
  1211. if not line.startswith("#"):
  1212. show_name = line.strip()
  1213. show_name = show_name.replace(".","")
  1214. show_name = show_name.replace("\\","")
  1215. show_name = show_name.replace("/","")
  1216. self.show_name = show_name
  1217. except Exception as e:
  1218. cprint("show name exception",color="red")
  1219. msg="Error Exception:{}".format(e)
  1220. r=tkinter.messagebox.showwarning(message=msg,parent=None)
  1221. finally:
  1222. f.close()
  1223. fpath = self.show_path1 +show_name
  1224. if not os.path.isdir(fpath):
  1225. cprint(fpath)
  1226. print( os.path.isdir(fpath))
  1227. msg="'{}'\n Show Does Not Exist\n\n".format(show_name)
  1228. msg += "please check\n"
  1229. msg += "-{}init.txt\n".format(self.show_path0)
  1230. msg += "-{}".format(self.show_path1)
  1231. showwarning(msg=msg,title="Show Error")
  1232. exit()
  1233. self._check()
  1234. def _set(self,fname):
  1235. ok= os.path.isdir(self.show_path1+"/"+fname)
  1236. ini = self.show_path0+"init.txt"
  1237. print("SET SHOW NAME",fname,ok,ini)
  1238. if ok:
  1239. #self.show_name = fname
  1240. f = open( ini ,"a")
  1241. f.write(fname+"\n")
  1242. f.close()
  1243. return 1
  1244. def _check(self):
  1245. if not os.path.isdir(self.show_path):
  1246. os.mkdir(self.show_path)
  1247. self.show_path += "/show/"
  1248. if not os.path.isdir(self.show_path):
  1249. os.mkdir(self.show_path)
  1250. self.show_path += "/" +self.show_name +"/"
  1251. if not os.path.isdir(self.show_path):
  1252. os.mkdir(self.show_path)
  1253. pass
  1254. def _list(self):
  1255. #self._check()
  1256. show_list = list(os.listdir( self.show_path1 ))
  1257. out = []
  1258. for fname in show_list:
  1259. #print(fname)
  1260. ctime = os.path.getmtime(self.show_path1+fname)
  1261. ctime = time.strftime("%Y-%m-%d %X", time.localtime(ctime)) #1650748726.6604707))
  1262. try:
  1263. mtime = os.path.getmtime(self.show_path1+fname+"/patch.sav")
  1264. mtime = time.strftime("%Y-%m-%d %X", time.localtime(mtime)) #1650748726.6604707))
  1265. except:
  1266. mtime = 0
  1267. if mtime:
  1268. out.append([fname,mtime])#,ctime])
  1269. from operator import itemgetter
  1270. out=sorted(out, key=itemgetter(1))
  1271. out.reverse()
  1272. return out
  1273. def _load(self,filename):
  1274. xfname = self.show_path+"/"+str(filename)+".sav"
  1275. print("load",xfname)
  1276. try:
  1277. f = open(xfname,"r")
  1278. lines = f.readlines()
  1279. f.close()
  1280. except Exception as e:
  1281. msg = "Exception: {}".format(e)
  1282. msg += "\n\ncheck\n-init.txt"
  1283. cprint(msg,color="red")
  1284. showwarning(msg=msg,title="load Error")
  1285. data = OrderedDict()
  1286. labels = OrderedDict()
  1287. i=0
  1288. for line in lines:
  1289. if line.count("\t") < 2:
  1290. cprint("Error line.count('\\t') < 2 (is:{})".format(line.count("\t")),color="red",end=" ")
  1291. cprint("file:{}".format(xfname),color="red")
  1292. continue
  1293. key,label,rdata = line.split("\t",2)
  1294. key = int(key)
  1295. jdata = json.loads(rdata,object_pairs_hook=OrderedDict)
  1296. nrnull = 0
  1297. if "ATTRIBUT" in jdata: # translate old FIXTURES.fixtures start with 0 to 1
  1298. if nrnull:
  1299. print("DMX NR IS NULL",attr,"CHANGE +1")
  1300. for attr in jdata["ATTRIBUT"]:
  1301. if "NR" in jdata["ATTRIBUT"][attr]:
  1302. nr = jdata["ATTRIBUT"][attr]["NR"]
  1303. if nr >= 0:
  1304. jdata["ATTRIBUT"][attr]["NR"] +=1
  1305. data[key] = jdata
  1306. labels[key] = label
  1307. return data,labels
  1308. def _clean_path(self,fpath):
  1309. _path=[]
  1310. for i in fpath:
  1311. fpath = fpath.replace(" ","_")
  1312. if i in string.ascii_letters+string.digits+"äöüßÖÄÜ_-":
  1313. _path.append(i)
  1314. path = "".join(_path)
  1315. return path
  1316. def build_path(self,save_as):
  1317. save_as = self._clean_path(save_as)
  1318. path = self.show_path.split("/")
  1319. path = "/".join(path[:-2])
  1320. fpath = path+"/"+save_as
  1321. return fpath,save_as
  1322. def _create_path(self,fpath):
  1323. if os.path.isdir(fpath):
  1324. cprint("STOP SHOW EXIST !",color="red")
  1325. return 0
  1326. else:
  1327. cprint("CREATE DIR ",fpath,color="green")
  1328. os.mkdir(fpath)
  1329. #self._set(save_as)
  1330. return fpath
  1331. def _backup(self,filename,data,labels,save_as):
  1332. if save_as:
  1333. xfname = save_as +"/"+str(filename)+".sav"
  1334. else:
  1335. xfname = self.show_path+"/"+str(filename)+".sav"
  1336. print("backup",xfname)
  1337. f = open(xfname,"w")
  1338. for key in data:
  1339. line = data[key]
  1340. #print(line)
  1341. label = "label"
  1342. if key in labels:
  1343. label = labels[key]
  1344. if label == "Name-"+str(key):
  1345. label = ""
  1346. #print(xfname,"load",key,label,len(line))
  1347. f.write( "{}\t{}\t{}\n".format( key,label,json.dumps(line) ) )
  1348. f.close()
  1349. return 1
  1350. class Event():
  1351. def __init__(self,name):
  1352. self.name=name
  1353. #print("init",self)
  1354. def event(self,event):
  1355. print(self.name,event)
  1356. class scroll():
  1357. def __init__(self,canvas):
  1358. self.canvas=canvas
  1359. def config(self,event):
  1360. canvas = self.canvas
  1361. canvas.configure(scrollregion=canvas.bbox("all"))#,width=400,height=200)
  1362. def hex_to_rgb(hex):
  1363. return tuple(int(hex[i:i+2], 16) for i in (0, 2, 4))
  1364. class cb():
  1365. def __init__(self,win):
  1366. self.win = win
  1367. def _callback(self,event):
  1368. clobj=event.widget
  1369. ## undermouse=find_withtag(master.CURRENT)
  1370. undermouse=self.win.find_closest(self.win.CURRENT)
  1371. print( repr(undermouse))
  1372. def callback(self,event):
  1373. print(__file__,self,"callback",event)
  1374. cnv = self.win
  1375. item = cnv.find_closest(cnv.canvasx(event.x), cnv.canvasy(event.y))[0]
  1376. tags = cnv.gettags(item)
  1377. #cnv.itemconfigure(self.tag, text=tags[0])
  1378. print(tags,item)
  1379. color = cnv.itemcget(item, "fill")
  1380. cnv.itemconfig("all", width=1)#filla="green")
  1381. cnv.itemconfig(item, width=3)#filla="green")
  1382. print(color)
  1383. print( hex_to_rgb(color[1:]))
  1384. class MiniButton:
  1385. def __init__(self,root,width=72,height=38,text="button"):
  1386. self.text=text
  1387. self.rb = tk.Frame(root, highlightbackground = "lightgrey", highlightthickness = 1, bd=0)
  1388. self.bb = tk.Canvas(self.rb, highlightbackground = "black", highlightthickness = 1, bd=1,relief=tk.RAISED)
  1389. self.bb.configure(width=width, height=height)
  1390. self.fg = "#002"
  1391. self.label = []
  1392. self.bind("<Enter>", self.on_enter)
  1393. self.bind("<Leave>", self.on_leave)
  1394. # !! BLOCK's other bindings like GO
  1395. #self.bind("<Button-1>", self.on_b1)
  1396. #self.bind("<ButtonPress>", self.on_press)
  1397. #self.bind("<ButtonRelease>", self.on_release)
  1398. #self.bind("<ButtonRelease-1>", self.on_release)
  1399. self.activebackground="lightgrey"
  1400. self.defaultBackground="grey"
  1401. def on_b1(self, e):
  1402. print("on_b1",e)
  1403. #self.bb.config(background=self.activebackground)
  1404. self.bb.config(relief=tk.SUNKEN)#abackground=self.activebackground)
  1405. return 1
  1406. def on_press(self, e):
  1407. print("on_press",e)
  1408. #self.bb.config(background=self.activebackground)
  1409. self.bb.config(relief=tk.SUNKEN)#abackground=self.activebackground)
  1410. return 1
  1411. def on_release(self, e):
  1412. print("on_release",e)
  1413. #self.bb.config(background=self.activebackground)
  1414. self.bb.config(relief=tk.RAISED)#abackground=self.activebackground)
  1415. return 1
  1416. def on_enter(self, e):
  1417. #print("on_enter",e)
  1418. #self.bb.config(background=self.activebackground)
  1419. self.bb.config(relief=tk.FLAT)#abackground=self.activebackground)
  1420. return 1
  1421. def on_leave(self, e):
  1422. #print("on_leave",e)
  1423. self.bb.config(background=self.defaultBackground)
  1424. self.bb.config(relief=tk.RAISED)#abackground=self.activebackground)
  1425. return 1
  1426. def _label(self,text="1\n2\n3\n"):
  1427. z = 0
  1428. self.bb.delete("label")
  1429. self.label = []
  1430. for t in text.split("\n"):
  1431. self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label")
  1432. #self.l["color"] = self.fg
  1433. self.label.append(self.l)
  1434. z+=1
  1435. def _configure(self,**args):
  1436. if "text" in args:
  1437. self.text = args["text"]
  1438. self._label(self.text)
  1439. if "bg" in args:
  1440. #print(dir(self.bb))
  1441. self.bb.configure(bg=args["bg"])
  1442. self.defaultBackground=args["bg"]
  1443. if "fg" in args:
  1444. #print(dir(self.bb))
  1445. self.fg=args["fg"]
  1446. #if len(self.label):
  1447. # self.label[0].configure(color="red") #args["fg"])
  1448. #self.defaultBackground=args["fg"]
  1449. def configure(self,**args):
  1450. self._configure(**args)
  1451. def config(self,**args):
  1452. self._configure(**args)
  1453. def bind(self,etype="<Button>",cb=None):
  1454. #bb.bind("<ButtonRelease>",Xevent(fix=0,elem=b,attr=k,data=self,mode="PRESET").cb)
  1455. if cb:
  1456. self.bb.bind(etype,cb)
  1457. def grid(self,row=0, column=0, sticky=""):
  1458. self.bb.pack() #(row=row, column=column, sticky=sticky)
  1459. self.rb.grid(row=row, column=column, sticky=sticky)
  1460. class ExecButton(MiniButton):
  1461. def __init__(self,root,width=72,height=38,text="button"):
  1462. super().__init__(root,width,height,text)
  1463. self.text = "1\n2\n3\n"
  1464. self.x9font = tk.font.Font(family="FreeSans", size=9, weight="bold")
  1465. self.x8font = tk.font.Font(family="FreeSans", size=8, weight="bold")
  1466. self.x7font = tk.font.Font(family="FreeSans", size=7, weight="bold")
  1467. self.x6font = tk.font.Font(family="FreeSans", size=6, weight="bold")
  1468. self.x5font = tk.font.Font(family="FreeSans", size=5, weight="bold")
  1469. def config(self,**args):
  1470. self._configure(**args)
  1471. self._label()
  1472. def configure(self,**args):
  1473. self._configure(**args)
  1474. self._label()
  1475. def _label(self,text=None):
  1476. if type(text) is str:
  1477. self.text = text
  1478. else:
  1479. text = self.text
  1480. self.bb.delete("label")
  1481. txt2 = text
  1482. try:
  1483. text = text.split("\n")[1]
  1484. except:pass
  1485. if "grün" in text.lower() or "green" in text.lower():
  1486. self.l = self.bb.create_rectangle(10,27,20,37,fill="green",tag="label")
  1487. elif "blau" in text.lower() or "blue" in text.lower():
  1488. self.l = self.bb.create_rectangle(10,27,20,37,fill="blue",tag="label")
  1489. elif "rot" in text.lower() or "red" in text.lower():
  1490. self.l = self.bb.create_rectangle(10,27,20,37,fill="red",tag="label")
  1491. elif "orange" in text.lower():# or "yellow" in text.lower():
  1492. self.l = self.bb.create_rectangle(10,27,20,37,fill="orange",tag="label")
  1493. elif "weiß" in text.lower() or "white" in text.lower():
  1494. self.l = self.bb.create_rectangle(10,27,20,37,fill="white",tag="label")
  1495. elif "cyan" in text.lower():# or "yellow" in text.lower():
  1496. self.l = self.bb.create_rectangle(10,27,20,37,fill="cyan",tag="label")
  1497. elif "gelb" in text.lower() or "yellow" in text.lower():
  1498. self.l = self.bb.create_rectangle(10,27,20,37,fill="yellow",tag="label")
  1499. elif "mage" in text.lower() or "mage" in text.lower():
  1500. self.l = self.bb.create_rectangle(10,27,20,37,fill="magenta",tag="label")
  1501. if "nebel" in text.lower() or "smoke" in text.lower() or "haze" in text.lower():
  1502. self.l = self.bb.create_rectangle(10,27,60,37,fill="white",tag="label")
  1503. if "mh " in text.lower() or " mh" in text.lower() :
  1504. self.l = self.bb.create_rectangle(30,27,35,32,fill="black",tag="label")
  1505. self.l = self.bb.create_rectangle(28,34,37,37,fill="black",tag="label")
  1506. if "off" in text.lower():
  1507. self.l = self.bb.create_rectangle(50,30,55,35,fill="black",tag="label")
  1508. if "dim" in text.lower() or "front" in text.lower() or "on" in text.lower():
  1509. #self.l = self.bb.create_line(56,30,60,28,fill="black",tag="label")
  1510. self.l = self.bb.create_rectangle(50,30,55,35,fill="white",tag="label")
  1511. #self.l = self.bb.create_line(56,36,58,36,fill="black",tag="label")
  1512. if "circle" in text.lower():
  1513. self.l = self.bb.create_oval(30,27,40,37,fill="",tag="label")
  1514. if "pan" in text.lower():
  1515. self.l = self.bb.create_line(20,34 ,45,34,fill="black",arrow=tk.BOTH,tag="label")
  1516. if "tilt" in text.lower():
  1517. self.l = self.bb.create_line(30,25 ,30,43,fill="black",arrow=tk.BOTH,tag="label")
  1518. text = txt2
  1519. z = 0
  1520. for t in text.split("\n"):
  1521. ts = 10
  1522. _max = 7
  1523. if z==1 and len(t) >= _max:
  1524. ts = int(10 - (len(t)-_max)/1.5)
  1525. if ts < 5:
  1526. ts = 5
  1527. xfont = self.x9font
  1528. if 1:
  1529. if ts == 9:
  1530. xfont = self.x9font
  1531. elif ts == 8:
  1532. xfont = self.x8font
  1533. elif ts == 7:
  1534. xfont = self.x7font
  1535. elif ts == 6:
  1536. xfont = self.x6font
  1537. elif ts == 5:
  1538. xfont = self.x5font
  1539. #self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label",fill=self.fg,font=xfont)
  1540. self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label",fill=self.fg)
  1541. else:
  1542. self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label",fill=self.fg)
  1543. z+=1
  1544. class Elem_Container():
  1545. def __init__(self):
  1546. self.commands = []
  1547. self.val = {}
  1548. self.elem = {}
  1549. class GUI():
  1550. def __init__(self):
  1551. #super().__init__()
  1552. self.base = Base ()
  1553. self.load()
  1554. self._XX = 0
  1555. self.all_attr =["DIM","PAN","TILT"]
  1556. self.elem_attr = {}
  1557. self.fx_moves = Elem_Container()
  1558. self.fx_moves.commands =["REC-FX","FX OFF","\n"
  1559. ,"FX:CIR","FX:PAN","FX:TILT", "WIDTH:\n100","DIR:\n0","INVERT:\n0","\n",
  1560. "SHUFFLE:\n0","SIZE:\n","SPEED:\n","START:\n","OFFSET:\n","\n"
  1561. ]
  1562. #, "FX:SIN","FX:COS","FX:RAMP","FX:RAMP2","FX:FD","FX:ON","BASE:\n-"] #,"FX:RND" ]
  1563. self.fx = Elem_Container()
  1564. self.fx.commands =[
  1565. "FX:DIM","FX:RED", "WIDTH:\n25","WING:\n2","DIR:\n1","INVERT:\n1","\n","SHUFFLE:\n0"
  1566. ,"SIZE:\n","SPEED:\n","START:\n","OFFSET:\n","BASE:\n-"
  1567. ]
  1568. self.fx_generic = Elem_Container()
  1569. self.fx_generic.commands =["FX:SIN","FX:COS","FX:RAMP","FX:RAMP2","FX:FD","FX:ON"]
  1570. self.commands = Elem_Container()
  1571. self.commands.commands =["\n","ESC","CFG-BTN","LABEL","-","DEL","\n"
  1572. ,"SELECT","FLASH","GO","-","MOVE","\n"
  1573. ,"BLIND","CLEAR","REC","EDIT","COPY","\n"
  1574. ]
  1575. self.elem_presets = {}
  1576. for i in range(8*8*8):
  1577. if i not in PRESETS.val_presets:
  1578. name = "Preset:"+str(i+1)+":\nXYZ"
  1579. #self.presets[i] = [i]
  1580. PRESETS.val_presets[i] = OrderedDict() # FIX
  1581. PRESETS.val_presets[i]["CFG"] = OrderedDict() # CONFIG
  1582. PRESETS.label_presets[i] = "-"
  1583. modes.set_cb(self.xcb)
  1584. def button_refresh(self,name,color,color2=None,text="",fg=None):
  1585. cprint("button_refresh",name,color)
  1586. #if color == "gold":
  1587. # color2 = "yellow"
  1588. if color2 is None:
  1589. color2 = color
  1590. if text:
  1591. text = "\n"+str(text)
  1592. if name in self.commands.elem:
  1593. self.commands.elem[name]["bg"] = color
  1594. self.commands.elem[name]["text"] = name+ text
  1595. self.commands.elem[name].config(activebackground=color2)
  1596. if fg:
  1597. self.commands.elem[name]["fg"] = fg
  1598. elif name in self.fx.elem:
  1599. #todo
  1600. self.fx.elem[name]["bg"] = color
  1601. self.fx.elem[name].config(activebackground=color2)
  1602. if fg:
  1603. self.fx.elem[name]["fg"] = fg
  1604. # new version
  1605. for elems in [self.fx_moves]:
  1606. if name in elems.elem:
  1607. elem = elems.elem[name]
  1608. cprint("elem",elem)
  1609. elem.config(bg = color)
  1610. elem.config(text = name+text)
  1611. elem.config(activebackground=color2)
  1612. if fg and "fg" in elem:
  1613. elem["fg"] = fg
  1614. def btn_cfg(self,nr):
  1615. txt = PRESETS.btn_cfg(nr)
  1616. txt = tkinter.simpledialog.askstring("CFG-BTN","GO=GO FL=FLASH\nSEL=SELECT EXE:"+str(nr+1),initialvalue=txt)
  1617. if txt:
  1618. PRESETS.btn_cfg(nr,txt)
  1619. self.elem_presets[nr].configure(text= PRESETS.get_btn_txt(nr))
  1620. modes.val("CFG-BTN",0)
  1621. master._refresh_exec()
  1622. def label(self,nr):
  1623. txt = PRESETS.label(nr)
  1624. txt = tkinter.simpledialog.askstring("LABEL","EXE:"+str(nr+1),initialvalue=txt)
  1625. if txt:
  1626. PRESETS.label(nr,txt)
  1627. self.elem_presets[nr].configure(text = PRESETS.get_btn_txt(nr))
  1628. modes.val("LABEL", 0)
  1629. master._refresh_exec()
  1630. def xcb(self,mode,value=None):
  1631. cprint("MODE CALLBACK",mode,value,color="green",end="")
  1632. #cprint(self,"xcb","MODE CALLBACK",mode,value,color="green")
  1633. if value:
  1634. cprint("===== ON ======",color="red")
  1635. txt = ""
  1636. if mode == "REC-FX":
  1637. modes.val("REC",1)
  1638. if value == 2:
  1639. if mode in ["MOVE","COPY"]:
  1640. txt="to"
  1641. self.button_refresh(mode,color="orange",text=txt)#,fg="blue")
  1642. else:
  1643. if mode in ["MOVE","COPY"]:
  1644. txt="from"
  1645. self.button_refresh(mode,color="red",text=txt)#,fg="blue",text="from")
  1646. else:
  1647. cprint("===== OFF ======",color="red")
  1648. if mode == "REC-FX":
  1649. modes.val("REC",0)
  1650. self.button_refresh(mode,color="lightgrey")#,fg="black")
  1651. def load(self,fname=""):
  1652. pass
  1653. def exit(self):
  1654. print("__del__",self)
  1655. PRESETS.backup_presets()
  1656. #print("********************************************************")
  1657. FIXTURES.backup_patch()
  1658. #print("*********del",self,"***********************************************")
  1659. def refresh_exec(self):
  1660. refresher.reset() # = Refresher()
  1661. def _refresh_exec(self):
  1662. cprint("PRESET.refresh_exec()")
  1663. self._XX +=1
  1664. for k in PRESETS.val_presets:
  1665. label = ""
  1666. if k not in self.elem_presets:
  1667. cprint("ERROR",k ,"not in elem_presets continue")
  1668. continue
  1669. if k in PRESETS.label_presets:
  1670. label = PRESETS.label_presets[k]
  1671. #print([label])
  1672. b = self.elem_presets[k]
  1673. ifval = 0
  1674. fx_only = 0
  1675. if k in PRESETS.val_presets and len(PRESETS.val_presets[k]) :
  1676. sdata = PRESETS.val_presets[k]
  1677. #print("sdata7654",sdata)
  1678. BTN="go"
  1679. if "CFG" in sdata:#["BUTTON"] = "GO"
  1680. if "BUTTON" in sdata["CFG"]:
  1681. BTN = sdata["CFG"]["BUTTON"]
  1682. #txt=str(k+1)+" "+str(BTN)+" "+str(len(sdata)-1)+"\n"+label
  1683. txt="{} {} {}\n{}".format(k+1,BTN,len(sdata)-1,label)
  1684. #txt+=str(self._XX)
  1685. b.configure(text= txt)
  1686. b.configure(bg="yellow")
  1687. b.config(activebackground="yellow")
  1688. if len(sdata) > 1:
  1689. ifval = 1
  1690. fx_color = 0
  1691. val_color = 0
  1692. for fix in sdata:
  1693. if fix == "CFG":
  1694. continue
  1695. #print( "$$$$",fix,sdata[fix])
  1696. for attr in sdata[fix]:
  1697. if "FX2" in sdata[fix][attr]:
  1698. if sdata[fix][attr]["FX2"]:
  1699. fx_color = 1
  1700. if "FX" in sdata[fix][attr]:
  1701. if sdata[fix][attr]["FX"]:
  1702. fx_color = 1
  1703. if "VALUE" in sdata[fix][attr]:
  1704. if sdata[fix][attr]["VALUE"] is not None:
  1705. val_color = 1
  1706. b.configure(fg= "black")
  1707. if val_color:
  1708. b.configure(bg="gold")
  1709. b.config(activebackground="#ffaa55")
  1710. if fx_color:
  1711. b.configure(fg = "blue")
  1712. else:
  1713. if fx_color:
  1714. fx_only = 1
  1715. else:
  1716. b.configure(bg="grey")
  1717. b.config(activebackground="#aaa")
  1718. if "\n" in txt:
  1719. txt1 = txt.split("\n")[0]
  1720. if ifval:
  1721. if fx_only:
  1722. b.configure(bg = "cyan")
  1723. b.config(activebackground="#55d4ff")
  1724. if "SEL" in txt1:
  1725. b.configure(fg="black")
  1726. b.configure(bg="#77f")
  1727. #b.config(activebackground="#fff")
  1728. elif "ON" in txt1:
  1729. b.configure(fg="#040")
  1730. #b.configure(bg="#cca")
  1731. elif "GO" in txt1:
  1732. b.configure(fg="black")
  1733. elif "FL" in txt1:
  1734. #b.configure(fg="#7f00ff")
  1735. b.configure(fg="#00e")
  1736. #b.configure(bg="#f0a000")
  1737. else:
  1738. b.configure(bg="grey")
  1739. b.configure(fg="black")
  1740. def refresh_fix(self):
  1741. refresher.reset() # = Refresher()
  1742. def _refresh_fix(self):
  1743. c_d =0
  1744. c_f =0
  1745. c_a =0
  1746. for fix in FIXTURES.fixtures:
  1747. sdata = FIXTURES.fixtures[fix]
  1748. _c_a = 0
  1749. for attr in sdata["ATTRIBUT"]:
  1750. if "FINE" in attr:
  1751. continue
  1752. v2 = sdata["ATTRIBUT"][attr]["VALUE"]
  1753. if fix in self.elem_attr:
  1754. elem = self.elem_attr[fix][attr]
  1755. #print( attr,v2)
  1756. elem["text"] = "{} {:0.2f}".format(attr,v2)
  1757. if sdata["ATTRIBUT"][attr]["ACTIVE"]:
  1758. elem["bg"] = "yellow"
  1759. elem.config(activebackground="yellow")
  1760. if "DIM" in sdata["ATTRIBUT"] and len(sdata["ATTRIBUT"]) == 1:
  1761. c_d+=1
  1762. else:
  1763. _c_a += 1
  1764. else:
  1765. elem["bg"] = "grey"
  1766. elem.config(activebackground="grey")
  1767. if "FX2" not in sdata["ATTRIBUT"][attr]: # insert FX2 excetption
  1768. sdata["ATTRIBUT"][attr]["FX2"] = OrderedDict()
  1769. if sdata["ATTRIBUT"][attr]["FX"]:
  1770. elem["fg"] = "blue"
  1771. elif sdata["ATTRIBUT"][attr]["FX2"]:
  1772. elem["fg"] = "red"
  1773. else:
  1774. elem["fg"] = "black"
  1775. c_a += _c_a
  1776. if _c_a>0:
  1777. c_f +=1
  1778. c_a2=0
  1779. if c_f > 0:
  1780. c_a2 = round(c_a/c_f,2)
  1781. if c_a2 % 1 > 0:
  1782. gui_menu.config("FIXTURES","bg","orange")
  1783. gui_menu.config("FIXTURES","activebackground","orange")
  1784. else:
  1785. gui_menu.config("FIXTURES","bg","yellow")
  1786. gui_menu.config("FIXTURES","activebackground","yellow")
  1787. else:
  1788. gui_menu.config("FIXTURES","bg","")
  1789. gui_menu.config("FIXTURES","activebackground","")
  1790. gui_menu.update("FIXTURES","{} : {}".format(c_f,c_a2))
  1791. if c_d > 0:
  1792. gui_menu.config("DIMMER","bg","yellow")
  1793. gui_menu.config("DIMMER","activebackground","yellow")
  1794. else:
  1795. gui_menu.config("DIMMER","bg","")
  1796. gui_menu.config("DIMMER","activebackground","")
  1797. gui_menu.update("DIMMER","{}".format(c_d))
  1798. def preset_rec(self,nr):
  1799. print("------- STORE PRESET")
  1800. data = FIXTURES.get_active()
  1801. if modes.val("REC-FX"):
  1802. PRESETS.rec(nr,data,"REC-FX")
  1803. modes.val("REC-FX",0)
  1804. else:
  1805. PRESETS.rec(nr,data)
  1806. sdata=data
  1807. PRESETS.val_presets[nr] = sdata
  1808. master._refresh_exec()
  1809. return 1
  1810. def preset_select(self,nr):
  1811. print("SELECT PRESET")
  1812. sdata = PRESETS.val_presets[nr]
  1813. cmd = ""
  1814. for fix in sdata:
  1815. if fix == "CFG":
  1816. continue
  1817. for attr in sdata[fix]:
  1818. v2 = sdata[fix][attr]["VALUE"]
  1819. v2_fx = sdata[fix][attr]["FX"]
  1820. #print( self.data.elem_attr)
  1821. if fix in self.elem_attr:
  1822. if attr in self.elem_attr[fix]:
  1823. elem = self.elem_attr[fix][attr]
  1824. FIXTURES.fixtures[fix]["ATTRIBUT"][attr]["ACTIVE"] = 1
  1825. elem["bg"] = "yellow"
  1826. def preset_go(self,nr,val=None,xfade=None,event=None,button="",ptfade=None):
  1827. t_start = time.time()
  1828. if xfade is None and FADE._is():
  1829. xfade = FADE.val()
  1830. if ptfade is None and FADE_move._is():
  1831. ptfade = FADE_move.val()
  1832. print("GO PRESET FADE",nr,val)
  1833. rdata = PRESETS.get_raw_map(nr)
  1834. if not rdata:
  1835. return 0
  1836. print("???????")
  1837. cfg = PRESETS.get_cfg(nr)
  1838. print("''''''''")
  1839. #virtcmd = FIXTURES.get_virtual(rdata)
  1840. if not cfg:
  1841. cprint("NO CFG",cfg,nr)
  1842. return 0
  1843. xFLASH = 0
  1844. value=None
  1845. cprint("preset_go",nr,cfg)
  1846. if modes.val("SELECT") or ( "BUTTON" in cfg and cfg["BUTTON"] == "SEL") and val and not button: #FLASH
  1847. self.preset_select(nr)
  1848. elif modes.val("FLASH") or ( "BUTTON" in cfg and cfg["BUTTON"] == "FL") and not button: #FLASH
  1849. xFLASH = 1
  1850. xfade = 0
  1851. if type(val) is not type(None) and val == 0 :
  1852. value = "off"
  1853. if event:
  1854. if str(event.type) == "ButtonRelease" or event.type == '5' :
  1855. value = "off"
  1856. cprint("preset_go() FLUSH",value,color="red")
  1857. fcmd = FIXTURES.update_raw(rdata,update=0)
  1858. self._preset_go(rdata,cfg,fcmd,value,xfade=xfade,xFLASH=xFLASH)
  1859. elif not val:
  1860. cprint("preset_go() STOP",value,color="red")
  1861. elif button == "on" or ( modes.val("ON") or ( "BUTTON" in cfg and cfg["BUTTON"] in ["on","ON"])):
  1862. fcmd = FIXTURES.update_raw(rdata)
  1863. self._preset_go(rdata,cfg,fcmd,value,xfade=0,xFLASH=xFLASH)
  1864. elif button == "go" or ( modes.val("GO") or ( "BUTTON" in cfg and cfg["BUTTON"] in ["go","GO"])):
  1865. fcmd = FIXTURES.update_raw(rdata)
  1866. self._preset_go(rdata,cfg,fcmd,value,xfade=xfade,xFLASH=xFLASH,ptfade=ptfade,nr=nr)
  1867. if not (modes.val("FLASH") or ( "BUTTON" in cfg and cfg["BUTTON"] == "FL")): #FLASH
  1868. self.refresh_exec()
  1869. self.refresh_fix()
  1870. cprint("preset_go",time.time()-t_start)
  1871. def _preset_go(self,rdata,cfg,fcmd,value=None,xfade=None,event=None,xFLASH=0,ptfade=0,nr=None):
  1872. if xfade is None and FADE._is():
  1873. xfade = FADE.val()
  1874. if ptfade is None and FADE_move._is():
  1875. ptfade = FADE_move.val()
  1876. cprint("PRESETS._preset_go() len=",len(rdata),cfg)
  1877. if xfade is None:
  1878. xfade = cfg["FADE"]
  1879. if ptfade is None:
  1880. ptfade = cfg["FADE"]
  1881. #vcmd = reshape_preset( rdata ,value,[],xfade=xfade,fx=1)
  1882. #cprint(rdata,color="red")
  1883. vcmd = reshape_preset( rdata ,value,xfade=xfade,ptfade=ptfade)
  1884. cmd = []
  1885. delay=0
  1886. for i,v in enumerate(fcmd):
  1887. #print("go",i,v)
  1888. if xFLASH:
  1889. vcmd[i]["FLASH"] = 1
  1890. DMX = fcmd[i]["DMX"]
  1891. if "VALUE" in vcmd[i] and type(vcmd[i]["VALUE"]) is type(float):
  1892. vcmd[i]["VALUE"] = round(vcmd[i]["VALUE"],3)
  1893. if value is not None:
  1894. vcmd[i]["VALUE"] = value
  1895. if value == "off":
  1896. if "FX2" in vcmd:
  1897. vcmd[i]["FX2"]["TYPE"] = value
  1898. if DMX and vcmd[i]:
  1899. vcmd[i]["DMX"] = DMX
  1900. if "VIRTUAL" in fcmd[i]:
  1901. for a in fcmd[i]["VIRTUAL"]:
  1902. DMX = fcmd[i]["VIRTUAL"][a]
  1903. if DMX and vcmd[i]:
  1904. vcmd[i]["DMX"] = DMX
  1905. if type(nr) is not type(None):
  1906. vcmd[i]["EXEC"] = str(int(nr)+1)
  1907. #cprint(vcmd[i],color="red")
  1908. cmd.append(vcmd[i])
  1909. if cmd and not modes.val("BLIND"):
  1910. jclient_send(cmd)
  1911. def render(self):
  1912. #Xroot.bind("<Key>",Xevent(fix=0,elem=None,attr="ROOT",data=self,mode="ROOT").cb)
  1913. #self.draw_input()
  1914. pass
  1915. def draw_sub_dim(gui,fix,data,c=0,r=0,frame=None):
  1916. i=0
  1917. if frame is None:
  1918. frame = tk.Frame(root,bg="black")
  1919. frame.pack(fill=tk.X, side=tk.TOP)
  1920. if fix not in gui.elem_attr:
  1921. gui.elem_attr[fix] = {}
  1922. for attr in data["ATTRIBUT"]:
  1923. if attr not in gui.all_attr:
  1924. gui.all_attr.append(attr)
  1925. if attr not in gui.elem_attr[fix]:
  1926. gui.elem_attr[fix][attr] = []
  1927. if attr.endswith("-FINE"):
  1928. continue
  1929. v= data["ATTRIBUT"][attr]["VALUE"]
  1930. b = tk.Button(frame,bg="lightblue", text=""+str(fix),width=3,anchor="w")
  1931. b.config(padx=1)
  1932. b.bind("<Button>",Xevent(fix=fix,mode="D-SELECT",elem=b).cb)
  1933. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  1934. c+=1
  1935. b = tk.Button(frame,bg="lightblue", text=data["NAME"],width=10,anchor="w")
  1936. b.config(padx=1)
  1937. b.bind("<Button>",Xevent(fix=fix,mode="D-SELECT",elem=b).cb)
  1938. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  1939. c+=1
  1940. b = tk.Button(frame,bg="grey", text=str(round(v,2)),width=10,anchor="w")
  1941. b.config(padx=1)
  1942. gui.elem_attr[fix][attr] = b
  1943. b.bind("<Button>",Xevent(fix=fix,elem=b,attr=attr,mode="ENCODER",data=data).cb)
  1944. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  1945. c+=1
  1946. if c >=12:
  1947. c=0
  1948. r+=1
  1949. return c,r
  1950. class _SET_PATCH():
  1951. def __init__(self,k,v,fix,data,_cb=None):
  1952. self._cb = _cb
  1953. self.v = v
  1954. self.button = None
  1955. self.k = k
  1956. self.fix = fix
  1957. self.data = data
  1958. def attr(self,_event=None):
  1959. k = self.k
  1960. data = self.data
  1961. fix = self.fix
  1962. txt = "k={} v={}".format(self.k,self.v)
  1963. print(txt)
  1964. print( "fix", self.fix )
  1965. print( "row data",self.data)
  1966. val = ""
  1967. if k in self.data:
  1968. val = self.data[k]
  1969. txt = tkinter.simpledialog.askstring("SET","SET: {}={}".format(self.k,self.v),initialvalue=val)
  1970. print("_SET.attr",txt)
  1971. v = txt
  1972. if v is not None:
  1973. err = 1
  1974. if k in self.data:
  1975. if k == "NAME":
  1976. self.data[k] = v
  1977. err = 0
  1978. if k == "DMX":
  1979. v = int(v)
  1980. if v <= 512 and v >= 0:
  1981. self.data[k] = v
  1982. err = 0
  1983. if k == "UNIVERS":
  1984. v = int(v)
  1985. if v > 15:
  1986. v=15
  1987. if v < 0:
  1988. v=0
  1989. self.data[k] = v
  1990. err = 0
  1991. if self.button:
  1992. if err:
  1993. self.button["bg"] = "red"
  1994. else:
  1995. self.button["bg"] = "#fff"
  1996. self.button["text"] = "{}".format(v)
  1997. if self._cb:
  1998. self._cb()
  1999. print( "row data",self.data)
  2000. def set_button(self,button):
  2001. self.button = button
  2002. class GUI_PATCH():
  2003. def __init__(self,gui,yframe):
  2004. self.gui = gui
  2005. self.yframe = yframe
  2006. def draw(self): #,gui,yframe):
  2007. gui = self.gui
  2008. yframe = self.yframe
  2009. #print(dir(yframe))
  2010. #yframe.clear()
  2011. for widget in yframe.winfo_children():
  2012. widget.destroy()
  2013. xframe = tk.Frame(yframe,bg="black")
  2014. xframe.pack()
  2015. def yview(event):
  2016. print("yevent",event)
  2017. yyy=20.1
  2018. xframe.yview_moveto(yyy)
  2019. i=0
  2020. c=0
  2021. r=0
  2022. b = tk.Button(xframe,bg="lightblue", text="ID",width=6,anchor="e")
  2023. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2024. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2025. c+=1
  2026. b = tk.Button(xframe,bg="lightblue", text="NAME",width=14,anchor="w")
  2027. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2028. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2029. c+=1
  2030. b = tk.Button(xframe,bg="#ddd", text="TYPE",width=3)
  2031. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2032. c+=1
  2033. b = tk.Button(xframe,bg="#ddd", text="Uni",width=1)
  2034. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2035. c+=1
  2036. b = tk.Button(xframe,bg="#ddd", text="DMX",width=1)
  2037. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2038. c+=1
  2039. b = tk.Button(xframe,bg="#ddd", text="CH's",width=1)
  2040. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2041. c+=1
  2042. b = tk.Button(xframe,bg="#ddd", text="from - to",width=1)
  2043. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2044. c+=1
  2045. b = tk.Button(xframe,bg="#ddd", text="DMX-SUM",width=1)
  2046. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2047. c+=1
  2048. b = tk.Button(xframe,bg="#ddd", text="DMX Collision!",width=12)
  2049. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2050. c+=1
  2051. c=0
  2052. r+=1
  2053. dmx_ch_sum = 0
  2054. dmx_collision = {}
  2055. for fix in FIXTURES.fixtures:
  2056. data = FIXTURES.fixtures[fix]
  2057. max_dmx = FIXTURES.get_max_dmx_nr(fix)
  2058. for i in range(data["DMX"],data["DMX"]+max_dmx[1]):
  2059. k = "{}.{}".format(data["UNIVERS"],i)
  2060. if k in dmx_collision:
  2061. dmx_collision[k] += 1
  2062. else:
  2063. dmx_collision[k] = 0
  2064. z=0
  2065. for fix in FIXTURES.fixtures:
  2066. z+=1
  2067. collision = []
  2068. i+=1
  2069. data = FIXTURES.fixtures[fix]
  2070. b = tk.Button(xframe,bg="lightblue", text=""+str(fix),width=6,anchor="e")
  2071. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2072. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2073. c+=1
  2074. command = _SET_PATCH("NAME",data["NAME"],fix,data)
  2075. b = tk.Button(xframe,bg="lightblue", text=data["NAME"],width=14,anchor="w",command=command.attr)
  2076. command.set_button(b)
  2077. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2078. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2079. c+=1
  2080. if len(data["ATTRIBUT"]) == 1:
  2081. b = tk.Button(xframe,bg="#ddd", text="DIMMER",width=8,anchor="w")
  2082. elif "PAN" in data["ATTRIBUT"] or "TILT" in data["ATTRIBUT"] :
  2083. b = tk.Button(xframe,bg="#ddd", text="MOVER",width=8,anchor="w")
  2084. else:
  2085. b = tk.Button(xframe,bg="#ddd", text="",width=8,anchor="w")
  2086. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2087. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2088. c+=1
  2089. b = tk.Button(xframe,bg="#ddd", text="EDIT",width=3)
  2090. b.bind("<Button>",Xevent(fix=fix,mode="SELECT",elem=b).cb)
  2091. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2092. c+=1
  2093. b = tk.Button(xframe,bg="#ddd", text="[ ][x]",width=1)
  2094. b.bind("<Button>",Xevent(fix=fix,mode="SELECT",elem=b).cb)
  2095. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2096. c+=1
  2097. #r+=1
  2098. start_c=3
  2099. c=start_c
  2100. if fix not in gui.elem_attr:
  2101. gui.elem_attr[fix] = {}
  2102. patch = ["UNIVERS","DMX"]
  2103. for k in patch:
  2104. v=data[k]
  2105. #b = tk.Button(xframe,bg="grey", text=str(k)+' '+str(v),width=8)
  2106. command = _SET_PATCH(k,v,fix,data,_cb=self.draw)
  2107. b = tk.Button(xframe,bg="grey", text=str(v),width=2,command=command.attr)
  2108. command.set_button(b)
  2109. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2110. c+=1
  2111. if c >=8:
  2112. c=start_c
  2113. r+=1
  2114. max_dmx = FIXTURES.get_max_dmx_nr(fix)
  2115. dmx_ch_sum += max_dmx[1]
  2116. for i in range(data["DMX"],data["DMX"]+max_dmx[1]):
  2117. k = "{}.{}".format(data["UNIVERS"],i)
  2118. if k in dmx_collision:
  2119. if dmx_collision[k]:
  2120. collision.append(k)
  2121. b = tk.Button(xframe,bg="grey", text="{:3} ({})".format(max_dmx[1] , max_dmx[0]),width=4) #a,anchor="w")
  2122. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2123. c+=1
  2124. #b = tk.Button(xframe,bg="#aaa", text="{:03}-{:03}".format(data["DMX"],len(data["ATTRIBUT"])+(data["DMX"])-1),width=6,anchor="w")
  2125. b = tk.Button(xframe,bg="#aaa", text="{:03} - {:03}".format(data["DMX"],max_dmx[1]+(data["DMX"]-1)),width=8,anchor="w")
  2126. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2127. c+=1
  2128. b = tk.Button(xframe,bg="#aaa",fg="#225", text="{} : {:03}".format(z,dmx_ch_sum),width=6,anchor="w")
  2129. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2130. c+=1
  2131. bg = "#252"
  2132. if collision:
  2133. bg = "#f22"
  2134. else:
  2135. collision = ""
  2136. b = tk.Button(xframe,bg=bg, text="{}".format(",".join(collision)),width=14,anchor="w")
  2137. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2138. c=0
  2139. r+=1
  2140. class GUI_FIX():
  2141. def __init__(self,gui,xframe,yframe=None):
  2142. self.gui = gui
  2143. self.xframe = xframe
  2144. self.yframe = yframe
  2145. def draw(self):
  2146. gui=self.gui
  2147. xframe=self.xframe
  2148. yframe=self.yframe
  2149. r=0
  2150. c=0
  2151. frame_dim=xframe
  2152. if yframe:
  2153. frame_dim=yframe
  2154. for widget in yframe.winfo_children():
  2155. widget.destroy()
  2156. frame_fix=xframe
  2157. for widget in xframe.winfo_children():
  2158. widget.destroy()
  2159. root = frame_dim
  2160. dim_frame = tk.Frame(root,bg="black")
  2161. dim_frame.pack(fill=tk.X, side=tk.TOP)
  2162. root = frame_fix
  2163. fix_frame = tk.Frame(root,bg="black")
  2164. fix_frame.pack(fill=tk.X, side=tk.TOP)
  2165. i=0
  2166. c=0
  2167. r=0
  2168. dim_end=0
  2169. for fix in FIXTURES.fixtures:
  2170. i+=1
  2171. data = FIXTURES.fixtures[fix]
  2172. #print("draw_fix", fix ,data )
  2173. if(len(data["ATTRIBUT"].keys()) <= 1):
  2174. c,r=draw_sub_dim(gui,fix,data,c=c,r=r,frame=dim_frame)
  2175. else:
  2176. if not dim_end:
  2177. dim_end=1
  2178. c=0
  2179. r=0
  2180. #gui._draw_fix(fix,data,root=fix_frame)
  2181. frame = fix_frame
  2182. b = tk.Button(frame,bg="lightblue", text="ID:"+str(fix),width=6,anchor="w")
  2183. b.bind("<Button>",Xevent(fix=fix,mode="SELECT",elem=b).cb)
  2184. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2185. c+=1
  2186. b = tk.Button(frame,bg="#55f", text=data["NAME"],width=10,anchor="w")
  2187. b.bind("<Button>",Xevent(fix=fix,attr="ALL",mode="ENCODER",elem=b).cb)
  2188. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2189. c+=1
  2190. #r+=1
  2191. start_c=3
  2192. c=start_c
  2193. if fix not in gui.elem_attr:
  2194. gui.elem_attr[fix] = {}
  2195. for attr in data["ATTRIBUT"]:
  2196. if attr.endswith("-FINE"):
  2197. continue
  2198. if attr not in gui.all_attr:
  2199. gui.all_attr.append(attr)
  2200. if attr not in gui.elem_attr[fix]:
  2201. gui.elem_attr[fix][attr] = ["line1348",fix,attr]
  2202. v= data["ATTRIBUT"][attr]["VALUE"]
  2203. b = tk.Button(frame,bg="grey", text=str(attr)+' '+str(round(v,2)),width=12, anchor="w")
  2204. gui.elem_attr[fix][attr] = b
  2205. b.bind("<Button>",Xevent(fix=fix,elem=b,attr=attr,mode="ENCODER",data=data).cb)
  2206. b.grid(row=r, column=c, sticky=tk.W+tk.E,ipadx=0,ipady=0,padx=0,pady=0)
  2207. c+=1
  2208. if c >=8:
  2209. c=start_c
  2210. r+=1
  2211. c=0
  2212. r+=1
  2213. #master._refresh_exec()
  2214. #master.refresh_exec()
  2215. def draw_enc(gui,xframe):
  2216. for widget in xframe.winfo_children():
  2217. widget.destroy()
  2218. root2 = xframe
  2219. i=0
  2220. c=0
  2221. r=0
  2222. frame = tk.Frame(xframe,bg="black")
  2223. frame.pack( side=tk.LEFT,expand=0,fill="both")
  2224. b = tk.Button(frame,bg="lightblue", text="ENCODER",width=6)
  2225. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2226. c+=1
  2227. #for attr in ["xx"]*23: # gui.all_attr:
  2228. eat = gui.all_attr
  2229. if len(eat) < 23:
  2230. for i in range(23-len(eat)):
  2231. eat.append("")
  2232. for attr in eat:
  2233. if attr.endswith("-FINE"):
  2234. continue
  2235. v=0
  2236. b = tk.Button(frame,bg="#6e6e6e", text=str(attr)+'',width=7)#, anchor="w")
  2237. if attr == "DIM":
  2238. b = tk.Button(frame,bg="#ff7f00", text=str(attr)+'',width=7)#, anchor="w")
  2239. b.bind("<Button>",Xevent(fix=0,elem=b,attr=attr,data=gui,mode="ENCODER").cb)
  2240. b.grid(row=r, column=c, sticky=tk.W+tk.E ,ipadx=0,ipady=0,padx=0,pady=0)#,expand=True)
  2241. c+=1
  2242. if c >=8:
  2243. c=0
  2244. r+=1
  2245. def _draw_fx(frame,c,r,gui,mode="FX"):
  2246. ct = gui.fx
  2247. prm = fx_prm
  2248. if mode=="FX-MOVE":
  2249. ct = gui.fx_moves
  2250. prm = fx_prm_move
  2251. elif mode=="FX-GENERIC":
  2252. ct = gui.fx_generic
  2253. prm = fx_prm #_generic
  2254. for comm in ct.commands:
  2255. if comm == "\n\n":
  2256. b = tk.Label(frame,bg="black", text="-",font=space_font)
  2257. b.grid(row=r, column=c,pady=0,padx=0, sticky=tk.W+tk.E)
  2258. c=0
  2259. r+=1
  2260. continue
  2261. if comm == "\n":
  2262. c=0
  2263. r+=1
  2264. continue
  2265. v=0
  2266. if "PAN/TILT" in comm:
  2267. b = tk.Button(frame,bg="grey", text=str(comm),width=6,height=2)
  2268. else:
  2269. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  2270. if comm not in ct.elem:
  2271. #comm = comm.replace("\n","")
  2272. ct.elem[comm] = b
  2273. ct.val[comm] = 0
  2274. b.bind("<Button>",Xevent_fx(fix=0,elem=b,attr=comm,data=gui,mode=mode).cb)
  2275. if comm == "REC-FX":
  2276. b["bg"] = "grey"
  2277. elif comm == "FX OFF":
  2278. b["bg"] = "magenta"
  2279. elif comm[:3] == "FX:":
  2280. b["text"] = comm
  2281. b["bg"] = "#ffbf00"
  2282. elif comm[:3] == "MO:":
  2283. b["text"] = comm
  2284. b["bg"] = "lightgreen"
  2285. elif comm.startswith( "SIZE:"):
  2286. b["text"] = "SIZE:\n{:0.0f}".format(prm["SIZE"])
  2287. b["bg"] = "lightgreen"
  2288. elif comm.startswith( "SPEED:"):
  2289. b["text"] = "SPEED:\n{:0.0f}".format(prm["SPEED"])
  2290. b["bg"] = "lightgreen"
  2291. elif comm.startswith("START:"):
  2292. b["bg"] = "lightgreen"
  2293. b["text"] = "START:\n{:0.0f}".format(prm["START"])
  2294. elif comm.startswith( "OFFSET:"):
  2295. b["bg"] = "lightgreen"
  2296. b["text"] = "OFFSET:\n{:0.0f}".format(prm["OFFSET"])
  2297. elif comm[:3] == "BASE:":
  2298. b["bg"] = "lightgreen"
  2299. b["text"] = "BASE:\n{}".format(prm["BASE"])
  2300. elif comm[0] == "M":
  2301. b["text"] = comm
  2302. b["bg"] = "lightgrey"
  2303. if comm:
  2304. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2305. c+=1
  2306. if c >=6:
  2307. c=0
  2308. r+=1
  2309. return c,r
  2310. def draw_fx(gui,xframe):
  2311. frame_fx=xframe
  2312. i=0
  2313. c=0
  2314. r=0
  2315. frame = tk.Frame(frame_fx,bg="black")
  2316. frame.pack(fill=tk.X, side=tk.TOP)
  2317. b = tk.Button(frame,bg="lightblue", text="FX.",width=6)
  2318. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2319. c+=1
  2320. c,r = _draw_fx(frame,c,r,gui,mode="FX-MOVE")
  2321. r+=1
  2322. b = tk.Canvas(frame,bg="black", height=4,bd=0,width=6,highlightthickness=0) #,bd="black")
  2323. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2324. r+=1
  2325. c=0
  2326. c,r = _draw_fx(frame,c,r,gui,mode="FX")
  2327. b = tk.Canvas(frame,bg="black", height=4,bd=0,width=6,highlightthickness=0) #,bd="black")
  2328. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2329. r+=1
  2330. c=0
  2331. c,r = _draw_fx(frame,c,r,gui,mode="FX-GENERIC")
  2332. def draw_setup(gui,xframe):
  2333. frame_cmd=xframe
  2334. i=0
  2335. c=0
  2336. r=0
  2337. frame = tk.Frame(frame_cmd,bg="black")
  2338. frame.pack(fill=tk.X, side=tk.TOP)
  2339. #b = tk.Button(frame,bg="lightblue", text="SETUP",width=6)
  2340. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2341. #b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2342. #r+=1
  2343. c+=1
  2344. for comm in ["SAVE\nSHOW","LOAD\nSHOW","NEW\nSHOW","SAVE\nSHOW AS","SAVE &\nRESTART","DRAW\nGUI"]:
  2345. if comm == "\n":
  2346. c=0
  2347. r+=1
  2348. continue
  2349. v=0
  2350. if comm == "SAVE\nSHOW":
  2351. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=5,height=2)
  2352. elif comm == "LOAD\nSHOW":
  2353. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=5,height=2)
  2354. elif comm == "SAVE\nSHOW AS":
  2355. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  2356. elif comm == "SAVE &\nRESTART":
  2357. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  2358. elif comm == "DRAW\nGUI":
  2359. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  2360. else:
  2361. b = tk.Button(frame,bg="grey", text=str(comm),width=5,height=2)
  2362. if comm not in gui.commands.elem:
  2363. gui.commands.elem[comm] = b
  2364. gui.commands.val[comm] = 0
  2365. b.bind("<Button>",Xevent(fix=0,elem=b,attr=comm,data=gui,mode="SETUP").cb)
  2366. if comm == "BASE:":
  2367. b["text"] = "BASE:{}".format(prm["BASE"])
  2368. if comm:
  2369. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2370. c+=1
  2371. if c >=7:
  2372. c=0
  2373. r+=1
  2374. def draw_live(gui,xframe):
  2375. frame_cmd=xframe
  2376. i=0
  2377. c=0
  2378. r=0
  2379. frame = tk.Frame(frame_cmd,bg="black")
  2380. frame.pack(fill=tk.X, side=tk.TOP)
  2381. c+=1
  2382. for comm in ["FADE","DELAY","PAN/TILT\nFADE","PAN/TILT\nDELAY"]:
  2383. if comm == "\n":
  2384. c=0
  2385. r+=1
  2386. continue
  2387. v=0
  2388. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  2389. if comm not in gui.commands.elem:
  2390. gui.commands.elem[comm] = b
  2391. gui.commands.val[comm] = 0
  2392. b.bind("<Button>",Xevent(fix=0,elem=b,attr=comm,data=gui,mode="LIVE").cb)
  2393. if "FADE" == comm:
  2394. b["text"] = "FADE:\n{:0.2}".format(FADE.val())
  2395. if "DELAY" == comm:
  2396. b["text"] = "DELAY:\n{:0.2}".format(DELAY.val())
  2397. if "PAN/TILT\nFADE" == comm:
  2398. b["text"] = "PAN/TILT\nFADE:{:0.2}".format(FADE_move.val())
  2399. if "FADE" in comm:
  2400. b["bg"] = "green"
  2401. b.config(activebackground="lightgreen")
  2402. if comm:
  2403. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2404. c+=1
  2405. if c >=5:
  2406. c=0
  2407. r+=1
  2408. class LOAD_FIXTURE():
  2409. def __init__(self,name="",master=None):
  2410. self.name=name
  2411. self.master=master
  2412. def cb(self,event=None):
  2413. print("LOAD_FIXTURE",self.name,event)
  2414. if self.master is not None:
  2415. #for i in dir(self.master): #.load_MH2()
  2416. # print(i)
  2417. if "SPARX" in self.name:
  2418. self.master.load_MH2()
  2419. else:
  2420. self.master.load_DIM()
  2421. print(dir(self.master))
  2422. class LOAD_SHOW_AND_RESTAT():
  2423. def __init__(self,fname=""):
  2424. self.fname=fname
  2425. self.base = Base()
  2426. def cb(self,event=None,force=0):
  2427. print("LOAD_SHOW_AND_RESTART.cb force={} name={}".format(force,self.fname) )
  2428. if not self.fname and not force:
  2429. return 0
  2430. if self.base.show_name == self.fname and not force:
  2431. cprint("filename is the same",self.fname)
  2432. return 0
  2433. if not force:
  2434. self.base._set(self.fname)
  2435. print("LOAD SHOW:",event,self.fname)
  2436. print(sys.executable, os.path.abspath(__file__), *sys.argv)
  2437. os.execl("/usr/bin/python3", "/opt/LibreLight/Xdesk/_LibreLightDesk.py", "_LibreLightDesk.py")
  2438. sys.exit()
  2439. class PopupList():
  2440. def __init__(self,name="<NAME>",master=0,width=400,height=450,exit=1,left=_POS_LEFT+400,top=_POS_TOP+100,cb=None,bg="black"):
  2441. self.name = name
  2442. self.frame = None
  2443. self.bg=bg
  2444. self.cb = cb
  2445. if cb is None:
  2446. cb = DummyCallback #("load_show_list.cb")
  2447. w = GUIWindow(self.name,master=master,width=width,height=height,exit=exit,left=left,top=top,cb=cb)
  2448. self.w = w
  2449. w.show()
  2450. def sframe(self,line1="<line1>",line2="<line2>",data=[]):
  2451. xframe=self.w.tk
  2452. if self.bg:
  2453. xframe.configure(bg=self.bg)
  2454. self.w.tk.configure(bg=self.bg)
  2455. c=0
  2456. r=0
  2457. b = tk.Label(xframe,bg="grey",text=line1,anchor="w")
  2458. b.pack(side="top",expand=0,fill="x" )
  2459. b = tk.Label(xframe,bg="grey",text=line2,anchor="w")
  2460. b.pack(side="top",expand=0,fill="x" )
  2461. b = tk.Label(xframe,bg="black",fg="black",text="")
  2462. if self.bg:
  2463. b.configure(fg=self.bg)
  2464. b.configure(bg=self.bg)
  2465. b.pack(side="top")
  2466. b = tk.Entry(xframe,width=10,text="")#,anchor="w")
  2467. b.pack(side="top",expand=0,fill="x")
  2468. b.focus()
  2469. #frame = tk.Frame(xframe,heigh=2800)
  2470. #frame.pack(fill=tk.BOTH,expand=1, side=tk.TOP)
  2471. frame = ScrollFrame(xframe,width=300,height=500,bd=1,bg=self.bg)
  2472. frame.pack(side="left") #fill=tk.BOTH,expand=1, side=tk.TOP)
  2473. self.frame = frame
  2474. self.w.tk.attributes('-topmost',True)
  2475. return frame
  2476. class DummyCallback():
  2477. def __init__(self,name="name"):
  2478. self.name = name
  2479. def cb(self,event=None):
  2480. print("DummyCallback.cb",[self.name,event])
  2481. def _load_show_list(frame,cb=None):
  2482. c=0
  2483. r=0
  2484. base = Base()
  2485. for i in ["name","stamp"]: #,"create"]:
  2486. b = tk.Label(frame,bg="grey",text=i)
  2487. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2488. c+=1
  2489. r+=1
  2490. blist = base._list()
  2491. for i in range(10):
  2492. blist.append(["",""])
  2493. if cb is None:
  2494. cb = DummyCallback #("load_show_list.cb")
  2495. for i in blist:
  2496. #print(i)
  2497. c=0
  2498. for j in i:
  2499. bg="lightgrey"
  2500. dbg="lightgrey"
  2501. if i[1] > time.strftime("%Y-%m-%d %X", time.localtime(time.time()-3600*4)):
  2502. dbg = "lightgreen"
  2503. elif i[1] > time.strftime("%Y-%m-%d %X", time.localtime(time.time()-3600*24*7)):
  2504. dbg = "green"
  2505. if c > 0:
  2506. b = tk.Button(frame,text=j,anchor="w",bg=dbg,relief="sunken")
  2507. b.config(activebackground=dbg)
  2508. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2509. else:
  2510. if base.show_name == i[0]:
  2511. bg="green"
  2512. _cb = cb(j)
  2513. b = tk.Button(frame,text=j,anchor="w",height=1,bg=bg,command=_cb.cb)
  2514. if base.show_name == i[0]:
  2515. b.config(activebackground=bg)
  2516. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2517. c+=1
  2518. r+=1
  2519. def _load_fixture_list(frame,cb=None,master=None,bg="black"):
  2520. frame.configure(bg=bg)
  2521. c=0
  2522. r=0
  2523. base = Base()
  2524. for i in ["name","stamp"]: #,"create"]:
  2525. b = tk.Label(frame,bg="grey",text=i)
  2526. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2527. c+=1
  2528. r+=1
  2529. blist = [] #base._list()
  2530. blist.append(["MAC-500","martin","z"])
  2531. blist.append(["MAC-2000","martin","z"])
  2532. blist.append(["MAC-VIPER","martin","z"])
  2533. blist.append(["SPARX-7","JB","z"])
  2534. blist.append(["SPARX-11","JB","z"])
  2535. blist.append(["JB-P6","JB","z"])
  2536. blist.append(["JB-P7","JB","z"])
  2537. blist.append(["JB-A7","JB","z"])
  2538. blist.append(["TMH-12","Eurolight","z"])
  2539. for i in range(10):
  2540. blist.append(["",""])
  2541. if cb is None:
  2542. cb = DummyCallback #("load_show_list.cb")
  2543. for i in blist:
  2544. #print(i)
  2545. c=0
  2546. for j in i:
  2547. bg="lightgrey"
  2548. dbg="lightgrey"
  2549. if i[1] > time.strftime("%Y-%m-%d %X", time.localtime(time.time()-3600*4)):
  2550. dbg = "lightgreen"
  2551. elif i[1] > time.strftime("%Y-%m-%d %X", time.localtime(time.time()-3600*24*7)):
  2552. dbg = "green"
  2553. if c > 0:
  2554. b = tk.Button(frame,text=j,anchor="w",bg=dbg,relief="sunken")
  2555. b.config(activebackground=dbg)
  2556. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2557. else:
  2558. if base.show_name == i[0]:
  2559. bg="green"
  2560. _cb=cb(j)
  2561. _cb.master=master
  2562. b = tk.Button(frame,text=j,anchor="w",height=1,bg=bg,command=_cb.cb)
  2563. if base.show_name == i[0]:
  2564. b.config(activebackground=bg)
  2565. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2566. c+=1
  2567. r+=1
  2568. def draw_command(gui,xframe):
  2569. frame_cmd=xframe
  2570. i=0
  2571. c=0
  2572. r=0
  2573. frame = tk.Frame(frame_cmd,bg="black")
  2574. frame.pack(fill=tk.X, side=tk.TOP)
  2575. # b = tk.Button(frame,bg="lightblue", text="COMM.",width=6)
  2576. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2577. #b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2578. #r+=1
  2579. c+=1
  2580. for comm in gui.commands.commands:
  2581. if comm == "\n":
  2582. c=0
  2583. r+=1
  2584. continue
  2585. v=0
  2586. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  2587. if comm not in gui.commands.elem:
  2588. gui.commands.elem[comm] = b
  2589. gui.commands.val[comm] = 0
  2590. b.bind("<Button>",Xevent(fix=0,elem=b,attr=comm,data=gui,mode="COMMAND").cb)
  2591. if comm == "BLIND":
  2592. b["bg"] = "grey"
  2593. if comm == "CLEAR":
  2594. b["bg"] = "grey"
  2595. if comm == "REC-FX":
  2596. b["bg"] = "grey"
  2597. if comm == "FADE":
  2598. b["bg"] = "green"
  2599. if comm == "FX OFF":
  2600. b["bg"] = "magenta"
  2601. if comm == "SIZE:":
  2602. b["text"] = "SIZE:{:0.0f}".format(fx_prm["SIZE"])
  2603. if comm == "SPEED:":
  2604. b["text"] = "SPEED:{:0.0f}".format(fx_prm["SPEED"])
  2605. if comm == "DELAY":
  2606. b["text"] = "FADE:\n{:0.02f}".format(DELAY.val())
  2607. if comm == "FADE":
  2608. b["text"] = "FADE:\n{:0.02f}".format(FADE.val())
  2609. if comm == "START:":
  2610. b["text"] = "START:{:0.0f}".format(fx_prm["START"])
  2611. if comm == "OFFSET:":
  2612. b["text"] = "OFFSET:{:0.0f}".format(fx_prm["OFFSET"])
  2613. if comm == "BASE:":
  2614. b["text"] = "BASE:{}".format(fx_prm["BASE"])
  2615. if comm:
  2616. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2617. c+=1
  2618. if c >=5:
  2619. c=0
  2620. r+=1
  2621. def draw_preset(gui,xframe):
  2622. i=0
  2623. c=0
  2624. r=0
  2625. root = xframe
  2626. frame = tk.Frame(root,bg="black")
  2627. frame.pack(fill=tk.X, side=tk.TOP)
  2628. i=0
  2629. for k in PRESETS.val_presets:
  2630. if i%(10*8)==0 or i ==0:
  2631. c=0
  2632. #b = tk.Label(frame,bg="black", text="" )
  2633. b = tk.Canvas(frame,bg="black", height=4,bd=0,width=6,highlightthickness=0) #,bd="black")
  2634. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2635. r+=1
  2636. c=0
  2637. b = tk.Button(frame,bg="lightblue", text="EXEC " )
  2638. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2639. c+=1
  2640. b = tk.Button(frame,bg="lightblue", text="BANK " + str(int(i/(8*8))+1) )
  2641. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2642. c+=1
  2643. b = tk.Button(frame,bg="lightblue", text="NAME" )
  2644. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2645. r+=1
  2646. c=0
  2647. i+=1
  2648. v=0
  2649. label = ""
  2650. #if k in PRESETS.label_presets:
  2651. # label = PRESETS.label_presets[k]
  2652. # #print([label])
  2653. sdata=PRESETS.val_presets[k]
  2654. BTN="go"
  2655. if "CFG" in sdata:#["BUTTON"] = "GO"
  2656. if "BUTTON" in sdata["CFG"]:
  2657. BTN = sdata["CFG"]["BUTTON"]
  2658. #bb = tk.Frame(frame, highlightbackground = "red", highlightthickness = 1, bd=0)
  2659. #bb = tk.Canvas(frame, highlightbackground = "black", highlightthickness = 1, bd=1)
  2660. #bb.configure(width=70, height=38)
  2661. txt=str(k+1)+":"+str(BTN)+":"+str(len(sdata)-1)+"\n"+label
  2662. b = ExecButton(frame,text=txt)
  2663. #b = tk.Button(bb,bg="grey", text=txt,width=7,height=2)
  2664. b.bind("<Button>",Xevent(fix=0,elem=b,attr=k,data=gui,mode="PRESET").cb)
  2665. b.bind("<ButtonRelease>",Xevent(fix=0,elem=b,attr=k,data=gui,mode="PRESET").cb)
  2666. if k not in gui.elem_presets:
  2667. gui.elem_presets[k] = b
  2668. #b.pack(expand=1)
  2669. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2670. c+=1
  2671. if c >=10:
  2672. c=0
  2673. r+=1
  2674. time.sleep(0.1)
  2675. gui._refresh_exec()
  2676. gui.refresh_exec()
  2677. gui.refresh_exec()
  2678. def draw_input(gui):
  2679. i=0
  2680. c=0
  2681. r=0
  2682. frame = tk.Frame(root2,bg="black")
  2683. frame.pack(fill=tk.X, side=tk.TOP)
  2684. b = tk.Label(frame,bg="black", text="------------------------ ---------------------------------------")
  2685. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2686. r=0
  2687. frame = tk.Frame(root2,bg="black")
  2688. frame.pack(fill=tk.X, side=tk.TOP)
  2689. b = tk.Label(frame, text="send:")
  2690. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2691. c+=1
  2692. b = tk.Entry(frame,bg="grey", text="",width=50)
  2693. gui.entry = b
  2694. b.bind("<Button>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT").cb)
  2695. b.bind("<Key>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT").cb)
  2696. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2697. b.insert("end","d0:127,fx241:sinus:50:50:10,fx243:cosinus:50:50:10,d201:127,fx201:sinus:50:300:10")
  2698. r+=1
  2699. b = tk.Entry(frame,bg="grey", text="",width=20)
  2700. gui.entry2 = b
  2701. b.bind("<Button>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT2").cb)
  2702. b.bind("<Key>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT2").cb)
  2703. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2704. b.insert("end","d1:0:4")
  2705. r+=1
  2706. b = tk.Entry(frame,bg="grey", text="",width=20)
  2707. gui.entry3 = b
  2708. b.bind("<Button>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT3").cb)
  2709. #b.bind("<B1-Motion>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT3").cb)
  2710. b.bind("<Key>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT3").cb)
  2711. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2712. b.insert("end","fx:alloff:::")
  2713. def draw_colorpicker(gui,xframe):
  2714. import lib.colorpicker as colp
  2715. class _CB():
  2716. def __init__(gui):
  2717. gui.old_color = (0,0,0)
  2718. def cb(gui,event,data):
  2719. print("CB.cb",gui,event,data)
  2720. cprint("colorpicker CB")
  2721. if "color" not in data:
  2722. return 0
  2723. if gui.old_color == data["color"]:
  2724. pass #return 0
  2725. #gui.old_color = data["color"]
  2726. color = data["color"]
  2727. print("e",event,data)
  2728. print("e",dir(event))#.keys())
  2729. try:
  2730. print("e.state",event.state)
  2731. except:pass
  2732. set_fade = FADE.val() #fade
  2733. event_ok = 0
  2734. event_num = 0
  2735. event_state = 0
  2736. if event is None:
  2737. event_ok = 1
  2738. event_num = 3
  2739. elif event.num == 1:
  2740. event_ok = 1
  2741. event_num = event.num
  2742. elif event.num == 3:
  2743. event_ok = 1
  2744. event_num = event.num
  2745. elif event.num==2:
  2746. event_ok = 1
  2747. event_num = event.num
  2748. elif event.state in [256,1024]:
  2749. event_ok = 1
  2750. event_state = event.state
  2751. if "color" in data and event_ok:
  2752. cr=None
  2753. cg=None
  2754. cb=None
  2755. cw=0
  2756. ca=0
  2757. set_fade=0
  2758. if event_num == 1:
  2759. if FADE._is():
  2760. set_fade=FADE.val() #fade
  2761. cr = color[0]
  2762. cg = color[1]
  2763. cb = color[2]
  2764. elif event_num == 3:
  2765. cr = color[0]
  2766. cg = color[1]
  2767. cb = color[2]
  2768. elif event_num == 2:
  2769. cr= "click"
  2770. cg= "click"
  2771. cb= "click"
  2772. cw= "click"
  2773. ca= "click"
  2774. elif event_state == 256:
  2775. cr = color[0]
  2776. cg = color[1]
  2777. cb = color[2]
  2778. if cr is not None:
  2779. FIXTURES.encoder(fix=0,attr="RED",xval=cr,xfade=set_fade)
  2780. if cg is not None:
  2781. FIXTURES.encoder(fix=0,attr="GREEN",xval=cg,xfade=set_fade)
  2782. if cb is not None:
  2783. FIXTURES.encoder(fix=0,attr="BLUE",xval=cb,xfade=set_fade)
  2784. FIXTURES.encoder(fix=0,attr="WHITE",xval=cw,xfade=set_fade)
  2785. FIXTURES.encoder(fix=0,attr="AMBER",xval=ca,xfade=set_fade)
  2786. master.refresh_fix()
  2787. print("PICK COLOR:",data["color"])
  2788. _cb=_CB()
  2789. colp.colorpicker(xframe,width=580,height=113, xcb=_cb.cb)
  2790. return 0
  2791. canvas=tk.Canvas(xframe,width=600,height=113)
  2792. canvas["bg"] = "yellow" #"green"
  2793. canvas.pack()
  2794. # RGB
  2795. x=0
  2796. y=0
  2797. j=0
  2798. d = 20
  2799. for i in range(0,d+1):
  2800. fi = int(i*255/d)
  2801. f = 255-fi
  2802. if i > d/2:
  2803. pass#break
  2804. color = '#%02x%02x%02x' % (f, fi, fi)
  2805. print( "farbe", i*10, j, f,fi,fi,color)
  2806. r = canvas.create_rectangle(x, y, x+20, y+20, fill=color)
  2807. x+=20
  2808. class TableFrame():
  2809. def __init__(self,root, width=50,height=100,bd=1):
  2810. self.root=root
  2811. self.a = _TableFrame(self.root)
  2812. f=self.a.HFrame()
  2813. f=self.a.Sframe(f, width=width,height=height,bd=bd)
  2814. self.a.draw([["A","11"],["B",4],["E",""],["R","R"],["Z","Z"],["U","U"]])
  2815. self.b = _TableFrame(self.root) #äself.root)
  2816. b=self.b.HFrame()
  2817. b=self.b.Sframe(b, width=width,height=height,bd=bd)
  2818. self.b.draw([["AA","1a1"],["BBB",114],["EE","22"],["RRR","RRR"],["TTZ","TTZ"],["ZZU","ZZU"]])
  2819. self.c = _TableFrame(self.root)
  2820. c=self.c.HFrame()
  2821. c=self.c.Sframe(c, width=width,height=height,bd=bd)
  2822. self.c.draw([["A","11"],["B",4],["E",""],["R","R"],["Z","Z"],["U","U"]][::-1])
  2823. self.bframe=None
  2824. def draw(self,data=[1,2],head=[],config=[]):
  2825. pass
  2826. class _TableFrame():
  2827. def __init__(self,main):
  2828. self.main = main
  2829. self.frame=tk.Frame(self.main,relief=tk.GROOVE,bg="yellow")#,width=width,height=height,bd=bd)
  2830. self.frame.pack(side="top",fill="x",expand=1) #x=0,y=0)
  2831. self.hframe=tk.Frame(self.frame,relief=tk.GROOVE,bg="yellow")#,width=width,height=height,bd=bd)
  2832. self.hframe.pack(side="top",fill="x",expand=0) #x=0,y=0)
  2833. self.aframe=tk.Frame(self.main,relief=tk.GROOVE)#,width=width,height=height,bd=bd)
  2834. #aframe.place(x=0,y=0)
  2835. self.aframe.pack(side="top",fill="both",expand=1) #x=0,y=0)
  2836. self.canvas=tk.Canvas(self.aframe,width=100-24,height=150)
  2837. self.canvas["bg"] = "blue" #black" #"green"
  2838. self.bframe=tk.Frame(self.canvas)#,width=width,height=height)
  2839. self.bframe["bg"] = "blue"
  2840. self.scrollbar=tk.Scrollbar(self.aframe,orient="vertical",command=self.canvas.yview,width=20)
  2841. self.canvas.configure(yscrollcommand=self.scrollbar.set)
  2842. self.scrollbar.pack(side="right",fill="y")
  2843. self.canvas.pack(side="left",expand=1,fill="both")
  2844. self.canvas.create_window((0,0),window=self.bframe,anchor='nw')
  2845. self.bframe.bind("<Configure>",scroll(self.canvas).config)
  2846. self.canvas.bind("<Button>",Event("XXX").event)
  2847. self.canvas.bind("<Key>",Event("XXX").event)
  2848. self.canvas.bind("<KeyRelease>",Event("XXX").event)
  2849. #self.bframe=tk.Frame(self.frame,relief=tk.GROOVE,bg="magenta")#,width=width,height=height,bd=bd)
  2850. #self.bframe.pack(side="top",fill="both",expand=1) #x=0,y=0)
  2851. #self.HFrame()
  2852. def HFrame(self,main=None):
  2853. self.e = tk.Label(self.hframe,text="Filter:")
  2854. self.e.pack(side="left")
  2855. self.e = tk.Entry(self.hframe)
  2856. self.e.pack(side="left")
  2857. def Sframe(self,main=None, **args):
  2858. pass
  2859. def draw(self,data=[1,2],head=[],config=[]):
  2860. yframe = self.bframe
  2861. if 1:
  2862. xframe = tk.Frame(yframe,bg="black")
  2863. xframe.pack(side="top", expand=1,fill="both")
  2864. def yview(event):
  2865. print("yevent",event)
  2866. yyy=20.1
  2867. xframe.yview_moveto(yyy)
  2868. i=0
  2869. c=0
  2870. r=0
  2871. b = tk.Button(xframe,bg="lightblue", text="ID",width=6,anchor="e")
  2872. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2873. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2874. c+=1
  2875. b = tk.Button(xframe,bg="lightblue", text="NAME",width=14,anchor="w")
  2876. #b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  2877. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2878. c+=1
  2879. b = tk.Button(xframe,bg="#ddd", text="TYPE",width=3)
  2880. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2881. c+=1
  2882. b = tk.Button(xframe,bg="#ddd", text="Uni",width=1)
  2883. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2884. c+=1
  2885. b = tk.Button(xframe,bg="#ddd", text="DMX",width=1)
  2886. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2887. c+=1
  2888. b = tk.Button(xframe,bg="#ddd", text="CH's",width=1)
  2889. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2890. c+=1
  2891. c=0
  2892. r+=1
  2893. for i,p in enumerate(data):
  2894. for j in data[i]:
  2895. b = tk.Button(xframe,bg="lightblue", text=""+str(j),width=6,anchor="e")
  2896. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  2897. c+=1
  2898. c=0
  2899. r+=1
  2900. return self.bframe
  2901. def ScrollFrame(root,width=50,height=100,bd=1,bg="black"):
  2902. #print("ScrollFrame init",width,height)
  2903. aframe=tk.Frame(root,relief=tk.GROOVE)#,width=width,height=height,bd=bd)
  2904. #aframe.place(x=0,y=0)
  2905. aframe.pack(side="left",fill="both",expand=1) #x=0,y=0)
  2906. canvas=tk.Canvas(aframe,width=width-24,height=height)
  2907. if bg == "":
  2908. bg="orange"
  2909. canvas["bg"] = bg # "black" #"green"
  2910. bframe=tk.Frame(canvas,width=width,height=height)
  2911. bframe["bg"] = "blue"
  2912. scrollbar=tk.Scrollbar(aframe,orient="vertical",command=canvas.yview,width=20)
  2913. canvas.configure(yscrollcommand=scrollbar.set)
  2914. scrollbar.pack(side="right",fill="y")
  2915. canvas.pack(side="left",expand=1,fill="both")
  2916. canvas.create_window((0,0),window=bframe,anchor='nw')
  2917. bframe.bind("<Configure>",scroll(canvas).config)
  2918. canvas.bind("<Button>",Event("XXX").event)
  2919. canvas.bind("<Key>",Event("XXX").event)
  2920. canvas.bind("<KeyRelease>",Event("XXX").event)
  2921. return bframe
  2922. #frame = ScrollFrame(root)
  2923. class GUIHandler():
  2924. def __init__(self):
  2925. pass
  2926. def update(self,fix,attr,args={}):
  2927. print("GUIHandler.update()",fix,attr,args)
  2928. for i,k in enumerate(args):
  2929. v = args[k]
  2930. #print("GUI-H", i,k,v)
  2931. class Fixtures():
  2932. def __init__(self):
  2933. #super().__init__()
  2934. self.base=Base()
  2935. #self.load()
  2936. self.fixtures = OrderedDict()
  2937. self.gui = GUIHandler()
  2938. def load_patch(self):
  2939. filename="patch"
  2940. #self.base._init()
  2941. d,l = self.base._load(filename)
  2942. self.fixtures = OrderedDict()
  2943. for i in l:
  2944. sdata = d[i]
  2945. new_f = OrderedDict()
  2946. #print("++++")
  2947. for k,j in sdata.items():
  2948. overide=0 # only for repair
  2949. if overide:
  2950. if k in ["TYPE","VENDOR"]: #ignor
  2951. continue
  2952. new_f[k] = j
  2953. if k =="NAME":
  2954. #print("AAAADDDDDD")
  2955. if "TYPE" not in sdata and not overide:
  2956. if len( sdata["ATTRIBUT"]) == 1:
  2957. new_f["TYPE"] = "DIMMER"
  2958. elif "PAN" in sdata["ATTRIBUT"]:
  2959. new_f["TYPE"] = "MOVER"
  2960. elif "RED" in sdata["ATTRIBUT"] and len(sdata["ATTRIBUT"]) == 3:
  2961. new_f["TYPE"] = "RGB"
  2962. elif "RED" in sdata["ATTRIBUT"]:
  2963. new_f["TYPE"] = "LED"
  2964. elif "CYAN" in sdata["ATTRIBUT"]:
  2965. new_f["TYPE"] = "COLOR"
  2966. else:
  2967. new_f["TYPE"] = ""
  2968. if "VENDOR" not in sdata and not overide:
  2969. new_f["VENDOR"] = ""
  2970. #print(k,j)#,sdata)
  2971. sdata = new_f
  2972. if "ACTIVE" not in sdata:
  2973. sdata["ACTIVE"] = 0
  2974. for attr in sdata["ATTRIBUT"]:
  2975. sdata["ATTRIBUT"][attr]["ACTIVE"] = 0
  2976. #print("load",filename,sdata)
  2977. #if "CFG" not in sdata:
  2978. # sdata["CFG"] = OrderedDict()
  2979. self.fixtures[str(i)] = sdata
  2980. #PRESETS.label_presets = l
  2981. def backup_patch(self,save_as=""):
  2982. filename = "patch"
  2983. data = self.fixtures
  2984. labels = {}
  2985. for k in data:
  2986. labels[k] = k
  2987. #self.base._init()
  2988. self.base._backup(filename,data,labels,save_as)
  2989. def fx_get(self,fix=None):
  2990. out={}
  2991. if not fix or fix == "all":
  2992. #self.data.fx.elem[self.attr]["bg"] = "magenta"
  2993. for fix in self.fixtures:
  2994. data = self.fixtures[fix]
  2995. for attr in data["ATTRIBUT"]:
  2996. out[str(fix)+"."+str(attr)+".fx"] = data["ATTRIBUT"][attr]["FX"]
  2997. out[str(fix)+"."+str(attr)+".fx"] = data["ATTRIBUT"][attr]["FX2"]
  2998. return out
  2999. def fx_off(self,fix=None):
  3000. if not fix or fix == "all":
  3001. #self.data.fx.elem[self.attr]["bg"] = "magenta"
  3002. for fix in self.fixtures:
  3003. data = self.fixtures[fix]
  3004. for attr in data["ATTRIBUT"]:
  3005. data["ATTRIBUT"][attr]["FX"] = ""
  3006. data["ATTRIBUT"][attr]["FX2"] = OrderedDict()
  3007. def get_attr(self,fix,attr):
  3008. if fix in self.fixtures:
  3009. data = self.fixtures[fix]
  3010. if "ATTRIBUT" in data:
  3011. if attr in data["ATTRIBUT"]:
  3012. return data["ATTRIBUT"][attr]
  3013. def get_max_dmx_nr(self,fix):
  3014. max_dmx = 0
  3015. used_dmx = 0
  3016. if fix not in self.fixtures:
  3017. return (used_dmx,max_dmx)
  3018. data = self.fixtures[fix]
  3019. used_dmx = len(data["ATTRIBUT"])
  3020. for a in data["ATTRIBUT"]:
  3021. attr = data["ATTRIBUT"][a]
  3022. if "NR" in attr:
  3023. try:
  3024. _n = int(attr["NR"])
  3025. if _n > max_dmx:
  3026. max_dmx=_n
  3027. except ValueError:pass
  3028. return (used_dmx,max_dmx)
  3029. def get_dmx(self,fix,attr):
  3030. #cprint("get_dmx",[fix,attr])
  3031. if fix in self.fixtures:
  3032. data = self.fixtures[fix]
  3033. DMX = -99
  3034. if "DMX" in data:
  3035. DMX = int(data["DMX"])
  3036. if DMX < 1: # ignore attribute with DMX lower 1
  3037. return -22
  3038. else:
  3039. return -1
  3040. if "UNIVERS" in data:
  3041. if int(data["UNIVERS"]) >= 0:
  3042. DMX += (int(data["UNIVERS"])*512)
  3043. else:
  3044. return -33
  3045. adata = self.get_attr(fix,attr)
  3046. #-hier ende 8.2.22
  3047. #cprint("adata",adata,DMX)
  3048. if adata:
  3049. if "NR" in adata:
  3050. NR = adata["NR"]
  3051. if NR >= 1:
  3052. DMX+=NR-1
  3053. else:
  3054. return -44
  3055. return DMX
  3056. return -4
  3057. return -3
  3058. def update_raw(self,rdata,update=1):
  3059. cprint("update_raw",len(rdata))
  3060. cmd = []
  3061. for i,d in enumerate(rdata):
  3062. xcmd = {"DMX":""}
  3063. #print("fix:",i,d)
  3064. fix = d["FIX"]
  3065. attr = d["ATTR"]
  3066. v2 = d["VALUE"]
  3067. v2_fx = d["FX"]
  3068. if fix not in self.fixtures:
  3069. continue
  3070. sdata = self.fixtures[fix] #shortcat
  3071. ATTR = sdata["ATTRIBUT"]
  3072. sDMX = 0
  3073. if sdata["DMX"] > 0:
  3074. #print( sdata)
  3075. sDMX = (sdata["UNIVERS"]*512)+sdata["DMX"]
  3076. #sDMX =sdata["DMX"]
  3077. #else:
  3078. # continue
  3079. if attr not in ATTR:
  3080. continue
  3081. #DMX = FIXTURES.get_dmx(fix)
  3082. if ATTR[attr]["NR"] >= 0:
  3083. DMX = sDMX+ATTR[attr]["NR"]-1
  3084. xcmd["DMX"] = str(DMX)
  3085. else:
  3086. if attr == "DIM" and ATTR[attr]["NR"] < 0:
  3087. xcmd["VIRTUAL"] = {}
  3088. for a in ATTR:
  3089. if ATTR[a]["MASTER"]:
  3090. xcmd["VIRTUAL"][a] = sDMX+ATTR[a]["NR"]-1
  3091. #print( "VIRTUAL",xcmd)
  3092. cmd.append(xcmd)
  3093. v=ATTR[attr]["VALUE"]
  3094. if v2 is not None and update:
  3095. ATTR[attr]["VALUE"] = v2
  3096. if d["FX2"] and update:
  3097. ATTR[attr]["FX2"] = d["FX2"]
  3098. #self.data.elem_attr[fix][attr]["text"] = str(attr)+' '+str(round(v,2))
  3099. text = str(attr)+' '+str(round(v,2))
  3100. #self.gui.update(fix,attr,args={"text":text})
  3101. #print("END 5454 _=_=_=_=_==_")
  3102. #cprint("update_raw",cmd,color="red")
  3103. return cmd
  3104. def encoder(self,fix,attr,xval="",xfade=0,xdelay=0):
  3105. cprint("FIXTURES.encoder",fix,attr,xval,xfade,color="yellow")
  3106. if attr == "CLEAR":
  3107. self.clear()
  3108. return 0
  3109. if attr == "ALL":
  3110. x=self.select(fix,attr,mode="toggle")
  3111. return x
  3112. if fix not in self.fixtures:
  3113. jdata=[{"MODE":"---"}]
  3114. ii =0
  3115. jclient_send(jdata)
  3116. delay=0
  3117. for fix in self.fixtures:
  3118. ii+=1
  3119. #cprint(fix,attr,xval)
  3120. data = self.fixtures[fix]
  3121. if "-FINE" in attr.upper():
  3122. continue
  3123. elif attr == "ALL":
  3124. pass
  3125. elif (attr in data["ATTRIBUT"] or attr == "ALL") and "-FINE" not in attr.upper() :
  3126. if xval == "click":
  3127. self.select(fix,attr,mode="on")
  3128. elif data["ATTRIBUT"][attr]["ACTIVE"]:
  3129. if fix: # prevent endless recursion
  3130. self.encoder(fix,attr,xval,xfade,delay)
  3131. if DELAY._is():
  3132. delay += DELAY.val()/100
  3133. jdata=[{"MODE":ii}]
  3134. jclient_send(jdata)
  3135. return 0
  3136. data = self.fixtures[fix]
  3137. if xval == "click":
  3138. #cprint(data)
  3139. return self.select(fix,attr,mode="toggle")
  3140. v2=data["ATTRIBUT"][attr]["VALUE"]
  3141. change=0
  3142. increment = 4.11
  3143. jdata = {"MODE":"ENC"}
  3144. if xval == "++":
  3145. v2+= increment
  3146. jdata["INC"] = increment
  3147. change=1
  3148. elif xval == "--":
  3149. jdata["INC"] = increment*-1
  3150. v2-= increment
  3151. change=1
  3152. elif xval == "+":
  3153. increment = 0.5
  3154. v2+= increment
  3155. jdata["INC"] = increment
  3156. change=1
  3157. elif xval == "-":
  3158. increment = 0.5
  3159. jdata["INC"] = increment*-1
  3160. v2-= increment
  3161. change=1
  3162. elif type(xval) is int or type(xval) is float:
  3163. v2 = xval
  3164. change=1
  3165. if v2 < 0:
  3166. v2=0
  3167. elif v2 > 256:
  3168. v2=256
  3169. jdata["VALUE"] = round(v2,4)
  3170. jdata["FIX"] = fix
  3171. jdata["ATTR"] = attr
  3172. jdata["DMX"] = FIXTURES.get_dmx(fix,attr)
  3173. out = {}
  3174. if change:
  3175. data["ATTRIBUT"][attr]["ACTIVE"] = 1
  3176. data["ATTRIBUT"][attr]["VALUE"] = round(v2,4)
  3177. jdata["FADE"] = 0
  3178. if xfade:
  3179. jdata["FADE"] = xfade
  3180. if xdelay:
  3181. #if attr not in ["PAN","TILT"] and 1:
  3182. jdata["DELAY"] = xdelay
  3183. if not modes.val("BLIND"):
  3184. jdata = [jdata]
  3185. #print("ENC",jdata)
  3186. jclient_send(jdata)
  3187. time.sleep(0.001)
  3188. return v2
  3189. def get_active(self):
  3190. cprint("get_active",self)
  3191. CFG = OrderedDict()
  3192. sdata = OrderedDict()
  3193. sdata["CFG"] = CFG # OrderedDict()
  3194. sdata["CFG"]["FADE"] = FADE.val()
  3195. sdata["CFG"]["DEALY"] = 0
  3196. #sdata["CFG"]["BUTTON"] = "GO"
  3197. for fix in self.fixtures:
  3198. data = self.fixtures[fix]
  3199. for attr in data["ATTRIBUT"]:
  3200. if data["ATTRIBUT"][attr]["ACTIVE"]:
  3201. if fix not in sdata:
  3202. sdata[fix] = {}
  3203. if attr not in sdata[fix]:
  3204. sdata[fix][attr] = OrderedDict()
  3205. if not modes.val("REC-FX"):
  3206. sdata[fix][attr]["VALUE"] = data["ATTRIBUT"][attr]["VALUE"]
  3207. #sdata[fix][attr]["FADE"] = FADE.val() #fade
  3208. else:
  3209. sdata[fix][attr]["VALUE"] = None #data["ATTRIBUT"][attr]["VALUE"]
  3210. if "FX" not in data["ATTRIBUT"][attr]:
  3211. data["ATTRIBUT"][attr]["FX"] =""
  3212. if "FX2" not in data["ATTRIBUT"][attr]:
  3213. data["ATTRIBUT"][attr]["FX2"] ={}
  3214. sdata[fix][attr]["FX"] = data["ATTRIBUT"][attr]["FX"]
  3215. sdata[fix][attr]["FX2"] = data["ATTRIBUT"][attr]["FX2"]
  3216. return sdata
  3217. def _deselect_all(self,fix=None):
  3218. cprint("FIXTURES._deselect_all()",fix,"ALL",color="yellow")
  3219. c=0
  3220. if fix in self.fixtures:
  3221. data = self.fixtures[fix]
  3222. for attr in data["ATTRIBUT"]:
  3223. #print("SELECT ALL",fix,attr)
  3224. if "-FINE" in attr.upper():
  3225. pass
  3226. else:
  3227. c+=self.select(fix,attr,mode="off",mute=1)
  3228. return c
  3229. def _select_all(self,fix=None,mode="toggle"):
  3230. cprint("FIXTURES._select_all()",fix,"ALL",mode,color="yellow")
  3231. c=0
  3232. if fix in self.fixtures:
  3233. data = self.fixtures[fix]
  3234. for attr in data["ATTRIBUT"]:
  3235. #print("SELECT ALL",fix,attr)
  3236. if "-FINE" in attr.upper():
  3237. pass
  3238. else:
  3239. c+=self.select(fix,attr,mode="on",mute=1)
  3240. if not c and mode == "toggle": # unselect all
  3241. c= self._deselect_all(fix=fix)
  3242. return c
  3243. def select(self,fix=None,attr=None,mode="on",mute=0):
  3244. if not mute:
  3245. cprint("FIXTURES.select()",fix,attr,mode,color="yellow")
  3246. out = 0
  3247. if fix in self.fixtures:
  3248. data = self.fixtures[fix]
  3249. if attr.upper() == "ALL":
  3250. x=self._select_all(fix=fix,mode=mode)
  3251. return x
  3252. elif attr in data["ATTRIBUT"]:
  3253. if mode == "on":
  3254. if not data["ATTRIBUT"][attr]["ACTIVE"]:
  3255. data["ATTRIBUT"][attr]["ACTIVE"] = 1
  3256. out = 1
  3257. elif mode == "off":
  3258. if data["ATTRIBUT"][attr]["ACTIVE"]:
  3259. data["ATTRIBUT"][attr]["ACTIVE"] = 0
  3260. out = 1
  3261. elif mode == "toggle":
  3262. if data["ATTRIBUT"][attr]["ACTIVE"]:
  3263. data["ATTRIBUT"][attr]["ACTIVE"] = 0
  3264. else:
  3265. data["ATTRIBUT"][attr]["ACTIVE"] = 1
  3266. out = 1
  3267. return out
  3268. def clear(self):
  3269. out = 0
  3270. for fix in self.fixtures:
  3271. data = self.fixtures[fix]
  3272. for attr in data["ATTRIBUT"]:
  3273. #if attr.endswith("-FINE"):
  3274. # continue
  3275. if data["ATTRIBUT"][attr]["ACTIVE"]:
  3276. out +=1
  3277. data["ATTRIBUT"][attr]["ACTIVE"] = 0
  3278. return out
  3279. class Presets():
  3280. def __init__(self):
  3281. #super().__init__()
  3282. self.base = Base()
  3283. #self.load()
  3284. self._last_copy = None
  3285. self._last_move = None
  3286. self.fx_buffer = {}
  3287. def load_presets(self):
  3288. #self._load()
  3289. filename="presets"
  3290. #self.base._init()
  3291. d,l = self.base._load(filename)
  3292. for i in d:
  3293. sdata = d[i]
  3294. if "CFG" not in sdata:
  3295. sdata["CFG"] = OrderedDict()
  3296. if "FADE" not in sdata["CFG"]:
  3297. sdata["CFG"]["FADE"] = 4
  3298. if "DELAY" not in sdata["CFG"]:
  3299. sdata["CFG"]["DELAY"] = 0
  3300. if "BUTTON" not in sdata["CFG"]:
  3301. sdata["CFG"]["BUTTON"] = "GO"
  3302. self.val_presets = d
  3303. self.label_presets = l
  3304. def check_cfg(self,nr=None):
  3305. cprint("PRESETS.check_cfg()",nr)#,color="red")
  3306. ok = 0
  3307. if nr is not None:
  3308. if nr in self.val_presets:
  3309. sdata = self.val_presets[nr]
  3310. ok += self._check_cfg(sdata)
  3311. else:
  3312. cprint("nr not in data ",nr,color="red")
  3313. else:
  3314. for nr in self.val_presets:
  3315. sdata = self.val_presets[nr]
  3316. ok += self._check_cfg(sdata)
  3317. return ok
  3318. def _check_cfg(self,sdata):
  3319. cprint("PRESETS._check_cfg()")#,color="red")
  3320. ok=0
  3321. if "CFG" not in sdata:
  3322. sdata["CFG"] = OrderedDict()
  3323. ok += 1
  3324. if "FADE" not in sdata["CFG"]:
  3325. sdata["CFG"]["FADE"] = 4
  3326. ok += 1
  3327. if "DELAY" not in sdata["CFG"]:
  3328. sdata["CFG"]["DELAY"] = 0
  3329. ok += 1
  3330. if "BUTTON" not in sdata["CFG"]:
  3331. sdata["CFG"]["BUTTON"] = "GO"
  3332. ok += 1
  3333. if ok:
  3334. cprint("REPAIR CFG's",ok,sdata["CFG"],color="red")
  3335. return ok
  3336. def backup_presets(self,save_as=""):
  3337. filename = "presets"
  3338. data = self.val_presets
  3339. labels = self.label_presets
  3340. #self.base._init()
  3341. self.base._backup(filename,data,labels,save_as)
  3342. def get_cfg(self,nr):
  3343. cprint("PRESETS.get_cfg()",nr)
  3344. self.check_cfg(nr)
  3345. if nr not in self.val_presets:
  3346. cprint("get_cfg",self,"error get_cfg no nr:",nr,color="red")
  3347. return {}
  3348. if "CFG" in self.val_presets[nr]:
  3349. return self.val_presets[nr]["CFG"]
  3350. def clean(self,nr):
  3351. if nr not in self.val_presets:
  3352. self.val_presets[nr] = OrderedDict()
  3353. #self.val_presets[nr]["VALUE"] = 0
  3354. #self.val_presets[nr]["FX"] = ""
  3355. sdata = self.val_presets[nr]
  3356. for fix in sdata:
  3357. #print("exec.clear()",nr,fix,sdata[fix])
  3358. for attr in sdata[fix]:
  3359. row = sdata[fix][attr]
  3360. if fix == "CFG":
  3361. continue
  3362. if "VALUE" not in row:
  3363. row["VALUE"] = None
  3364. if "FX" not in row:
  3365. row["FX"] = ""
  3366. if "FX2" not in row:
  3367. row["FX2"] = OrderedDict()
  3368. elif row["FX2"]:
  3369. for k in ["SIZE","SPEED","START","OFFSET"]:
  3370. row["FX2"][k] = int( row["FX2"][k] )
  3371. row["FX"] = ""
  3372. if "FX" in row and row["FX"] and not row["FX2"]: # rebuild old FX to Dict-FX2
  3373. #"off:0:0:0:16909:-:"
  3374. x = row["FX"].split(":")
  3375. print("-fx",x,len(x))
  3376. #'FX2': {'TYPE': 'sinus', 'SIZE': 200, 'SPEED': 30, 'START': 0, 'OFFSET': 2805, 'BASE': '-'}}
  3377. if len(x) >= 6:
  3378. row["FX2"]["TYPE"] = x[0]
  3379. row["FX2"]["SIZE"] = int(x[1])
  3380. row["FX2"]["SPEED"] = int(x[2])
  3381. row["FX2"]["START"] = int(x[3])
  3382. row["FX2"]["OFFSET"] = int(x[4])
  3383. row["FX2"]["BASE"] = x[5]
  3384. row["FXOLD"] = row["FX"]
  3385. row["FX"] = ""
  3386. #cprint("exec.clear()",nr,fix,row)
  3387. def get_raw_map(self,nr):
  3388. self.clean(nr)
  3389. print("get_raw_map",nr)
  3390. sdata = self.val_presets[nr]
  3391. cmd = ""
  3392. out = []
  3393. dmx=-1
  3394. for fix in sdata:
  3395. if fix == "CFG":
  3396. #print("CFG",nr,sdata[fix])
  3397. continue
  3398. for attr in sdata[fix]:
  3399. x = {}
  3400. #print("RAW",attr)
  3401. x["FIX"] = fix
  3402. x["ATTR"] = attr
  3403. x["VALUE"] = sdata[fix][attr]["VALUE"]
  3404. x["FX"] = sdata[fix][attr]["FX"]
  3405. x["FX2"] = sdata[fix][attr]["FX2"]
  3406. #x["DMX"] = sdata[fix][attr]["NR"]
  3407. out.append(x)
  3408. return out
  3409. def get_btn_txt(self,nr):
  3410. sdata=self.val_presets[nr]
  3411. BTN="go"
  3412. if "CFG" in sdata:
  3413. if "BUTTON" in sdata["CFG"]:
  3414. BTN = sdata["CFG"]["BUTTON"]
  3415. _label = self.label_presets[nr] # = label
  3416. txt=str(nr+1)+":"+str(BTN)+":"+str(len(sdata)-1)+"\n"+_label
  3417. print("get_btn_txt",nr,[txt])
  3418. return txt
  3419. def btn_cfg(self,nr,txt=None):
  3420. if nr not in self.val_presets:
  3421. return ""
  3422. if "CFG" not in self.val_presets[nr]:
  3423. self.val_presets[nr]["CFG"] = OrderedDict()
  3424. if "BUTTON" not in self.val_presets[nr]["CFG"]:
  3425. self.val_presets[nr]["CFG"]["BUTTON"] = ""
  3426. if type(txt) is str:
  3427. self.val_presets[nr]["CFG"]["BUTTON"] = txt
  3428. if self.val_presets[nr]["CFG"]["BUTTON"] is None:
  3429. self.val_presets[nr]["CFG"]["BUTTON"] = ""
  3430. print("EEE", self.val_presets[nr]["CFG"]["BUTTON"] )
  3431. return self.val_presets[nr]["CFG"]["BUTTON"]
  3432. def label(self,nr,txt=None):
  3433. if nr not in self.label_presets:
  3434. return ""
  3435. if type(txt) is str:
  3436. self.label_presets[nr] = txt
  3437. print("set label",nr,[txt])
  3438. print("??? ?? set label",nr,[txt])
  3439. return self.label_presets[nr]
  3440. def clear_move(self):
  3441. cprint("PRESETS.clear_move()",end=" ")
  3442. self.clear_copy()
  3443. def clear_copy(self):
  3444. cprint("PRESETS.clear_copy()",end=" ")
  3445. if self._last_copy is not None:
  3446. cprint("=OK=",color="red")
  3447. self._last_copy = None
  3448. else:
  3449. cprint("=NONE=",color="green")
  3450. def copy(self,nr,overwrite=1):
  3451. cprint("PRESETS._copy",nr,"last",self._last_copy)
  3452. if nr >= 0:
  3453. if self._last_copy is not None:
  3454. if modes.val("COPY"):
  3455. modes.val("COPY",3)
  3456. ok = self._copy(self._last_copy,nr,overwrite=overwrite)
  3457. return ok #ok
  3458. else:
  3459. if modes.val("COPY"):
  3460. modes.val("COPY",2)
  3461. self._last_copy = nr
  3462. cprint("PRESETS.copy START ",color="red")
  3463. return 0
  3464. return 1 # on error reset move
  3465. def _copy(self,nr_from,nr_to,overwrite=1):
  3466. cprint("PRESETS._copy",nr_from,"to",nr_to)
  3467. self.check_cfg(nr_from)
  3468. if type(self._last_copy) is None:
  3469. cprint("PRESETS._copy last nr is None",color="red")
  3470. return 0
  3471. cprint("------ PRESETS._copy", nr_from in self.val_presets , nr_to in self.val_presets)
  3472. if nr_from in self.val_presets and nr_to in self.val_presets:
  3473. fdata = self.val_presets[nr_from]
  3474. tdata = self.val_presets[nr_to]
  3475. #cprint(fdata)
  3476. flabel = self.label_presets[nr_from]
  3477. tlabel = self.label_presets[nr_to]
  3478. self.val_presets[nr_to] = copy.deepcopy(fdata)
  3479. self.label_presets[nr_to] = flabel
  3480. if not overwrite: #default
  3481. cprint("overwrite",overwrite)
  3482. self.val_presets[nr_from] = copy.deepcopy(tdata)
  3483. self.label_presets[nr_from] = tlabel
  3484. #self.label_presets[nr_from] = "MOVE"
  3485. self.clear_copy()
  3486. cprint("PRESETS.copy OK",color="green")
  3487. return 1
  3488. def move(self,nr):
  3489. cprint("PRESETS.move",self._last_copy,"to",nr)
  3490. if nr >= 0:
  3491. last = self._last_copy
  3492. if modes.val("MOVE"):
  3493. modes.val("MOVE",2)
  3494. ok= self.copy(nr,overwrite=0)
  3495. if ok and last:
  3496. if modes.val("MOVE"):
  3497. modes.val("MOVE",3)
  3498. cprint("PRESETS.move OK",color="red")
  3499. #self.delete(last)
  3500. return ok #ok
  3501. return 0 # on error reset move
  3502. def delete(self,nr):
  3503. cprint("PRESETS.delete",nr)
  3504. ok=0
  3505. if nr in self.val_presets:
  3506. self.val_presets[nr] = OrderedDict()
  3507. self.label_presets[nr] = ""
  3508. ok = 1
  3509. self.check_cfg(nr)
  3510. return ok
  3511. def rec(self,nr,data,arg=""):
  3512. cprint("rec",self,"rec()",len(data),arg)
  3513. self.check_cfg(nr)
  3514. self._check_cfg(data) #by ref
  3515. odata=self.val_presets[nr]
  3516. #print("odata",odata)
  3517. if "CFG" in odata:
  3518. if "BUTTON" in odata["CFG"]:
  3519. data["CFG"]["BUTTON"] = odata["CFG"]["BUTTON"]
  3520. self.val_presets[nr] = data
  3521. return 1
  3522. def test(a1="",a2=""):
  3523. print([a1,a2])
  3524. class FixtureEditor():
  3525. def __init__(self,dmx=1):
  3526. pass
  3527. self.elem=[]
  3528. self.dmx=dmx
  3529. print("init FixtureEditor",dmx)
  3530. def event(self,a1="",a2=""):
  3531. print([self.dmx,a1,a2])
  3532. j=[]
  3533. jdata = {'VALUE': int(a1), 'args': [] , 'FADE': 0,'DMX': str(self.dmx)}
  3534. j.append(jdata)
  3535. jclient_send(j)
  3536. class MasterWing():
  3537. def __init__(self,dmx=1):
  3538. pass
  3539. self.elem=[]
  3540. self.dmx=dmx
  3541. print("init MasterWing",dmx)
  3542. def event(self,a1="",a2=""):
  3543. print([self.dmx,a1,a2])
  3544. jdata = {'CMD': "MASTER", 'NAME': str(a1),'VALUE':str(a2) }
  3545. j=[]
  3546. j.append(jdata)
  3547. jclient_send(j)
  3548. class BufferVar():
  3549. def __init__(self,elem):
  3550. self.elem = elem
  3551. def change_dmx(self,event=""):
  3552. nr=1
  3553. txt=""
  3554. txt = tkinter.simpledialog.askstring("FADER-DMX-START",""+str(nr+1),initialvalue=txt)
  3555. print("change_dmx",[event,self])
  3556. class EXEC_FADER():
  3557. def __init__(self,frame,nr,cb=None,**args):
  3558. self.frame = frame
  3559. self.nr= nr
  3560. self.id=nr
  3561. self.elem = []
  3562. self._cb = cb
  3563. width=11
  3564. frameS = tk.Frame(self.frame,bg="#005",width=width)
  3565. frameS.pack(fill=tk.Y, side=tk.LEFT)
  3566. self.frame=frameS
  3567. def event(self,a1="",a2=""):
  3568. if self._cb is not None:
  3569. self._cb(a1,a2,nr=self.nr)
  3570. else:
  3571. print(self,"event",[self.nr,a1,a2])
  3572. j=[]
  3573. jdata = {'VALUE': int(a1), 'args': [] , 'FADE': 0,'DMX': str(self.nr)}
  3574. j.append(jdata)
  3575. jclient_send(j)
  3576. def set_attr(self,_event=None):
  3577. txt= self.attr["text"]
  3578. txt = tkinter.simpledialog.askstring("ATTR","set attr:",initialvalue=txt)
  3579. self._set_attr(txt)
  3580. def _set_attr(self,txt=""):
  3581. if type(txt) is str:
  3582. self.attr["text"] = "{}".format(txt)
  3583. print("_set_attr",[self])
  3584. def set_label(self,name=""):
  3585. #print("set_label",self.b,name)
  3586. self.label["text"] = name
  3587. def set_mode(self,_event=None):
  3588. txt= self.mode["text"]
  3589. txt = tkinter.simpledialog.askstring("MODE S/F:","SWITCH or FADE",initialvalue=txt)
  3590. w = GUIWindow("config",master=1,width=200,height=140,left=L1,top=TOP)
  3591. #w.pack()
  3592. self._set_mode(txt)
  3593. w.show()
  3594. def _set_mode(self,txt=""):
  3595. if type(txt) is str:
  3596. self.mode["text"] = "{}".format(txt[0].upper())
  3597. print("_set_attr",[self])
  3598. def _refresh(self):
  3599. pass
  3600. def pack(self,init=None,from_=255,to=0,**args):
  3601. width=11
  3602. r=0
  3603. c=0
  3604. j=0
  3605. font8 = ("FreeSans",8)
  3606. frameS=self.frame
  3607. self.b = tk.Scale(frameS,bg="lightblue", width=18,from_=from_,to=to,command=self.event)
  3608. self.b.pack(fill=tk.Y, side=tk.TOP)
  3609. if init is not None:
  3610. self.b.set(init)
  3611. self.elem.append(self.b)
  3612. self.b = tk.Button(frameS,bg="lightblue",text="{}".format(self.nr), width=5,command=test,font=font8 )
  3613. self.b.pack(fill=tk.BOTH, side=tk.TOP)
  3614. self.label = self.b
  3615. if 1: #self.nr <= 10:
  3616. self.elem.append(self.b)
  3617. self.b = tk.Button(frameS,bg="lightblue",text="", width=5,command=self.set_attr,font=font8 )
  3618. self.attr=self.b
  3619. self.b.pack(fill=tk.BOTH, side=tk.TOP)
  3620. self.elem.append(self.b)
  3621. f = tk.Frame(frameS)
  3622. ##f.pack()
  3623. #self.b = tk.Button(f,bg="lightblue",text="<+", width=1,command=self.set_mode,font=font8 )
  3624. #self.mode=self.b
  3625. ##self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3626. #self.elem.append(self.b)
  3627. #self.b = tk.Button(frameS,bg="lightblue",text="F", width=4,command=self.set_mode,font=font8 )
  3628. #self.mode=self.b
  3629. #self.b.pack(fill=tk.BOTH, side=tk.TOP)
  3630. ##self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3631. #self.elem.append(self.b)
  3632. #self.b = tk.Button(f,bg="lightblue",text="+>", width=1,command=self.set_mode,font=font8 )
  3633. #self.mode=self.b
  3634. ##self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3635. #self.elem.append(self.b)
  3636. self.b = tk.Label(frameS,bg="black",text="", width=4,font=font8 )
  3637. self.b.pack(fill=tk.BOTH, side=tk.TOP)
  3638. self.elem.append(self.b)
  3639. class ELEM_FADER():
  3640. def __init__(self,frame,nr,cb=None,**args):
  3641. self.frame = frame
  3642. self.nr= nr
  3643. self.id=nr
  3644. self.elem = []
  3645. self._cb = cb
  3646. width=11
  3647. frameS = tk.Frame(self.frame,bg="#005",width=width)
  3648. frameS.pack(fill=tk.Y, side=tk.LEFT)
  3649. self.frame=frameS
  3650. def event(self,a1="",a2=""):
  3651. if self._cb is not None:
  3652. self._cb(a1,a2,nr=self.nr)
  3653. else:
  3654. print(self,"event",[self.nr,a1,a2])
  3655. j=[]
  3656. jdata = {'VALUE': int(a1), 'args': [] , 'FADE': 0,'DMX': str(self.nr)}
  3657. j.append(jdata)
  3658. jclient_send(j)
  3659. def set_attr(self,_event=None):
  3660. txt= self.attr["text"]
  3661. txt = tkinter.simpledialog.askstring("ATTR","set attr:",initialvalue=txt)
  3662. self._set_attr(txt)
  3663. def _set_attr(self,txt=""):
  3664. if type(txt) is str:
  3665. self.attr["text"] = "{}".format(txt)
  3666. print("_set_attr",[self])
  3667. def set_label(self,name=""):
  3668. #print("set_label",self.b,name)
  3669. self.label["text"] = name
  3670. def set_mode(self,_event=None):
  3671. txt= self.mode["text"]
  3672. txt = tkinter.simpledialog.askstring("MODE S/F:","SWITCH or FADE",initialvalue=txt)
  3673. w = GUIWindow("config",master=1,width=200,height=140,left=L1,top=TOP)
  3674. #w.pack()
  3675. self._set_mode(txt)
  3676. w.show()
  3677. def _set_mode(self,txt=""):
  3678. if type(txt) is str:
  3679. self.mode["text"] = "{}".format(txt[0].upper())
  3680. print("_set_attr",[self])
  3681. def _refresh(self):
  3682. pass
  3683. def pack(self,init=None,from_=255,to=0,**args):
  3684. width=11
  3685. r=0
  3686. c=0
  3687. j=0
  3688. font8 = ("FreeSans",8)
  3689. frameS=self.frame
  3690. self.b = tk.Scale(frameS,bg="lightblue", width=18,from_=from_,to=to,command=self.event)
  3691. self.b.pack(fill=tk.Y, side=tk.TOP)
  3692. if init is not None:
  3693. self.b.set(init)
  3694. self.elem.append(self.b)
  3695. self.b = tk.Button(frameS,bg="lightblue",text="{}".format(self.nr), width=4,command=test,font=font8 )
  3696. self.b.pack(fill=tk.BOTH, side=tk.TOP)
  3697. self.label = self.b
  3698. self.elem.append(self.b)
  3699. self.b = tk.Button(frameS,bg="lightblue",text="", width=5,command=self.set_attr,font=font8 )
  3700. self.attr=self.b
  3701. self.b.pack(fill=tk.BOTH, side=tk.TOP)
  3702. self.elem.append(self.b)
  3703. f = tk.Frame(frameS)
  3704. #f.pack()
  3705. self.b = tk.Button(f,bg="lightblue",text="<+", width=1,command=self.set_mode,font=font8 )
  3706. self.mode=self.b
  3707. #self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3708. self.elem.append(self.b)
  3709. self.b = tk.Button(frameS,bg="lightblue",text="F", width=4,command=self.set_mode,font=font8 )
  3710. self.mode=self.b
  3711. self.b.pack(fill=tk.BOTH, side=tk.TOP)
  3712. #self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3713. self.elem.append(self.b)
  3714. self.b = tk.Button(f,bg="lightblue",text="+>", width=1,command=self.set_mode,font=font8 )
  3715. self.mode=self.b
  3716. #self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3717. self.elem.append(self.b)
  3718. self.b = tk.Label(frameS,bg="black",text="", width=4,font=font8 )
  3719. self.b.pack(fill=tk.BOTH, side=tk.TOP)
  3720. self.elem.append(self.b)
  3721. class GUI_ExecWingLayout():
  3722. def __init__(self,root,data,title="tilte",width=800,start=81):
  3723. #xfont = tk.font.Font(family="FreeSans", size=5, weight="bold")
  3724. font8 = ("FreeSans",8)
  3725. self.dmx=1
  3726. self.univ=0
  3727. self.start=start-1
  3728. r=0
  3729. c=0
  3730. i=1
  3731. self.elem=[]
  3732. self.header=[]
  3733. self.data = data
  3734. #self.frame = tk.Frame(root,bg="black",width=width)
  3735. #self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3736. #self.b = tk.Label(self.frame,bg="#fff",text="Master Wing") #,font=font8 )
  3737. #self.b.pack(fill=None, side=tk.LEFT)
  3738. #self.frame = tk.Frame(root,bg="black",width=width)
  3739. #self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3740. #self.b = tk.Label(self.frame,bg="black",text="") # spacer
  3741. #self.b.pack(fill=tk.Y, side=tk.LEFT)
  3742. self.frame = tk.Frame(root,bg="magenta",width=width,border=2) # fader frame
  3743. self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3744. r=0
  3745. c=0
  3746. pb=10
  3747. self.pb=pb
  3748. for j,row in enumerate(data):
  3749. if c % pb == 0 or c==0:
  3750. h=hex(j*10)[2:].rjust(2,"0")
  3751. frameS = tk.Frame(self.frame,bg="#000",width=width,border=2)
  3752. frameS.pack(fill=tk.BOTH, side=tk.TOP)
  3753. p=j//pb+1
  3754. if j < 10:
  3755. txt="x-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb)
  3756. else:
  3757. txt="x-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb)
  3758. self.b = tk.Label(frameS,bg="lightblue",text=txt,width=25,font=font8 )
  3759. self.header.append(self.b)
  3760. self.b.pack(fill=None, side=tk.LEFT)
  3761. self.b = tk.Label(frameS,bg="black",text="" ,width=11,font=font8 )
  3762. self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3763. try:
  3764. frameS = tk.Frame(self.frame,bg="#a000{}".format(h),width=width,border=2)
  3765. except:
  3766. frameS = tk.Frame(self.frame,bg="#a0aadd",width=width,border=2)
  3767. c=0
  3768. #print(frameS)
  3769. #e= ELEM_FADER(frameS,nr=j+1,cb=self.event_cb)
  3770. e= EXEC_FADER(frameS,nr=j+1,cb=self.event_cb)
  3771. if j >= 10:
  3772. e.pack(from_=400,to=0,init=100)
  3773. else:
  3774. e.pack(from_=200,to=0,init=100)
  3775. self.elem.append(e)
  3776. frameS.pack(fill=tk.X, side=tk.TOP)
  3777. c+=1
  3778. i+=1
  3779. self.frame.pack()
  3780. self._event_redraw()
  3781. def set_fader(self,val):
  3782. print("set_fader",val)
  3783. for i in self.elem:
  3784. e = i #self.elem[i] #.append(e)
  3785. #print("e",e)
  3786. ee = e.elem[0]
  3787. #print(dir(ee))
  3788. ee.set(val)# = val
  3789. #for ee in e.elem: #.append(self.b)
  3790. # print("ee",ee)
  3791. def event_cb(self,a1="",a2="",nr=None,**args):
  3792. print("event_cb:",nr,a1,a2,args)
  3793. nr += 1
  3794. jdata= {"CMD":"X-MASTER","NR":nr,"VALUE":int(a1)}
  3795. if nr >= 1 and nr <= 10:
  3796. jdata["CMD"] = "EXEC-SIZE-MASTER"
  3797. jdata["NR"] = nr +self.start
  3798. if nr >= 11 and nr <= 20:
  3799. jdata["CMD"] = "EXEC-SPEED-MASTER"
  3800. jdata["NR"] = nr-10 +self.start
  3801. if nr >= 21 and nr <= 30:
  3802. jdata["CMD"] = "EXEC-OFFSET-MASTER"
  3803. jdata["NR"] = nr-20 +self.start
  3804. print("event_cb",jdata)
  3805. j = [jdata]
  3806. jclient_send(j)
  3807. def set_name(self,_event=None):
  3808. txt = self.name["text"]
  3809. txt = tkinter.simpledialog.askstring("FIXTURE NAME:","NAME:",initialvalue=txt)
  3810. self.name["text"] = "{}".format(txt)
  3811. print("change_dmx",[_event,self])
  3812. def event_value(self,_event=None):
  3813. nr=self.dmx
  3814. txt= self.entry_dmx["text"]
  3815. def _event_redraw(self,_event=None):
  3816. nr = 0
  3817. print("change_dmx",[_event,self])
  3818. for i,btn in enumerate(self.elem):
  3819. btn.set_label("{} D:{}".format(i+1,nr))
  3820. btn.nr = nr+i
  3821. pb=self.pb
  3822. for j,e in enumerate(self.header):
  3823. p=j+1
  3824. #p=nr/pb
  3825. if p == 1:
  3826. txt="SIZE-MASTER:{} {}-{}".format(p,1+self.start,10+self.start)#p*pb-pb+1,p*pb)
  3827. elif p == 2:
  3828. txt="SPEED-MASTER:{} {}-{}".format(p,1+self.start,10+self.start)#p*pb-pb+1,p*pb)
  3829. elif p == 3:
  3830. txt="OFFSET-MASTER:{} {}-{}".format(p,1+self.start,10+self.start)#p*pb-pb+1,p*pb)
  3831. else:
  3832. txt="X-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb)
  3833. #txt="BANK:{} {}-{}".format(p,p*pb-pb+nr,p*pb+nr)
  3834. print("---",j,txt,e)
  3835. e["text"] = txt
  3836. class GUI_MasterWingLayout():
  3837. def __init__(self,root,data,title="tilte",width=800):
  3838. #xfont = tk.font.Font(family="FreeSans", size=5, weight="bold")
  3839. font8 = ("FreeSans",8)
  3840. self.dmx=1
  3841. self.univ=0
  3842. r=0
  3843. c=0
  3844. i=1
  3845. self.elem=[]
  3846. self.header=[]
  3847. self.data = data
  3848. #self.frame = tk.Frame(root,bg="black",width=width)
  3849. #self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3850. #self.b = tk.Label(self.frame,bg="#fff",text="Master Wing") #,font=font8 )
  3851. #self.b.pack(fill=None, side=tk.LEFT)
  3852. #self.frame = tk.Frame(root,bg="black",width=width)
  3853. #self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3854. #self.b = tk.Label(self.frame,bg="black",text="") # spacer
  3855. #self.b.pack(fill=tk.Y, side=tk.LEFT)
  3856. self.frame = tk.Frame(root,bg="magenta",width=width,border=2) # fader frame
  3857. self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3858. r=0
  3859. c=0
  3860. pb=1
  3861. self.pb=pb
  3862. for j,row in enumerate(data):
  3863. if c % pb == 0 or c==0:
  3864. h=hex(j*10)[2:].rjust(2,"0")
  3865. frameS = tk.Frame(self.frame,bg="#000",width=width,border=2)
  3866. frameS.pack(fill=tk.BOTH, side=tk.TOP)
  3867. p=j//pb+1
  3868. if j < 1:
  3869. txt="x-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb)
  3870. else:
  3871. txt="x-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb)
  3872. self.b = tk.Label(frameS,bg="lightblue",text=txt,width=25,font=font8 )
  3873. self.header.append(self.b)
  3874. self.b.pack(fill=None, side=tk.LEFT)
  3875. self.b = tk.Label(frameS,bg="black",text="" ,width=11,font=font8 )
  3876. self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3877. try:
  3878. frameS = tk.Frame(self.frame,bg="#a000{}".format(h),width=width,border=2)
  3879. except:
  3880. frameS = tk.Frame(self.frame,bg="#a0aadd",width=width,border=2)
  3881. c=0
  3882. #print(frameS)
  3883. e= ELEM_FADER(frameS,nr=j+1,cb=self.event_cb)
  3884. if j >= 2:
  3885. e.pack(from_=400,to=0,init=100)
  3886. else:
  3887. e.pack(from_=200,to=0,init=100)
  3888. self.elem.append(e)
  3889. frameS.pack(fill=tk.X, side=tk.TOP)
  3890. c+=1
  3891. i+=1
  3892. self.frame.pack()
  3893. self._event_redraw()
  3894. def event_cb(self,a1="",a2="",nr=None,**args):
  3895. print("event_cb:",nr,a1,a2,args)
  3896. nr += 1
  3897. jdata= {"CMD":"X-MASTER","NR":nr,"VALUE":int(a1)}
  3898. if nr == 1:
  3899. jdata["CMD"] = "SIZE-MASTER"
  3900. jdata["NR"] = 1 #nr
  3901. if nr == 2:
  3902. jdata["CMD"] = "SPEED-MASTER"
  3903. jdata["NR"] = 1 #nr
  3904. print("event_cb",jdata)
  3905. j = [jdata]
  3906. jclient_send(j)
  3907. def set_name(self,_event=None):
  3908. txt = self.name["text"]
  3909. txt = tkinter.simpledialog.askstring("FIXTURE NAME:","NAME:",initialvalue=txt)
  3910. self.name["text"] = "{}".format(txt)
  3911. print("change_dmx",[_event,self])
  3912. def event_value(self,_event=None):
  3913. nr=self.dmx
  3914. txt= self.entry_dmx["text"]
  3915. def _event_redraw(self,_event=None):
  3916. nr = 0
  3917. print("change_dmx",[_event,self])
  3918. for i,btn in enumerate(self.elem):
  3919. btn.set_label("{} D:{}".format(i+1,nr))
  3920. btn.nr = nr+i
  3921. pb=self.pb
  3922. for j,e in enumerate(self.header):
  3923. p=j+1
  3924. #p=nr/pb
  3925. if p == 1:
  3926. txt="SIZE-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb)
  3927. else:
  3928. txt="SPEED-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb)
  3929. #txt="BANK:{} {}-{}".format(p,p*pb-pb+nr,p*pb+nr)
  3930. print("---",j,txt,e)
  3931. e["text"] = txt
  3932. class GUI_FaderLayout():
  3933. def __init__(self,root,data,title="tilte",width=800):
  3934. #xfont = tk.font.Font(family="FreeSans", size=5, weight="bold")
  3935. font8 = ("FreeSans",8)
  3936. self.dmx=1
  3937. self.univ=0
  3938. r=0
  3939. c=0
  3940. i=1
  3941. self.elem=[]
  3942. self.header=[]
  3943. self.data = data
  3944. self.frame = tk.Frame(root,bg="black",width=width)
  3945. self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3946. self.b = tk.Label(self.frame,bg="#fff",text="Fixture Editor") #,font=font8 )
  3947. self.b.pack(fill=None, side=tk.LEFT)
  3948. self.frame = tk.Frame(root,bg="black",width=width)
  3949. self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3950. self.b = tk.Label(self.frame,bg="#ddd",text="NAME:")
  3951. self.b.pack(fill=None, side=tk.LEFT)
  3952. self.b = tk.Button(self.frame,bg="lightblue",text="MAC-500", width=11)
  3953. self.name=self.b
  3954. self.b["command"] = self.set_name
  3955. self.b.pack( side=tk.LEFT)
  3956. self.b = tk.Label(self.frame,bg="lightblue",text="UNIV:")
  3957. self.b.pack(fill=None, side=tk.LEFT)
  3958. self.b_univ = tk.Button(self.frame,bg="lightblue",text="1", width=4)#,command=self.event) #bv.change_dmx)
  3959. self.entry_univ=self.b_univ
  3960. self.b_univ["command"] = self.event_univ
  3961. self.b_univ.pack( side=tk.LEFT)
  3962. self.b = tk.Label(self.frame,bg="lightblue",text="DMX:")
  3963. self.b.pack(fill=None, side=tk.LEFT)
  3964. self.b = tk.Button(self.frame,bg="lightblue",text="1", width=4)#,command=self.event) #bv.change_dmx)
  3965. self.entry_dmx=self.b
  3966. self.b["command"] = self.event_dmx
  3967. self.b.pack( side=tk.LEFT)
  3968. self.b_xdmx = tk.Label(self.frame,bg="lightgreen",text="5")
  3969. self.b_xdmx.pack(fill=None, side=tk.LEFT)
  3970. self.b = tk.Label(self.frame,bg="#ddd",text="TYPE:")
  3971. self.b.pack(fill=None, side=tk.LEFT)
  3972. self.b = tk.Button(self.frame,bg="lightblue",text="LIST", width=5)#,command=self.event) #bv.change_dmx)
  3973. self.b["command"] = self.open_fixture_list
  3974. self.b.pack( side=tk.LEFT)
  3975. self.b = tk.Label(self.frame,bg="black",text="") # spacer
  3976. self.b.pack(fill=tk.Y, side=tk.LEFT)
  3977. self.frame = tk.Frame(root,bg="magenta",width=width,border=2) # fader frame
  3978. self.frame.pack(fill=tk.BOTH, side=tk.TOP)
  3979. r=0
  3980. c=0
  3981. pb=12
  3982. self.pb=pb
  3983. for j,row in enumerate(data):
  3984. if c % pb == 0 or c==0:
  3985. h=hex(j*10)[2:].rjust(2,"0")
  3986. frameS = tk.Frame(self.frame,bg="#000",width=width,border=2)
  3987. frameS.pack(fill=tk.BOTH, side=tk.TOP)
  3988. p=j//pb+1
  3989. txt="BANK:{} {}-{}".format(p,p*pb-pb+1,p*pb)
  3990. self.b = tk.Label(frameS,bg="lightblue",text=txt,width=15,font=font8 )
  3991. self.header.append(self.b)
  3992. self.b.pack(fill=None, side=tk.LEFT)
  3993. self.b = tk.Label(frameS,bg="black",text="" ,width=11,font=font8 )
  3994. self.b.pack(fill=tk.BOTH, side=tk.LEFT)
  3995. try:
  3996. frameS = tk.Frame(self.frame,bg="#a000{}".format(h),width=width,border=2)
  3997. except:
  3998. frameS = tk.Frame(self.frame,bg="#a0aadd",width=width,border=2)
  3999. c=0
  4000. #print(frameS)
  4001. e= ELEM_FADER(frameS,nr=j+1)
  4002. e.pack()
  4003. self.elem.append(e)
  4004. frameS.pack(fill=tk.X, side=tk.TOP)
  4005. c+=1
  4006. i+=1
  4007. self.frame.pack()
  4008. self._event_redraw()
  4009. def set_name(self,_event=None):
  4010. txt = self.name["text"]
  4011. txt = tkinter.simpledialog.askstring("FIXTURE NAME:","NAME:",initialvalue=txt)
  4012. self.name["text"] = "{}".format(txt)
  4013. print("change_dmx",[_event,self])
  4014. def open_fixture_list(self):
  4015. name = "FIXTURE-LIB"
  4016. line1="Fixture Library"
  4017. line2="CHOOS to EDIT >> DEMO MODUS"
  4018. cb = LOAD_FIXTURE
  4019. #cb.master=self
  4020. pw = PopupList(name,cb=cb,left=_POS_LEFT+820,bg="red")
  4021. frame = pw.sframe(line1=line1,line2=line2)
  4022. r=_load_fixture_list(frame,cb=cb,master=self,bg="red")
  4023. #self.elem["bg"] = "red"
  4024. #self.elem.config(activebackground="red")
  4025. #w.tk.attributes('-topmost',False)
  4026. def load_EMPTY(self,_event=None,attr=[]):
  4027. #attr = [,"RED","GREEN","BLUE"]
  4028. #mode = ["F","F","F","F"]
  4029. self._load_mh(None)#,attr,mode)
  4030. def load_DIM(self,_event=None,attr=[]):
  4031. attr = ["DIM"]
  4032. mode = ["F"]
  4033. self._load_fix(None,attr,mode)
  4034. def load_LED(self,_event=None,attr=[]):
  4035. attr = ["DIM","RED","GREEN","BLUE"]
  4036. mode = ["F","F","F","F"]
  4037. self._load_fix(None,attr,mode)
  4038. def load_MH(self,_event=None,attr=[]):
  4039. attr = ["PAN","PAN-FINE","TILT","TILT-FINE","SHUTTER","DIM","RED","GREEN","BLUE","GOBO"]
  4040. mode = ["F","F","F","F","S","F","F","F","F","S"]
  4041. self._load_fix(None,attr,mode)
  4042. def load_MH2(self,_event=None,attr=[]):
  4043. attr = ["PAN","PAN-FINE","TILT","TILT-FINE","SHUTTER","DIM","RED","GREEN","BLUE","GOBO","G-ROT","PRISM","P-ROT","ZOOM","CONTR"]
  4044. mode = ["F","F","F","F","S","F","F","F","F","S","S","S","S","F","S"]
  4045. self._load_fix(None,attr,mode)
  4046. def _load_fix(self,_event=None,attr=[],mode=[]):
  4047. print("load_fixture",[_event,self])
  4048. #for i,e in enumerate(self.elem):
  4049. for i,e in enumerate(self.elem):
  4050. #print(self,"event",_event,e)
  4051. print("event",_event,e)
  4052. e._set_attr( "---")
  4053. if len(attr) > i:
  4054. e._set_attr( attr[i])
  4055. e._set_mode( "---")
  4056. if len(mode) > i:
  4057. e._set_mode( mode[i])
  4058. def event_univ(self,_event=None):
  4059. nr=self.univ
  4060. txt= self.entry_univ["text"]
  4061. txt = tkinter.simpledialog.askstring("Universe","Univ 0-15",initialvalue=txt)
  4062. try:
  4063. nr = int(txt)
  4064. except TypeError:
  4065. print("--- abort ---")
  4066. return 0
  4067. self.univ = nr
  4068. self._event_redraw(_event)
  4069. def event_dmx(self,_event=None):
  4070. nr=self.dmx
  4071. txt= self.entry_dmx["text"]
  4072. txt = tkinter.simpledialog.askstring("DMX","ArtNet 1-512 (7680 max)",initialvalue=txt)
  4073. try:
  4074. nr = int(txt)
  4075. except TypeError:
  4076. print("--- abort ---")
  4077. return 0
  4078. self.dmx = nr
  4079. if self.dmx <= 0:
  4080. self.dmx = 1
  4081. if self.dmx > 512:
  4082. self.univ = (self.dmx-1)//512
  4083. self.dmx = (self.dmx-1)%512+1
  4084. self._event_redraw(_event)
  4085. def _event_redraw(self,_event=None):
  4086. self.entry_dmx["text"] = "{}".format(self.dmx)
  4087. self.entry_univ["text"] = "{}".format(self.univ)
  4088. nr = self.univ*(512)+self.dmx
  4089. self.b_xdmx["text"] = " {} ".format(nr)
  4090. print("change_dmx",[_event,self])
  4091. for i,btn in enumerate(self.elem):
  4092. #print("event",_event,btn)
  4093. #print("btn",btn)
  4094. dmx=nr+i
  4095. nr2 = dmx%512
  4096. btn.set_label("{} D:{}\n{}.{}".format(i+1,dmx,self.univ,nr2))
  4097. btn.nr = nr+i
  4098. pb=self.pb
  4099. for j,e in enumerate(self.header):
  4100. p=j+1
  4101. #p=nr/pb
  4102. txt="BANK:{} {}-{}".format(p,p*pb-pb+nr,p*pb+nr)
  4103. print("---",j,txt,e)
  4104. e["text"] = txt
  4105. class GUI_grid():
  4106. def __init__(self,root,data,title="tilte",width=800):
  4107. self.data = data
  4108. self.frame = tk.Frame(root,bg="black",width=width)
  4109. self.frame.pack(fill=tk.BOTH, side=tk.LEFT)
  4110. r=0
  4111. c=0
  4112. i=1
  4113. for row in data:
  4114. self.b = tk.Button(self.frame,bg="lightblue", text=row["text"],width=11,height=4)
  4115. #self.b.bind("<Button>",Xevent(fix=fix,elem=b).cb)
  4116. self.b.grid(row=r, column=c, sticky=tk.W+tk.E)#,anchor="w")
  4117. c+=1
  4118. if c % 8 == 0:
  4119. r+=1
  4120. c=0
  4121. i+=1
  4122. self.frame.pack()
  4123. class BEvent():
  4124. def __init__(self,data,cb):
  4125. self._data = data
  4126. self._cb = cb
  4127. def cb(self,event):
  4128. #print(self,event)
  4129. self._cb(event,self._data)
  4130. class GUI_menu():
  4131. def __init__(self,root,data,title="tilte",width=800):
  4132. global tk
  4133. self.data = data
  4134. self.data2 = {}
  4135. self.frame = tk.Frame(root,bg="black",width=width)
  4136. self.frame.pack(fill=tk.BOTH, side=tk.LEFT)
  4137. r=0
  4138. c=0
  4139. i=1
  4140. self.b = tk.Label(self.frame,bg="lightblue", text="MAIN:MENU",width=8,height=1)
  4141. self.b.grid(row=r, column=c, sticky=tk.W+tk.E)#,anchor="w")
  4142. r+=1
  4143. for row in data:
  4144. #print(i)
  4145. #row = data[i]
  4146. self.b = tk.Button(self.frame,bg="lightgrey", text=row["text"],width=8,height=2)
  4147. self.b.bind("<Button>",BEvent({"NR":i,"text":row["text"]},self.callback).cb)
  4148. self.b.grid(row=r, column=c, sticky=tk.W+tk.E)#,anchor="w")
  4149. row["elem"] = self.b
  4150. self.data2[row["text"]] = row
  4151. r+=1
  4152. i+=1
  4153. self.frame.pack()
  4154. def callback(self,event,data={}):
  4155. print("callback543",self,event,data)
  4156. window_manager.top(data["text"])# = WindowManager()
  4157. def update(self,button,text):
  4158. #print(self,button,text)
  4159. for k in self.data2:
  4160. v=self.data2[k]
  4161. #print(self,k,v)
  4162. if button == k:
  4163. v["elem"]["text"] = k+"\n"+text
  4164. def config(self,button,attr,value):
  4165. #print("config",self,button,attr,value)
  4166. for k in self.data2:
  4167. v=self.data2[k]
  4168. #print(self,k,v)
  4169. if button == k:
  4170. #print(dir(v["elem"]))
  4171. if attr == "bg":
  4172. if value == "":
  4173. value = "lightgrey"
  4174. v["elem"][attr] = str(value)
  4175. if attr == "activebackground":
  4176. if value == "":
  4177. value = "lightgrey"
  4178. v["elem"][attr] = str(value)
  4179. lf_nr = 0
  4180. from tkinter import PhotoImage
  4181. _shift_key = 0
  4182. class GUIWindow():
  4183. def __init__(self,title="tilte",master=0,width=100,height=100,left=None,top=None,exit=0,cb=None):
  4184. global lf_nr
  4185. #ico_path="/opt/LibreLight/Xdesk/icon/"
  4186. ico_path="./icon/"
  4187. self.cb = cb
  4188. if master:
  4189. self.tk = tkinter.Tk()
  4190. self.tk.withdraw() # do not draw
  4191. defaultFont = tkinter.font.nametofont("TkDefaultFont")
  4192. print(defaultFont)
  4193. defaultFont.configure(family="FreeSans",
  4194. size=10,
  4195. weight="bold")
  4196. #self.tk.option_add("*Font", FontBold)
  4197. # MAIN MENUE
  4198. try:
  4199. self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"main.png"))
  4200. except Exception as e:
  4201. print("Exception GUIWindow.__init__",e)
  4202. else:
  4203. # addtional WINDOW
  4204. self.tk = tkinter.Toplevel()
  4205. self.tk.withdraw() # do not draw
  4206. self.tk.protocol("WM_DELETE_WINDOW", self.close_app_win)
  4207. try:
  4208. if "COLORPICKER" in title:
  4209. self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"picker.png"))
  4210. elif "ENCODER" in title:
  4211. self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"enc.png"))
  4212. elif "EXEC" in title:
  4213. self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"exec.png"))
  4214. elif "FX" in title:
  4215. self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"fx.png"))
  4216. else:
  4217. self.tk.iconphoto(False, tk.PhotoImage(file=ico_path+"scribble.png"))
  4218. except Exception as e:
  4219. print("Exception on load window icon",title)
  4220. print("Exception:",e)
  4221. self.tk["bg"] = "black"
  4222. self.tk.bind("<Button>",self.callback)
  4223. self.tk.bind("<Key>",self.callback)
  4224. self.tk.bind("<KeyRelease>",self.callback)
  4225. self.tk.title(""+str(title)+" "+str(lf_nr)+":"+str(rnd_id))
  4226. lf_nr+=1
  4227. #self.tk.geometry("270x600+0+65")
  4228. geo ="{}x{}".format(width,height)
  4229. if left is not None:
  4230. geo += "+{}".format(left)
  4231. if top is not None:
  4232. geo += "+{}".format(top)
  4233. #self._event_clear = Xevent(fix=0,elem=None,attr="CLEAR",data=self,mode="ROOT").cb
  4234. self.tk.geometry(geo)
  4235. self.show()
  4236. def update_idle_task(self):
  4237. tkinter.Tk.update_idletasks(gui_menu_gui.tk)
  4238. pass
  4239. def close_app_win(self,event=None):
  4240. print("close_app_win",self,event)
  4241. if exit:
  4242. #self.tk.quit()
  4243. self.tk.destroy()
  4244. #for i in dir(self.tk):
  4245. # print("i",i)
  4246. try:
  4247. self.cb("<exit>").cb()
  4248. except Exception as e:
  4249. print("EXCETPION close_app",e)
  4250. def title(self,title=None):
  4251. if title is None:
  4252. return self.tk.title()
  4253. else:
  4254. #return self.tk.title(title)
  4255. return self.tk.title(""+str(title)+" "+str(lf_nr)+":"+str(rnd_id))
  4256. def show(self):
  4257. self.tk.deiconify()
  4258. pass
  4259. def mainloop(self):
  4260. try:
  4261. self.tk.mainloop()
  4262. finally:
  4263. self.tk.quit()
  4264. def callback(self,event,data={}):#value=255):
  4265. global _shift_key
  4266. print()
  4267. print()
  4268. #cprint("<GUI>",event,color="yellow")
  4269. #cprint("<GUI>",event.state,data,[event.type],color="yellow")
  4270. value = 255
  4271. if "Release" in str(event.type) or str(event.type) == '5' or str(event.type) == '3':
  4272. value = 0
  4273. if "keysym" in dir(event):
  4274. if "Escape" == event.keysym:
  4275. FIXTURES.clear()
  4276. modes.val("ESC",1)
  4277. master.refresh_fix()
  4278. elif event.keysym in ["Shift_L","Shift_R"]:
  4279. #cprint(event.type)
  4280. if "KeyRelease" in str(event.type) or str(event.type) in ["3"]:
  4281. _shift_key = 0
  4282. else:
  4283. _shift_key = 1
  4284. #cprint("SHIFT_KEY",_shift_key,"??????????")
  4285. #cprint("SHIFT_KEY",_shift_key,"??????????")
  4286. global _ENCODER_WINDOW
  4287. if _shift_key:
  4288. _ENCODER_WINDOW.title("SHIFT/FINE ")
  4289. else:
  4290. _ENCODER_WINDOW.title("ENCODER")
  4291. elif event.keysym in "ebfclrms" and value:
  4292. if "e" == event.keysym:
  4293. modes.val("EDIT",1)
  4294. elif "b" == event.keysym:
  4295. modes.val("BLIND",1)
  4296. elif "f" == event.keysym:
  4297. modes.val("FLASH",1)
  4298. elif "c" == event.keysym:
  4299. modes.val("CFG-BTN",1)
  4300. elif "l" == event.keysym:
  4301. modes.val("LABEL",1)
  4302. elif "r" == event.keysym:
  4303. modes.val("REC",1)
  4304. elif "m" == event.keysym:
  4305. x=modes.val("MOVE",1)
  4306. if not x:
  4307. PRESETS.clear_move()
  4308. elif "s" == event.keysym:
  4309. modes.val("SELECT",1)
  4310. elif event.keysym in ["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]:
  4311. nr = int( event.keysym[1])
  4312. nr = nr-1+81
  4313. cprint("F-KEY",value,nr)
  4314. master.preset_go(nr-1,xfade=None,val=value)
  4315. elif event.keysym in ["1","2","3","4","5","6","7","8","9","0"]:
  4316. nr = int( event.keysym)
  4317. if nr == 0:
  4318. nr = 10
  4319. nr = nr-1+161
  4320. cprint("NUM-KEY",value,nr)
  4321. master.preset_go(nr-1,xfade=None,val=value)
  4322. elif "End" == event.keysym:
  4323. FIXTURES.fx_off("all")
  4324. CONSOLE.fx_off("all")
  4325. CONSOLE.flash_off("all")
  4326. elif "Delete" == event.keysym:
  4327. #PRESETS.delete(nr)
  4328. if value:
  4329. modes.val("DEL",1)
  4330. class WindowManager():
  4331. def __init__(self):
  4332. self.windows = {}
  4333. self.obj = {}
  4334. self.nr= 0
  4335. self.first=""
  4336. def new(self,w,name="",obj=None):
  4337. if not self.first:
  4338. if name:
  4339. self.first = name
  4340. else:
  4341. self.first = str(self.nr)
  4342. w.tk.attributes('-topmost',True)
  4343. if name:
  4344. self.windows[str(name)] = w
  4345. self.obj[str(name)] = obj
  4346. else:
  4347. self.windows[str(self.nr)] = w
  4348. self.obj[str(self.nr)] = obj
  4349. self.nr+=1
  4350. #w.show()
  4351. def mainloop(self):
  4352. self.windows[self.first].mainloop()
  4353. def get(self,name):
  4354. print(self,".get(name) =",name)
  4355. name = str(name)
  4356. if name in self.windows:
  4357. out = self.windows[name]
  4358. print(out)
  4359. return out
  4360. def get_obj(self,name):
  4361. print(self,".get(name) =",name)
  4362. name = str(name)
  4363. if name in self.windows:
  4364. out = self.obj[name]
  4365. print(out)
  4366. return out
  4367. def top(self,name):
  4368. name = str(name)
  4369. if name in self.windows:
  4370. self.windows[name].tk.attributes('-topmost',True)
  4371. self.windows[name].tk.attributes('-topmost',False)
  4372. #print("redraw",name)
  4373. #if name == "PATCH":
  4374. # gui_patch.draw()
  4375. #if name == "DIMMER":
  4376. # gui_fix.draw()
  4377. else:
  4378. print(name,"not in self.windows",self.windows.keys())
  4379. class Console():
  4380. def __init__(self):
  4381. pass
  4382. def flash_off(self,fix):
  4383. pass#client.send("df0:alloff:::,")
  4384. def fx_off(self,fix):
  4385. cprint("Console.fx_off()",fix)
  4386. if not fix or fix == "all":
  4387. #client.send("fx0:alloff:,fxf:alloff:,")
  4388. #client.send("df0:alloff:::,")
  4389. j = []
  4390. if 0:
  4391. jdata = {'VALUE': None, 'args': [], 'FX': 'alloff::::', 'FADE': 2, 'DMX': '0'}
  4392. j.append(jdata)
  4393. jdata = {'VALUE': None, 'args': [], 'FX': 'alloff::::', 'FADE': 2,'FLASH':1, 'DMX': '0'}
  4394. j.append(jdata)
  4395. else:
  4396. jdata = {'VALUE': None, 'args': [], 'FX2': {"TYPE":"alloff"}, 'FADE': 2,'FLASH':1, 'DMX': '1'}
  4397. j.append(jdata)
  4398. jclient_send(j)
  4399. return 0
  4400. def test_1():
  4401. #LibreLight --no-gui --show=unitest --dmx-out=on --exec="sel fix 1-10; go preset 2; encoder DIM sel; encoder DIM ++"
  4402. pass
  4403. window_manager = WindowManager()
  4404. CONSOLE = Console()
  4405. PRESETS = Presets()
  4406. FIXTURES = Fixtures()
  4407. def LOAD_SHOW():
  4408. PRESETS.load_presets()
  4409. FIXTURES.load_patch()
  4410. #draw_enc(gui,root2)
  4411. #master._refresh_fix()
  4412. #master._refresh_exec()
  4413. LOAD_SHOW()
  4414. master = GUI()
  4415. class Refresher():
  4416. def __init__(self):
  4417. self.time = time.time()+1
  4418. def reset(self):
  4419. self.time = time.time()+.1
  4420. def refresh(self):
  4421. if time.time() > self.time:
  4422. if time.time() < self.time+2:
  4423. #self.time = time.time()+1
  4424. self._refresh()
  4425. def _refresh(self):
  4426. master._refresh_fix()
  4427. master._refresh_exec()
  4428. def loop(self,args={}):
  4429. while 1:
  4430. try:
  4431. self.refresh()
  4432. tkinter.Tk.update_idletasks(gui_menu_gui.tk)
  4433. except Exception as e:print("loop exc",e)
  4434. time.sleep(0.2)
  4435. print("main",__name__)
  4436. __run_main = 0
  4437. if __name__ == "__main__":
  4438. __run_main = 1
  4439. else:
  4440. import __main__
  4441. if "unittest" not in dir(__main__):
  4442. __run_main = 1
  4443. refresher = Refresher()
  4444. if __run_main:
  4445. print("main")
  4446. thread.start_new_thread(refresher.loop,())
  4447. TOP = _POS_TOP + 15
  4448. L0 = _POS_LEFT
  4449. L1 = _POS_LEFT + 95
  4450. L2 = _POS_LEFT + 920
  4451. W1 = 810
  4452. H1 = 550
  4453. HTB = 23 # hight of the titlebar from window manager
  4454. w = GUIWindow("MAIN",master=1,width=85,height=H1//2,left=L0,top=TOP)
  4455. gui_menu_gui = w
  4456. data = []
  4457. #data.append({"text":"COMMAND"})
  4458. data.append({"text":"PATCH"})
  4459. data.append({"text":"DIMMER"})
  4460. data.append({"text":"FIXTURES"})
  4461. data.append({"text":"EXEC"})
  4462. data.append({"text":"EXEC-WING"})
  4463. gui_menu = GUI_menu(w.tk,data)
  4464. window_manager.new(w)
  4465. name="EXEC"
  4466. w = GUIWindow(name,master=0,width=W1,height=H1,left=L1,top=TOP)
  4467. w1 = ScrollFrame(w.tk,width=W1,height=H1)
  4468. #frame_exe = w.tk
  4469. draw_preset(master,w1)#w.tk)
  4470. window_manager.new(w,name)
  4471. name="DIMMER"
  4472. w = GUIWindow(name,master=0,width=W1,height=H1,left=L1,top=TOP)
  4473. w2 = ScrollFrame(w.tk,width=W1,height=H1)
  4474. #frame_dim = w1 # w.tk
  4475. #master.draw_dim(w1.tk)
  4476. window_manager.new(w,name)
  4477. name="FIXTURES"
  4478. w = GUIWindow(name,master=0,width=W1,height=H1,left=L1,top=TOP)
  4479. w1 = ScrollFrame(w.tk,width=W1,height=H1)
  4480. #frame_fix = w1 #w.tk
  4481. #draw_fix(master,w1,w2)#.tk)
  4482. gui_fix = GUI_FIX(master,w1,w2)
  4483. gui_fix.draw()
  4484. window_manager.new(w,name)
  4485. name="FIXTURE-EDITOR"
  4486. w = GUIWindow(name,master=0,width=W1,height=H1,left=L1,top=TOP)
  4487. w1 = ScrollFrame(w.tk,width=W1,height=H1)
  4488. data=[]
  4489. for i in range((24+12)*15):
  4490. data.append({"text"+str(i):"test"})
  4491. GUI_FaderLayout(w1,data)
  4492. window_manager.new(w,name)
  4493. name="MASTER-WING"
  4494. #w = GUIWindow(name,master=0,width=730,height=205,left=L1-80,top=TOP+H1-200)
  4495. w = GUIWindow(name,master=0,width=75,height=405,left=L0,top=TOP+H1-220)
  4496. #w1 = ScrollFrame(w.tk,width=W1,height=H1)
  4497. w1 = tk.Frame(w.tk,width=W1,height=H1)
  4498. w1.pack()
  4499. data=[]
  4500. for i in range(2):
  4501. data.append({"MASTER"+str(i):"MASTER"})
  4502. GUI_MasterWingLayout(w1,data)
  4503. window_manager.new(w,name)
  4504. name="EXEC-WING"
  4505. #w = GUIWindow(name,master=0,width=730,height=205,left=L1-80,top=TOP+H1-200)
  4506. w = GUIWindow(name,master=0,width=600,height=415,left=L1,top=TOP+H1+HTB*2)
  4507. #w1 = ScrollFrame(w.tk,width=W1,height=H1)
  4508. w1 = tk.Frame(w.tk,width=W1,height=H1)
  4509. w1.pack()
  4510. data=[]
  4511. for i in range(10*3):
  4512. data.append({"EXEC"+str(i):"EXEC"})
  4513. obj=GUI_ExecWingLayout(w1,data)
  4514. window_manager.new(w,name,obj)
  4515. name="ENCODER"
  4516. w = GUIWindow(name,master=0,width=620,height=113,left=L0+710,top=TOP+H1+HTB*2)
  4517. _ENCODER_WINDOW = w
  4518. draw_enc(master,w.tk)#Xroot)
  4519. name = "SETUP"
  4520. w = GUIWindow(name,master=0,width=415,height=42,left=L1+10+W1,top=TOP)
  4521. w.tk.title("SETUP SHOW:"+master.base.show_name)
  4522. draw_setup(master,w.tk)
  4523. window_manager.new(w,name)
  4524. name = "COMMAND"
  4525. w = GUIWindow(name,master=0,width=415,height=130,left=L1+10+W1,top=TOP+81)#+96)
  4526. draw_command(master,w.tk)
  4527. window_manager.new(w,name)
  4528. name = "LIVE"
  4529. w = GUIWindow(name,master=0,width=415,height=42,left=L1+10+W1,top=TOP+235)#250)
  4530. draw_live(master,w.tk)
  4531. window_manager.new(w,name)
  4532. name="FX"
  4533. w = GUIWindow(name,master=0,width=415,height=260,left=L1+10+W1,top=TOP+302)#317)
  4534. #frame_fx = w.tk
  4535. draw_fx(master,w.tk)
  4536. window_manager.new(w,name)
  4537. name="PATCH"
  4538. w = GUIWindow(name,master=0,width=W1,height=H1,left=L1,top=TOP)
  4539. w1 = ScrollFrame(w.tk,width=W1,height=H1)
  4540. main_preset_frame = w1
  4541. gui_patch = GUI_PATCH(master,main_preset_frame)
  4542. gui_patch.draw()
  4543. window_manager.new(w,name)
  4544. #LibreLightDesk
  4545. name="COLORPICKER"
  4546. w = GUIWindow(name,master=0,width=600,height=113,left=L1+5,top=TOP+5+HTB*2+H1)
  4547. draw_colorpicker(master,w.tk)
  4548. window_manager.new(w,name)
  4549. name="TableA"
  4550. w = GUIWindow(name,master=0,width=W1,height=H1,left=L1,top=TOP)
  4551. space_font = tk.font.Font(family="FreeSans", size=1 ) #, weight="bold")
  4552. x=TableFrame(root=w.tk)#,left=80,top=620)
  4553. w.show()
  4554. data =[]
  4555. for a in range(40):
  4556. data.append(["E","E{}".format(a+1)])
  4557. x.draw(data=data,head=["E","C"],config=[12,5,5])
  4558. w=x.bframe
  4559. #window_manager.new(w,name)
  4560. #Xroot = tk.Tk()
  4561. #Xroot["bg"] = "black" #white
  4562. #Xroot.title( xtitle+" "+str(rnd_id) )
  4563. #Xroot.geometry("1024x800+130+65")
  4564. master.render()
  4565. window_manager.top("Table")
  4566. #w = frame_fix #GUIWindow("OLD",master=0,width=W1,height=500,left=130,top=TOP)
  4567. window_manager.new(w,name)
  4568. try:
  4569. #root.mainloop()
  4570. #tk.mainloop()
  4571. window_manager.mainloop()
  4572. finally:
  4573. master.exit()