draw.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. import tkinter as tk
  2. import traceback
  3. from __main__ import *
  4. import lib.mytklib as mytklib
  5. def draw_command(gui,xframe,data):
  6. frame_cmd=xframe
  7. i=0
  8. c=0
  9. r=0
  10. frame = tk.Frame(frame_cmd,bg="black")
  11. frame.pack(fill=tk.X, side=tk.TOP)
  12. c+=1
  13. gui.commands.elem = {}
  14. for comm in gui.commands.commands:
  15. if comm == "\n":
  16. c=0
  17. r+=1
  18. continue
  19. v=0
  20. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  21. if comm not in gui.commands.elem:
  22. gui.commands.elem[comm] = b
  23. gui.commands.val[comm] = 0
  24. if comm == "BLIND":
  25. b["bg"] = "grey"
  26. myTip = Hovertip(b,'BLIND MODE\nNO CHANGE on DMX-OUTPUT')
  27. if comm == "CLEAR":
  28. b["bg"] = "grey"
  29. myTip = Hovertip(b,'CLEAR ALL SELECTED\nFIXTURES ATTRIBUTES')
  30. if comm == "REC-FX":
  31. b["bg"] = "grey"
  32. myTip = Hovertip(b,'RECORD ONLY FX\nINTO EXEC')
  33. if comm == "FADE":
  34. b["bg"] = "green"
  35. myTip = Hovertip(b,'adjust fade time')
  36. if comm == "S-KEY":
  37. b["bg"] = "green"
  38. myTip = Hovertip(b,'keyboard short-key\non or off')
  39. if comm == "FX OFF":
  40. b["bg"] = "magenta"
  41. if comm == "SIZE:":
  42. b["text"] = "SIZE:{:0.0f}".format(fx_prm["SIZE"])
  43. if comm == "SPEED:":
  44. b["text"] = "SPEED:{:0.0f}".format(fx_prm["SPEED"])
  45. if comm == "DELAY":
  46. b["text"] = "FADE:\n{:0.02f}".format(DELAY.val())
  47. if comm == "FADE":
  48. b["text"] = "FADE:\n{:0.02f}".format(FADE.val())
  49. if comm == "START:":
  50. b["text"] = "START:{:0.0f}".format(fx_prm["START"])
  51. if comm == "OFFSET:":
  52. b["text"] = "OFFSET:{:0.0f}".format(fx_prm["OFFSET"])
  53. if comm == "FX-X:":
  54. b["text"] = "FX-X:{}".format(fx_prm["FX-X"])
  55. if comm == "BASE:":
  56. b["text"] = "BASE:{}".format(fx_prm["BASE"])
  57. b.bind("<Button>",Xevent(fix=0,elem=b,attr=comm,data=gui,mode="COMMAND").cb)
  58. if comm:
  59. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  60. c+=1
  61. if c >=8:
  62. c=0
  63. r+=1
  64. def draw_exec(gui,xframe,PRESETS):
  65. draw_preset(gui,xframe,PRESETS)
  66. def draw_preset(gui,xframe,PRESETS):
  67. i=0
  68. c=0
  69. r=0
  70. root = xframe
  71. frame = tk.Frame(root,bg="black")
  72. frame.pack(fill=tk.X, side=tk.TOP)
  73. gui.elem_presets = {}
  74. i=0
  75. for k in PRESETS.val_presets:
  76. if i%(10*8)==0 or i ==0:
  77. c=0
  78. b = tk.Canvas(frame,bg="black", height=4,bd=0,width=6,highlightthickness=0) #,bd="black")
  79. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  80. r+=1
  81. c=0
  82. b = tk.Button(frame,bg="lightblue", text="EXEC " )
  83. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  84. c+=1
  85. b = tk.Button(frame,bg="lightblue", text="BANK " + str(int(i/(8*8))+1) )
  86. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  87. c+=1
  88. b = tk.Button(frame,bg="lightblue", text="NAME" )
  89. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  90. r+=1
  91. c=0
  92. i+=1
  93. v=0
  94. label = ""
  95. sdata=PRESETS.val_presets[k]
  96. BTN="go"
  97. if "CFG" in sdata:#["BUTTON"] = "GO"
  98. if "BUTTON" in sdata["CFG"]:
  99. BTN = sdata["CFG"]["BUTTON"]
  100. txt=str(k+1)+":"+str(BTN)+":"+str(len(sdata)-1)+"\n"+label
  101. b = mytklib.ExecButton(frame,text=txt)
  102. b.bind("<Button>",Xevent(fix=0,elem=b,attr=k,data=gui,mode="PRESET").cb)
  103. b.bind("<ButtonRelease>",Xevent(fix=0,elem=b,attr=k,data=gui,mode="PRESET").cb)
  104. if k not in gui.elem_presets:
  105. gui.elem_presets[k] = b
  106. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  107. b.config(text="xx")
  108. c+=1
  109. if c >=10:
  110. c=0
  111. r+=1
  112. time.sleep(0.1)
  113. gui._refresh_exec()
  114. print("##################################")
  115. def draw_input(gui,root2):
  116. i=0
  117. c=0
  118. r=0
  119. frame = tk.Frame(root2,bg="black")
  120. frame.pack(fill=tk.X, side=tk.TOP)
  121. b = tk.Label(frame,bg="black", text="------------------------ ---------------------------------------")
  122. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  123. r=0
  124. frame = tk.Frame(root2,bg="black")
  125. frame.pack(fill=tk.X, side=tk.TOP)
  126. b = tk.Label(frame, text="send:")
  127. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  128. c+=1
  129. b = tk.Entry(frame,bg="grey", text="",width=50)
  130. gui.entry = b
  131. b.bind("<Button>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT").cb)
  132. b.bind("<Key>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT").cb)
  133. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  134. b.insert("end","d0:127,fx241:sinus:50:50:10,fx243:cosinus:50:50:10,d201:127,fx201:sinus:50:300:10")
  135. r+=1
  136. b = tk.Entry(frame,bg="grey", text="",width=20)
  137. gui.entry2 = b
  138. b.bind("<Button>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT2").cb)
  139. b.bind("<Key>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT2").cb)
  140. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  141. b.insert("end","d1:0:4")
  142. r+=1
  143. b = tk.Entry(frame,bg="grey", text="",width=20)
  144. gui.entry3 = b
  145. b.bind("<Button>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT3").cb)
  146. #b.bind("<B1-Motion>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT3").cb)
  147. b.bind("<Key>",Xevent(fix=0,elem=b,attr="INPUT",data=gui,mode="INPUT3").cb)
  148. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  149. b.insert("end","fx:alloff:::")
  150. def draw_colorpicker(gui,xframe,data):
  151. FIXTURES,master = data
  152. import lib.colorpicker as colp
  153. class _CB():
  154. def __init__(gui,FIXTURES,master):
  155. gui.old_color = (0,0,0)
  156. def cb(gui,event,data):
  157. print("CB.cb",gui,event,data)
  158. cprint("colorpicker CB")
  159. if "color" not in data:
  160. return 0
  161. if gui.old_color == data["color"]:
  162. pass #return 0
  163. #gui.old_color = data["color"]
  164. color = data["color"]
  165. #print("e",event,data)
  166. #print("e",dir(event))#.keys())
  167. try:
  168. print("e.state",event.state)
  169. except:pass
  170. set_fade = FADE.val() #fade
  171. event_ok = 0
  172. event_num = 0
  173. event_state = 0
  174. if event is None:
  175. event_ok = 1
  176. event_num = 3
  177. elif event.num == 1:
  178. event_ok = 1
  179. event_num = event.num
  180. elif event.num == 3:
  181. event_ok = 1
  182. event_num = event.num
  183. elif event.num==2:
  184. event_ok = 1
  185. event_num = event.num
  186. elif event.state in [256,1024]:
  187. event_ok = 1
  188. event_state = event.state
  189. if "color" in data and event_ok:
  190. cr=None
  191. cg=None
  192. cb=None
  193. cw=0
  194. ca=0
  195. set_fade=0
  196. if event_num == 1:
  197. if FADE._is():
  198. set_fade=FADE.val() #fade
  199. cr = color[0]
  200. cg = color[1]
  201. cb = color[2]
  202. elif event_num == 3:
  203. cr = color[0]
  204. cg = color[1]
  205. cb = color[2]
  206. elif event_num == 2:
  207. cr= "click"
  208. cg= "click"
  209. cb= "click"
  210. cw= "click"
  211. ca= "click"
  212. elif event_state == 256:
  213. cr = color[0]
  214. cg = color[1]
  215. cb = color[2]
  216. rr,rg,rb = "","",""
  217. if cr is not None:
  218. rr = FIXTURES.encoder(fix=0,attr="RED",xval=cr,xfade=set_fade,blind=1)
  219. else:
  220. print("RED ERR ---"*10)
  221. if cg is not None:
  222. rg = FIXTURES.encoder(fix=0,attr="GREEN",xval=cg,xfade=set_fade,blind=1)
  223. else:
  224. print("GREEN ERR ---"*10)
  225. if cb is not None:
  226. rb = FIXTURES.encoder(fix=0,attr="BLUE",xval=cb,xfade=set_fade,blind=1)
  227. else:
  228. print("BLUE ERR ---"*10,event_num)
  229. #print(" COLOR PICK:",cr,cg,cb)
  230. rw = FIXTURES.encoder(fix=0,attr="WHITE",xval=cw,xfade=set_fade,blind=1)
  231. ra = FIXTURES.encoder(fix=0,attr="AMBER",xval=ca,xfade=set_fade,blind=1)
  232. #print(dir())
  233. #print((rr))
  234. #print((rg))
  235. #print((rb))
  236. #print((rw))
  237. #print((ra))
  238. jdata = []
  239. jdata.extend(rr)
  240. jdata.extend(rg)
  241. jdata.extend(rb)
  242. jdata.extend(rw)
  243. jdata.extend(ra)
  244. print("# blind ???")
  245. master.jclient_send(jdata)
  246. master.refresh_fix()
  247. print("PICK COLOR:",data["color"])
  248. _cb=_CB(FIXTURES,master)
  249. colp.colorpicker(xframe,width=580,height=113, xcb=_cb.cb)
  250. return 0
  251. canvas=tk.Canvas(xframe,width=600,height=113)
  252. canvas["bg"] = "yellow" #"green"
  253. canvas.pack()
  254. # RGB
  255. x=0
  256. y=0
  257. j=0
  258. d = 20
  259. for i in range(0,d+1):
  260. fi = int(i*255/d)
  261. f = 255-fi
  262. if i > d/2:
  263. pass#break
  264. color = '#%02x%02x%02x' % (f, fi, fi)
  265. print( "farbe", i*10, j, f,fi,fi,color)
  266. r = canvas.create_rectangle(x, y, x+20, y+20, fill=color)
  267. x+=20
  268. #def draw_config(gui,xframe):
  269. class GUI_CONF():
  270. def __init__(self,gui,xframe,data):
  271. self.gui = gui
  272. self.data = data
  273. self.xframe = xframe
  274. self.draw()
  275. def draw(self):
  276. gui =self.gui
  277. xframe = self.xframe
  278. for widget in xframe.winfo_children():
  279. widget.destroy()
  280. i=0
  281. c=0
  282. r=0
  283. root2 = xframe
  284. frame = tk.Frame(root2,bg="#222")
  285. frame.pack(fill="both", expand=1,side=tk.TOP)
  286. b = tk.Label(frame, text="",bg="#222")
  287. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  288. c+=0
  289. r+=1
  290. b = tk.Label(frame, text="",bg="#222")
  291. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  292. c=0
  293. r+=1
  294. b = tk.Label(frame, text="",bg="#222")
  295. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  296. c=1
  297. r+=1
  298. b = tk.Label(frame, text="_________")
  299. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  300. c+=1
  301. b = tk.Entry(frame,bg="grey", text="",width=50)
  302. gui.entry = b
  303. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  304. b.insert("end","" )
  305. r+=1
  306. b = tk.Entry(frame,bg="grey", text="",width=20)
  307. gui.entry2 = b
  308. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  309. b.insert("end","d1:0:4")
  310. r+=1
  311. b = tk.Entry(frame,bg="grey", text="",width=20)
  312. gui.entry3 = b
  313. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  314. b.insert("end","fx:alloff:::")
  315. r+=1
  316. b = tk.Label(frame, text="",bg="#222")
  317. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  318. c+=0
  319. r+=1
  320. b = tk.Label(frame, text="",bg="#222")
  321. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  322. c+=0
  323. r+=1
  324. b = tk.Label(frame, text=" BATCH COMMAND ")
  325. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  326. c+=0
  327. r+=1
  328. b1 = tk.Entry(frame,bg="grey", text="",width=50)
  329. b1.grid(row=r, column=c, sticky=tk.W+tk.E)
  330. b1.insert("end","fix 1-100 patch @ 2.120")
  331. r+=1
  332. b = tk.Label(frame, text="",bg="#222")
  333. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  334. c+=0
  335. r+=1
  336. b = tk.Label(frame, text=" BATCH COMMAND ")
  337. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  338. c+=0
  339. r+=1
  340. b2 = tk.Entry(frame,bg="grey", text="",width=50)
  341. b2.grid(row=r, column=c, sticky=tk.W+tk.E)
  342. b2.insert("end","SELECT 33-61 PAN,TILT")
  343. root2.pack(fill="both",expand=1,side="top")
  344. def draw_enc(gui,xframe,data=[]):
  345. FIXTURES = data.fixtures
  346. for widget in xframe.winfo_children():
  347. widget.destroy()
  348. root2 = xframe
  349. i=0
  350. c=0
  351. r=0
  352. frame = tk.Frame(xframe,bg="black")
  353. frame.pack( side=tk.LEFT,expand=0,fill="both")
  354. b = tk.Button(frame,bg="lightblue", text="ENCODER",width=6)
  355. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  356. thread.start_new_thread(mytklib.tk_btn_bg_loop,(b,))
  357. c+=1
  358. eat = gui.all_attr[:]
  359. for fix in FIXTURES:
  360. for attr in FIXTURES[fix]["ATTRIBUT"]:
  361. if attr.startswith("_"):
  362. continue
  363. if attr not in eat:
  364. eat.append(attr)
  365. if len(eat) < 24:
  366. for i in range(24-len(eat)):
  367. eat.append("")
  368. for attr in eat:
  369. if attr.endswith("-FINE"):
  370. continue
  371. v=0
  372. if attr.startswith("_"):
  373. continue
  374. b = tk.Button(frame,bg="#6e6e6e", text=str(attr)+'',width=7)#, anchor="w")
  375. if attr == "DIM":
  376. b = tk.Button(frame,bg="#ff7f00", text=str(attr)+'',width=7)#, anchor="w")
  377. b.bind("<Button>",Xevent(fix=0,elem=b,attr=attr,data=gui,mode="ENCODER2").cb)
  378. b.grid(row=r, column=c, sticky=tk.W+tk.E ,ipadx=0,ipady=0,padx=0,pady=0)#,expand=True)
  379. c+=1
  380. if c >=8:
  381. c=0
  382. r+=1
  383. b = tk.Button(frame,bg="#bfff00", text="INV-ATTR",width=6)
  384. myTip = Hovertip(b,'INVERT ATTRIBUT SELECTION')
  385. b.bind("<Button>",Xevent(fix="SEL",elem=b,attr="INV-ATTR",data=gui,mode="INVERT").cb)
  386. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  387. c+=1
  388. def _draw_fx(frame,c,r,gui,mode="FX"):
  389. if mode=="FX-MAIN":
  390. ct = gui.fx_main
  391. prm = fx_prm_main
  392. elif mode=="FX-MOVE":
  393. ct = gui.fx_moves
  394. prm = fx_prm_move
  395. elif mode=="FX":
  396. ct = gui.fx
  397. prm = fx_prm
  398. elif mode=="FX-GENERIC":
  399. ct = gui.fx_generic
  400. prm = fx_prm #_generic
  401. elif mode=="FX-COLOR":
  402. ct = gui.fx_color
  403. prm = fx_color #_generic
  404. else:
  405. ct = Elem_Container()
  406. ct.commands =["err"]
  407. prm = ["err"]
  408. for comm in ct.commands:
  409. if comm == "\n\n":
  410. b = tk.Label(frame,bg="black", text="-",font=space_font)
  411. b.grid(row=r, column=c,pady=0,padx=0, sticky=tk.W+tk.E)
  412. c=0
  413. r+=1
  414. continue
  415. if comm == "\n":
  416. c=0
  417. r+=1
  418. continue
  419. v=0
  420. if "PAN/TILT" in comm:
  421. b = tk.Button(frame,bg="grey", text=str(comm),width=6,height=2)
  422. else:
  423. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  424. if comm not in ct.elem:
  425. #comm = comm.replace("\n","")
  426. ct.elem[comm] = b
  427. ct.val[comm] = 0
  428. b.bind("<Button>",Xevent_fx(fix=0,elem=b,attr=comm,data=gui,mode=mode).cb)
  429. if comm == "REC-FX":
  430. b["bg"] = "grey"
  431. elif comm == "FX OFF":
  432. b["bg"] = "magenta"
  433. elif comm[:3] == "FX:" or comm[:3] == "2D:":
  434. b["text"] = comm
  435. b["bg"] = "#ffbf00"
  436. elif comm[:3] == "MO:":
  437. b["text"] = comm
  438. b["bg"] = "lightgreen"
  439. elif comm.startswith( "SIZE:"):
  440. b["text"] = "SIZE:\n{:0.0f}".format(prm["SIZE"])
  441. b["bg"] = "lightgreen"
  442. elif comm.startswith( "SPEED:"):
  443. b["text"] = "SPEED:\n{:0.0f}".format(prm["SPEED"])
  444. b["bg"] = "lightgreen"
  445. elif comm.startswith("START:"):
  446. b["bg"] = "lightgreen"
  447. b["text"] = "START:\n{:0.0f}".format(prm["START"])
  448. elif comm.startswith( "OFFSET:"):
  449. b["bg"] = "lightgreen"
  450. b["text"] = "OFFSET:\n{:0.0f}".format(prm["OFFSET"])
  451. elif comm[:3] == "BASE:":
  452. b["bg"] = "lightgreen"
  453. b["text"] = "BASE:\n{}".format(prm["BASE"])
  454. elif comm[0] == "M":
  455. b["text"] = comm
  456. b["bg"] = "lightgrey"
  457. if comm:
  458. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  459. c+=1
  460. if c >=6:
  461. c=0
  462. r+=1
  463. c=0
  464. r+=1
  465. return c,r
  466. def _add_space(frame,r,c):
  467. b = tk.Canvas(frame,bg="black", height=2,bd=0,width=6,highlightthickness=0) #,bd="black")
  468. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  469. r+=1
  470. c=0
  471. return r,c
  472. def draw_fx(gui,xframe,data=[]):
  473. frame_fx=xframe
  474. i=0
  475. c=0
  476. r=0
  477. frame = tk.Frame(frame_fx,bg="black")
  478. frame.pack(fill=tk.X, side=tk.TOP)
  479. # ------------------------------
  480. b = tk.Button(frame,bg="lightblue", text="FX.",width=6)
  481. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  482. c+=1
  483. thread.start_new_thread(mytklib.tk_btn_bg_loop,(b,))
  484. # ------------------------------
  485. _add_space(frame,r,c)
  486. c,r = _draw_fx(frame,c,r,gui,mode="FX-MAIN")
  487. r,c=_add_space(frame,r,c)
  488. c,r = _draw_fx(frame,c,r,gui,mode="FX-MOVE")
  489. r,c=_add_space(frame,r,c)
  490. c,r = _draw_fx(frame,c,r,gui,mode="FX")
  491. r,c=_add_space(frame,r,c)
  492. r,c=_add_space(frame,r,c)
  493. c,r = _draw_fx(frame,c,r,gui,mode="FX-GENERIC")
  494. #r,c=_add_space(frame,r,c)
  495. #c,r = _draw_fx(frame,c,r,gui,mode="FX-COLOR")
  496. def draw_setup(gui,xframe,data):
  497. frame_cmd=xframe
  498. i=0
  499. c=0
  500. r=0
  501. frame = tk.Frame(frame_cmd,bg="black")
  502. frame.pack(fill=tk.X, side=tk.LEFT)
  503. c+=1
  504. pro_mode=1
  505. if "--easy" in sys.argv:
  506. pro_mode=0
  507. gui.setup_elem = {}
  508. comms = gui.setup_cmd # = Elem_Container()
  509. for comm in comms:
  510. if comm == "\n":
  511. c=0
  512. r+=1
  513. continue
  514. v=0
  515. ok = 0
  516. if comm == "SAVE\nSHOW":
  517. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=4,height=2)
  518. myTip = Hovertip(b,'Strg + S ')
  519. ok = 1
  520. elif comm == "LOAD\nSHOW" and pro_mode:
  521. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=4,height=2)
  522. ok = 1
  523. elif comm == "SAVE\nSHOW AS" and pro_mode:
  524. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  525. ok = 1
  526. elif comm == "SAVE &\nRESTART":
  527. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  528. ok = 1
  529. elif comm == "NEW\nSHOW" and pro_mode:
  530. b = tk.Button(frame,bg="lightgreen", text=str(comm),width=5,height=2)
  531. ok = 1
  532. elif comm == "DRAW\nGUI" and pro_mode:
  533. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=5,height=2)
  534. ok = 1
  535. elif comm == "PRO\nMODE":
  536. bg="lightgrey"
  537. bg="yellow"
  538. if pro_mode:
  539. bg="green"
  540. comm = "EASY\nMODE"
  541. b = tk.Button(frame,bg=bg, text=str(comm),width=5,height=2)
  542. ok = 1
  543. elif pro_mode:
  544. b = tk.Button(frame,bg="grey", text=str(comm),width=4,height=2)
  545. ok = 1
  546. else: #empty
  547. b = tk.Button(frame,bg="grey", text="",width=5,height=2)
  548. if comm not in gui.commands.elem:
  549. gui.setup_elem[comm] = b
  550. #gui.setup_elem.val[comm] = 0
  551. if ok:
  552. b.bind("<Button>",Xevent(fix=0,elem=b,attr=comm,data=gui,mode="SETUP").cb)
  553. if comm == "BASE:":
  554. b["text"] = "BASE:{}".format(prm["BASE"])
  555. if comm:
  556. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  557. c+=1
  558. if c >=17:
  559. c=0
  560. r+=1
  561. c+=1
  562. r=0
  563. def draw_live(gui,xframe,data):
  564. frame_cmd=xframe
  565. i=0
  566. c=0
  567. r=0
  568. frame = tk.Frame(frame_cmd,bg="black")
  569. frame.pack(fill="both",expand=1, side="left")#tk.TOP)
  570. c+=1
  571. for comm in ["FADE","DELAY","PAN/TILT\nFADE","PAN/TILT\nDELAY"]:
  572. if comm == "\n":
  573. c=0
  574. r+=1
  575. continue
  576. v=0
  577. b = tk.Button(frame,bg="lightgrey", text=str(comm),width=6,height=2)
  578. if comm not in gui.commands.elem:
  579. gui.commands.elem[comm] = b
  580. gui.commands.val[comm] = 0
  581. b.bind("<Button>",Xevent(fix=0,elem=b,attr=comm,data=gui,mode="LIVE").cb)
  582. if "FADE" == comm:
  583. b["text"] = "FADE:\n{:0.2}".format(FADE.val())
  584. if "DELAY" == comm:
  585. b["text"] = "DELAY:\n{:0.2}".format(DELAY.val())
  586. if "PAN/TILT\nFADE" == comm:
  587. b["text"] = "PAN/TILT\nFADE:{:0.2}".format(FADE_move.val())
  588. if "FADE" in comm:
  589. b["bg"] = "green"
  590. b.config(activebackground="lightgreen")
  591. if comm:
  592. b.grid(row=r, column=c, sticky=tk.W+tk.E)
  593. c+=1
  594. if c >=5:
  595. c=0
  596. r+=1