_LibreLightDesk.py 215 KB

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