Changeset - ddd3c8f04640
[Not reviewed]
default
0 3 0
dmcc - 22 years ago 2002-07-14 09:07:14

more untested code, ready for production: colors for slider mapping
3 files changed with 74 insertions and 13 deletions:
0 comments (0 inline, 0 general)
light8/ExtSliderMapper.py
Show inline comments
 
@@ -10,16 +10,18 @@ It lets functions take any number of arg
 
Callbacks do this, and we typically don't care about what they have to say. """
 

	
 
from Tix import *
 
from uihelpers import FancyDoubleVar, get_selection
 

	
 
stdfont = ('Arial', 8)
 
colors = ('lightBlue', 'lightPink', 'lightGreen', 'aquamarine1')
 

	
 
class SliderMapping:
 
    def __init__(self, default='disconnected', synced=0, extinputlevel=0, 
 
                 sublevel=0):
 
    def __init__(self, color, default='disconnected', synced=0, 
 
                 extinputlevel=0, sublevel=0):
 
        self.color = color
 
        self.subname = StringVar() # name of submaster we're connected to
 
        self.subname.set(default)
 
        self.sublevel = DoubleVar() # scalelevel variable of that submaster
 
        # self.sublevel = FancyDoubleVar() # scalelevel variable of that submaster
 
        self.sublevel.set(sublevel)
 
        self.synced = BooleanVar() # currently synced
 
