_LibreLightDesk.py 196 KB

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