Changeset - 43aa1ee8b3a9
[Not reviewed]
default
0 2 0
drewp - 22 years ago 2002-07-07 06:43:40

some comments and garbage cleanup
2 files changed with 16 insertions and 6 deletions:
0 comments (0 inline, 0 general)
light8/rsn.py
Show inline comments
 
@@ -34,24 +34,25 @@ def get_data(*args):
 
    print "Subs:", ', '.join(Subs.subs.keys())
 

	
 
get_data()
 

	
 
io.init(DUMMY)
 

	
 
channel_levels = []
 
scalelevels = {}
 
fades = {}
 

	
 
_oldlevels=[None] * 68
 

	
 
# this is called on a loop, and ALSO by the Scales
 
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]
 

	
 
@@ -78,26 +79,24 @@ 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)
 
@@ -182,16 +181,12 @@ def make_sub(name):
 
    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)
light8/stage.py
Show inline comments
 
@@ -22,24 +22,38 @@ class Stage(Canvas):
 
    ctrl-shift-a or clicking on no light deselects all,
 
    re-clicking a light with shift key down toggles whether it's in the selection.
 
    ctrl-drag-rectangle deselects the lights in the rectangle,
 
    shift-drag-rectangle selects the lights in the rectangle,
 
    drag-rectangle selects only the lights in the rectangle.
 

	
 
    a light can be selected on its location point, its aim point
 
    (which may or may not be present), or its name.
 

	
 
    lights should be able to be interactively 'locked', which blocks
 
    them from being selected. 
 

	
 
    API:
 
      __init__(parent,**kw)
 
        put pass any canvas options you want
 
        
 
      setimage(stageimage)
 
        sets image to given filename (ppm, gif, etc) and resizes the canvas to the image size
 

	
 
      addlight(name, location, aim=None)
 
        location and aim are pixel coord tuples. name will be passed back to you in the callback (see below)
 

	
 
      setlightchangecb(cb)
 
        give a function which will be called like this: cb(list_of_light_names, delta)
 
      
 

	
 
    """
 
    def __init__(self,parent,**kw):
 
        Canvas.__init__(self,parent,**kw)
 

	
 
        self.bind("<ButtonPress-1>", self.leftpress)
 
        self.bind("<B1-Motion>", self.leftmotion)
 
        self.bind("<ButtonRelease-1>", self.leftrelease)
 
        
 
        self.halo=11 # search radius for clicked items
 

	
 
        self.lmbstate=None # as you perform with LMB, this goes from None to 'pressed','rectangle','levelchange'
 

	
 
@@ -121,24 +135,25 @@ class Stage(Canvas):
 
                    # deselect
 
                    self.select(touching[0],0)
 
                    # and do nothing else
 
                    self.lmbstate=None
 
                else:
 
                    # select only this light
 
                    self.clearselection()
 
                    self.select(touching[0])
 
                    # and adjust its level
 
                    self.lmbstate='levelchange'
 
                    
 
            else:
 
                # clicked a light that wasn't selected
 
                if not shifted:
 
                    self.clearselection()
 
                self.select(touching[0])
 
                # and adjust levels now
 
                self.lmbstate='levelchange'
 
                
 
        if self.lmbstate=='rectangle':
 
            self.markfordynselection()
 
    def leftmotion(self,ev):
 

	
 
        coords=(ev.x,ev.y)
 

	
0 comments (0 inline, 0 general)