@@ -150,14 +152,15 @@ class SliderMapping:
 
        'Draw interface into master, given a list of submaster names'
 
        self.subnames = subnames
 
        frame = Frame(master, bg='black')
 
        self.listbox = ScrolledListBox(frame, scrollbar='y', bg='black')
 
        self.listbox.listbox.bind("<<ListboxSelect>>", self.listbox_cb, add=1)
 
        self.listbox.listbox.configure(font=stdfont, exportselection=0, 
 
            selectmode=BROWSE, bg='black', fg='white')
 
        self.listbox.vsb.configure(troughcolor='black')
 
            selectmode=BROWSE, bg='black', fg='white', 
 
            selectbackground=self.color)
 
        self.listbox.vsb.configure(troughcolor=self.color)
 
        # self.listbox.listbox.insert(END, "disconnected")
 
        for s in subnames:
 
            self.listbox.listbox.insert(END, s)
 
        statframe = Frame(frame, bg='black')
 

	
 
        self.statuslabel = Label(statframe, text="No sync", width=15, 
 
@@ -180,34 +183,35 @@ class SliderMapping:
 
        frame.pack(side=LEFT, expand=1, fill=BOTH)
 

	
 
        self.widgets = [frame, self.listbox, statframe, self.statuslabel, 
 
                        ilabel, extlabel, rlabel, self.sublabel, disc_button]
 

	
 
class ExtSliderMapper(Frame):
 
    def __init__(self, parent, sliderlevels, sliderinput, filename='slidermapping',
 
                 numsliders=4):
 
    def __init__(self, parent, sliderlevels, sliderinput, 
 
                 lightboard, filename='slidermapping', numsliders=4):
 
        'Slider levels is scalelevels, sliderinput is an ExternalInput object'
 
        Frame.__init__(self, parent, bg='black')
 
        self.parent = parent
 
        self.sliderlevels = sliderlevels
 
        self.sliderinput = sliderinput
 
        self.filename = filename
 
        self.numsliders = numsliders
 
        self.lightboard = lightboard
 
        self.file = None
 

	
 
        # don't call setup, let them do that when scalelevels is created
 
    def setup(self):
 
        self.subnames = self.sliderlevels.keys()
 
        self.subnames.sort()
 
        self.presets = {}
 
        self.load_presets()
 

	
 
        self.current_preset = StringVar() # name of current preset
 
        self.current_mappings = []
 
        for i in range(self.numsliders):
 
            self.current_mappings.append(SliderMapping())
 
        for i, color in zip(range(self.numsliders), colors):
 
            self.current_mappings.append(SliderMapping(color))
 

	
 
        self.draw_interface()
 
    def load_presets(self):
 
        self.presets = {}
 
        self.file = open(self.filename, 'r')
 
        lines = self.file.readlines()
 
@@ -239,21 +243,31 @@ class ExtSliderMapper(Frame):
 
    def get_levels(self):
 
        'Called by changelevels, returns a dict of new values for submasters'
 
        if not self.sliderinput: return {}
 

	
 
        self.load_scalelevels() # freshen our input from the submasters
 

	
 
        for m, color in zip(self.current_mappings, colors):
 
            if not m.isdisconnected():
 
                name = m.get_mapping()
 
                lastsub = self.subs_highlighted.get(color)
 
                if name is not lastsub:
 
                    if lastsub is not None:
 
                        self.lightboard.highlight_sub(lastsub, 'restore')
 
                    self.lightboard.highlight_sub(name, color)
 
                    self.subs_highlighted[color] = name
 

	
 
        rawlevels = self.sliderinput.get_levels()
 
        for rawlev, slidermap in zip(rawlevels, self.current_mappings):
 
            slidermap.changed_extinput(rawlev)
 

	
 
        return dict([m.get_level_pair()
 
            for m in self.current_mappings
 
            if m.issynced()])
 
    def draw_interface(self):
 
        self.reallevellabels = []
 
        self.subs_highlighted = {}
 
        subchoiceframe = Frame(self, bg='black')
 
        for m in self.current_mappings:
 
            m.draw_interface(subchoiceframe, self.subnames)
 
        subchoiceframe.pack()
 
        
 
        presetframe = Frame(self, bg='black')
light8/Lightboard.py
Show inline comments
 
from __future__ import nested_scopes
 

	
 
from Tix import *
 
from signal import signal, SIGINT
 
from time import time
 
import sys, cPickle, random
 

	
 
from uihelpers import *
 
from panels import *
 
from Xfader import *
 
from subediting import Subediting
 
@@ -38,12 +39,14 @@ class Lightboard:
 
        self.get_data()
 
        self.buildinterface()
 
        self.load()
 
        print "Light 8.8: Enterring backgroundloop"
 
        self.backgroundloop()
 
        self.updatestagelevels()
 
        self.rec_file = open('light9.log', 'a')
 
        self.record_start()
 
        
 
    def buildinterface(self):
 
        print "Light 8.8: Constructing interface..."
 
        for w in self.master.winfo_children():
 
            w.destroy()
 

	
 
@@ -60,13 +63,14 @@ class Lightboard:
 
        effect_tl = toplevelat('effect')
 

	
 
        print "\tslider patching"
 
        mapping_tl = toplevelat('mapping')
 
        self.slidermapper = ExtSliderMapper.ExtSliderMapper(mapping_tl, 
 
                                                            self.scalelevels, 
 
                                                            ExternalSliders())
 
                                                            ExternalSliders(),
 
                                                            self)
 
        self.slidermapper.pack()
 

	
 
        print "\tsubmaster control"
 
        self.subpanels = Subpanels(sub_tl, effect_tl, scene_tl, self, self.scalelevels,
 
                                   Subs, self.xfader, self.changelevel,
 
                                   self.subediting, Subs.longestsubname())
 
@@ -113,18 +117,23 @@ class Lightboard:
 
        Patch.reload_data(self.DUMMY)
 
        print "Light 8.8:", len(Patch.patch), "dimmers patched"
 
        print "Light 8.8:", len(Subs.subs), "submasters loaded"
 

	
 
    def refresh(self, *args):
 
        'rebuild interface, reload data'
 
        print "Light 8.8: Refresh initiated.  Cross your fingers."
 
        self.get_data()
 
        print "Light 8.8: Subediting refreshed"
 
        self.subediting.refresh()
 
        print "Light 8.8: Rebuilding interface..."
 
        self.buildinterface()
 
        bindkeys(self.master,'<Escape>', self.quit)
 
        print "Light 8.8: Setting up slider patching..."
 
        self.slidermapper.setup()
 
        # self.master.tk_setPalette('gray40')
 
        print "Light 8.8: Now back to your regularly scheduled Light 8"
 

	
 
    def stageassub(self):
 
        """returns the current onstage lighting as a levels
 
        dictionary, skipping the zeros, and using names where
 
        possible"""
 
        levs=self.oldlevels
 
