Changeset - 411de8b46aef
[Not reviewed]
default
0 3 0
dmcc - 22 years ago 2002-07-07 12:06:16

the famous you-are-in-the-process-of-changing-this-light indicator.
the famous you-are-in-the-process-of-changing-this-light indicator.
red = going up
blue = going down

also, a generic color fader in uihelpers.py -- unused (as of now)
3 files changed with 26 insertions and 5 deletions:
0 comments (0 inline, 0 general)
light8/panels.py
Show inline comments
 
@@ -38,34 +38,34 @@ class Console:
 
    def execute(evt, str):
 
        if str[0] == '*': # make a new sub
 
            make_sub(str)
 
        else:
 
            print '>>>', str
 
            print eval(str)
 
        self.frame.focus()
 

	
 
class Leveldisplay:
 
    def __init__(self, parent, channel_levels, num_channels=68):
 
        frames = (make_frame(parent), make_frame(parent))
 
        channel_levels[:]=[]
 
        self.number_labels = {}
 
        self.number_labels = []
 
        for channel in range(1, num_channels+1):
 

	
 
            # frame for this channel
 
            f = Frame(frames[channel > (num_channels/2)])
 
            # channel number -- will turn yellow when being altered
 
            num_lab = Label(f, text=str(channel), width=3, bg='lightPink', 
 
                font=stdfont, padx=0, pady=0, bd=0, height=1)
 
            num_lab.pack(side='left')
 
            self.number_labels[channel] = num_lab
 
            self.number_labels.append(num_lab)
 

	
 
            # text description of channel
 
            Label(f, text=Patch.get_channel_name(channel), width=8, 
 
                font=stdfont, anchor='w', padx=0, pady=0, bd=0, 
 
                height=1).pack(side='left')
 

	
 
            # current level of channel, shows intensity with color
 
            l = Label(f, width=3, bg='lightBlue', font=stdfont, anchor='e', 
 
                      padx=1, pady=0, bd=0, height=1)
 
            l.pack(side='left')
 
            colorlabel(l)
 
            channel_levels.append(l)
light8/rsn.py
Show inline comments
 
#!/usr/bin/env python
 
from __future__ import nested_scopes
 

	
 
from Tkinter import *
 
from time import sleep
 
from signal import *
 
import sys, thread, cPickle
 
import sys, thread, cPickle, math
 

	
 
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:
 
@@ -60,25 +60,25 @@ class Lightboard:
 

	
 
        sub_tl = toplevelat(0,0)
 
        effect_tl = toplevelat(462,4)
 

	
 
        self.xfader = Xfader(self.scalelevels)
 

	
 
        self.subpanels = Subpanels(sub_tl, effect_tl, self.scalelevels, Subs, 
 
            self.xfader, self.changelevel)
 

	
 
        leveldisplay_tl = toplevelat(873,400)
 
        leveldisplay_tl.bind('<Escape>', sys.exit)
 

	
 
        leveldisplay = Leveldisplay(leveldisplay_tl, self.channel_levels)
 
        self.leveldisplay = Leveldisplay(leveldisplay_tl, self.channel_levels)
 

	
 
        Console()
 

	
 
        # root frame
 
        controlpanel = Controlpanel(root, self.xfader, self.refresh, self.quit)
 
        
 
        xf=Frame(root)
 
        xf.pack(side='right')
 

	
 
        root.bind('<q>', self.quit)
 
        root.bind('<r>', self.refresh)
 
        leveldisplay_tl.bind('<q>', self.quit)
 
@@ -96,28 +96,36 @@ class Lightboard:
 
    # this is called on a loop, and ALSO by the Scales
 
    def changelevel(self, *args):
 
        'Amp trims slider'
 

	
 
        levels = [0] * 68
 
        for name, s in Subs.subs.items():
 
            newlevels = s.get_levels(level=self.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, self.channel_levels, self.oldlevels):
 
        for lev,lab,oldlev,numlab in zip(levels, self.channel_levels, 
 
                                         self.oldlevels, 
 
                                         self.leveldisplay.number_labels):
 
            if lev != oldlev:
 
                lab.config(text="%d" % lev)
 
                colorlabel(lab)
 
                if lev < oldlev:
 
                    numlab['bg'] = 'red'
 
                else:
 
                    numlab['bg'] = 'blue'
 
            else:
 
                numlab['bg'] = 'lightPink'
 

	
 
        self.oldlevels = levels[:]
 
            
 
        parportdmx.sendlevels(levels)
 

	
 
    def load(self):
 
        try:
 
            filename = '/tmp/light9.prefs'
 
            if DUMMY:
 
                filename += '.dummy'
 
            print "Loading from", filename
 
            file = open(filename, 'r')
light8/uihelpers.py
Show inline comments
 
"""all the tiny tk helper functions"""
 

	
 
from Tkinter import *
 
from types import StringType
 

	
 
def make_frame(parent):
 
    f = Frame(parent, bd=0)
 
    f.pack(side='left')
 
    return f
 

	
 
def bindkeys(root,key, func):
 
    root.bind(key, func)
 
    for w in root.winfo_children():
 
        w.bind(key, func)
 

	
 
def toplevelat(x,y,w=None,h=None):
 
@@ -31,24 +32,36 @@ def printout(t):
 
    print t
 
    
 
def colorlabel(label):
 
    """color a label based on its own text"""
 
    txt=label['text'] or "0"
 
    lev=float(txt)/100
 
    low=(80,80,180)
 
    high=(255,55,050)
 
    out = [int(l+lev*(h-l)) for h,l in zip(high,low)]
 
    col="#%02X%02X%02X" % tuple(out)
 
    label.config(bg=col)
 

	
 
# TODO: get everyone to use this
 
def colorfade(low, high, percent):
 
    '''not foolproof.  make sure 0 < percent < 1'''
 
    out = [int(l+percent*(h-l)) for h,l in zip(high,low)]
 
    col="#%02X%02X%02X" % tuple(out)
 
    return col
 

	
 
def colortotuple(anytkobj, colorname):
 
    'pass any tk object and a color name, like "yellow"'
 
    rgb = anytkobj.winfo_rgb(colorname)
 
    return [v / 256 for v in rgb]
 

	
 
class Togglebutton(Button):
 
    """works like a single radiobutton, but it's a button so the label's on the button face, not to the side"""
 
    def __init__(self,parent,**kw):
 
        if kw['variable']:
 
            self.variable = kw['variable']
 
            self.variable.trace('w',self.varchanged)
 
            del kw['variable']
 
        else:
 
            self.variable=None
 
        self.oldcommand = kw.get('command',None)
 
        kw['command'] = self.invoke
 
        Button.__init__(self,parent,**kw)
0 comments (0 inline, 0 general)