_LibreLightDesk.py 216 KB

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