@@ -233,22 +242,45 @@ class Lightboard:
 
        self.slidermapper.setup()
 

	
 
    def backgroundloop(self, *args):
 
        self.master.after(50, self.backgroundloop, ())
 
        self.changelevel()
 
    def quit(self, *args):
 
        print "Light 8.8: And that's my cue to exit..."
 
        self.save()
 
        self.record_end()
 
        self.master.destroy()
 
        sys.exit()
 
    def save(self, *args):
 
        filename = '/tmp/light9.prefs'
 
        if self.DUMMY:
 
            filename += '.dummy'
 
        print "Saving to", filename
 
        print "Light 8.8: Saving to", filename
 
        file = open(filename, 'w')
 

	
 
        try:
 
            cPickle.dump(Pickles(self.scalelevels, Subs.subs.items()), file)
 
        except cPickle.UnpickleableError:
 
            print "UnpickleableError!  There's yer problem."
 
    def toggle_jostle(self, *args):
 
        self.jostle_mode = not self.jostle_mode
 
        print "Light 8.8: Jostle mode", ('off', 'on')[self.jostle_mode]
 
    def record_start(self):
 
        print "Light 8.8: Recorder started"
 
        self.rec_file.write("%s:\t%s\n" % (time(), "--- Start ---"))
 
        self.record_stamp()
 
    def record_end(self):
 
        print "Light 8.8: Recorder shutdown"
 
        self.rec_file.write("%s:\t%s\n" % (time(), "--- End ---"))
 
    def record_stamp(self):
 
        'Record the current submaster levels, continue this loop'
 
        levels = []
 
        for n, v in self.scalelevels.items():
 
            lev = v.get()
 
            if lev:
 
                levels.append('%s\t%s' % (n, lev))
 

	
 
        template = "%s:\t%s\n" % (time(), '\t'.join(levels))
 
        self.rec_file.write(template)
 
        self.master.after(100, self.record_stamp)
 
    def highlight_sub(self, name, color):
 
        self.subediting.colorsub(name, color)
light8/subediting.py
Show inline comments
 
@@ -38,24 +38,39 @@ class Subediting:
 
        this is called by widgets that are set up in the Subpanels interfaces.
 
        """
 
        
 
        print "subedit: editing ",sub.name
 
        self.sub = sub
 
        self.highlighteditsub()
 
    def highlighteditsub(self):
 
    def highlighteditsub(self, color='red'):
 
        """based on how widgets got self.register'd, we highlight
 
        just the row that's being edited"""
 

	
 
        # highlight that row only
 
        for n,wl in self.widgets.items():
 
            if n == self.sub.name:
 
                self.colorsub(n, color)
 
            else:
 
                self.colorsub(n, 'restore')
 

	
 
        '''
 
        # highlight that row only
 
        for n,wl in self.widgets.items():
 
            if n==self.sub.name:
 
                for w in wl:
 
                    w.config(bg='red')
 
                    w.config(bg=color)
 
            else:
 
                for w in wl:
 
                    w.config(bg=self.oldcolors[w])
 
        '''
 
    def colorsub(self, name, color):
 
        for w in self.widgets[name]:
 
            if color == 'restore':
 
                w.config(bg=self.oldcolors[w])
 
            else:
 
                w.config(bg=color)
 
        
 
    #
 
    # next two methods are called by the Stage
 
    #
 
    def startlevelchange(self):
 
        """stage is about to send some level changes. this method is
0 comments (0 inline, 0 general)