_LibreLightDesk.py 197 KB

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