changeset 103:ddd3c8f04640

more untested code, ready for production: colors for slider mapping
author dmcc
date Sun, 14 Jul 2002 09:07:14 +0000
parents e04f7b552bcd
children 15ead14b4dd1
files light8/ExtSliderMapper.py light8/Lightboard.py light8/subediting.py
diffstat 3 files changed, 74 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/light8/ExtSliderMapper.py	Sun Jul 14 08:01:24 2002 +0000
+++ b/light8/ExtSliderMapper.py	Sun Jul 14 09:07:14 2002 +0000
@@ -13,10 +13,12 @@
 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
@@ -153,8 +155,9 @@
         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)
@@ -183,8 +186,8 @@
                         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
@@ -192,6 +195,7 @@
         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
@@ -203,8 +207,8 @@
 
         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):
@@ -242,6 +246,16 @@
 
         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)
@@ -250,7 +264,7 @@
             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)
--- a/light8/Lightboard.py	Sun Jul 14 08:01:24 2002 +0000
+++ b/light8/Lightboard.py	Sun Jul 14 09:07:14 2002 +0000
@@ -2,6 +2,7 @@
 
 from Tix import *
 from signal import signal, SIGINT
+from time import time
 import sys, cPickle, random
 
 from uihelpers import *
@@ -41,6 +42,8 @@
         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..."
@@ -63,7 +66,8 @@
         mapping_tl = toplevelat('mapping')
         self.slidermapper = ExtSliderMapper.ExtSliderMapper(mapping_tl, 
                                                             self.scalelevels, 
-                                                            ExternalSliders())
+                                                            ExternalSliders(),
+                                                            self)
         self.slidermapper.pack()
 
         print "\tsubmaster control"
@@ -116,12 +120,17 @@
 
     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
@@ -236,14 +245,16 @@
         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:
@@ -252,3 +263,24 @@
             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)
--- a/light8/subediting.py	Sun Jul 14 08:01:24 2002 +0000
+++ b/light8/subediting.py	Sun Jul 14 09:07:14 2002 +0000
@@ -41,18 +41,33 @@
         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