_LibreLightDesk.py 178 KB

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