Files
@ 7dbe8067acea
Branch filter:
Location: light9/light8/rsn.py
7dbe8067acea
4.3 KiB
text/x-python
fixed bug with channel levels not displaying
fixed bug with channel levels not displaying
moved an import from rsn to io
fixed bug with channel levels not displaying
moved an import from rsn to io
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | #!/usr/bin/env python
from __future__ import nested_scopes
from Tkinter import *
from time import sleep
from signal import *
import sys, thread, cPickle
import io
from uihelpers import *
from panels import *
from Xfader import *
import stage
if len(sys.argv) >= 2:
DUMMY = 0
print "This is the real thing, baby"
window_title = "Light 8.8 (On Air)"
else:
DUMMY = 1
print "Dummy mode"
window_title = "Light 8.8 (Bogus)"
root = Tk()
root.wm_title(window_title)
root.wm_geometry('+447+373')
import Subs, Patch
def get_data(*args):
Subs.reload_data(DUMMY)
Patch.reload_data(DUMMY)
print "Patch:", Patch.patch
print "Subs:", ', '.join(Subs.subs.keys())
get_data()
io.init(DUMMY)
channel_levels = []
scalelevels = {}
fades = {}
_oldlevels=[None] * 68
def changelevel(*args):
'Amp trims slider'
global _oldlevels
levels = [0] * 68
for name, s in Subs.subs.items():
newlevels = s.get_levels(level=scalelevels[name].get())
for (ch, fadelev) in newlevels.items():
levels[ch-1] = max(levels[ch-1], fadelev)
levels = [int(l) for l in levels]
for lev,lab,oldlev in zip(levels, channel_levels, _oldlevels):
if lev != oldlev:
lab.config(text="%d" % lev)
colorlabel(lab)
_oldlevels = levels[:]
io.sendlevels(levels)
def backgroundloop(*args):
root.after(50, backgroundloop, ())
changelevel()
buildinterface = None # temporary
def refresh(*args):
get_data()
buildinterface()
bindkeys(root,'<Escape>', quit)
def quit(*args):
filename = '/tmp/light9.prefs'
if DUMMY:
filename += '.dummy'
print "Saving to", filename
file = open(filename, 'w')
cPickle.dump(Pickles(scalelevels), file)
root.destroy()
sys.exit()
xfader=Xfader(scalelevels)
def buildinterface(*args):
global channel_levels, _oldlevels, leveldisplay, xfader
for w in root.winfo_children():
w.destroy()
stage_tl=toplevelat(165,90)
s=stage.Stage(stage_tl)
stage.createlights(s)
s.pack()
sub_tl = toplevelat(0,0)
effect_tl = toplevelat(0,352)
Subpanels(sub_tl,effect_tl,scalelevels,Subs,xfader,changelevel)
# def event_printer(evt):
# print dir(evt)
# sub_tl.bind('<b>', event_printer)
leveldisplay=toplevelat(873,400)
leveldisplay.bind('<Escape>', sys.exit)
Leveldisplay(leveldisplay,_oldlevels,channel_levels)
Console()
# root frame
controlpanel = Controlpanel(root,xfader,refresh,quit)
xf=Frame(root)
xf.pack(side='right')
root.bind('<q>', quit)
root.bind('<r>', refresh)
leveldisplay.bind('<q>', quit)
leveldisplay.bind('<r>', refresh)
xfader.setupwidget(xf)
controlpanel.pack()
buildinterface()
class Pickles:
def __init__(self, scalelevels):
self.scalelevels = dict([(name, lev.get())
for name,lev in scalelevels.items()])
def load():
try:
filename = '/tmp/light9.prefs'
if DUMMY:
filename += '.dummy'
print "Loading from", filename
file = open(filename, 'r')
p = cPickle.load(file)
for s, v in p.scalelevels.items():
try:
scalelevels[s].set(v)
except:
print "Couldn't set %s -> %s" % (s, v)
except:
print "Couldn't load prefs (%s)" % filename
def make_sub(name):
global _oldlevels
i = 1
# name = console_entry.get() # read from console
if not name:
print "Enter sub name in console."
return
st = ''
linebuf = 'subs["%s"] = {' % name
for l in _oldlevels:
if l:
if len(linebuf) > 60:
st += linebuf + '\n '
linebuf = ''
linebuf += ' "%s" : %d,' % (Patch.get_channel_name(i), l)
i += 1
st += linebuf + '}\n'
if DUMMY:
filename = 'ConfigDummy.py'
else:
filename = 'Config.py'
f = open(filename, 'a')
f.write(st)
f.close()
print 'Added sub:', st
refresh()
load()
signal(SIGINT, quit)
bindkeys(root,'<Escape>', quit)
# bindkeys(root,'<q>', quit)
# bindkeys(root,'<r>', refresh)
# bindkeys(root,'<s>', make_sub)
backgroundloop()
root.mainloop() # Receiver switches main
while 1:
for lev in range(0,255,25)+range(255,0,-25):
sleep(.2)
|