_LibreLightDesk.py 198 KB

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