Changeset - 5bfcf309e1ad
[Not reviewed]
default
0 2 0
David McClosky - 20 years ago 2005-06-17 19:57:29
dmcc@bigasterisk.com
Submaster objects listen for a signal to reload, curvecalc can broadcast it
Also, an easter egg change: "Something I shoulda done a long time ago!"
2 files changed with 16 insertions and 6 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -218,13 +218,17 @@ def add_one_subterm(subname, curveset, s
 

	
 
    return term
 

	
 
def subterm_adder(master, curveset, subterms, root, ssv):
 
def sub_commands_tk(master, curveset, subterms, root, ssv):
 
    f=tk.Frame(master,relief='raised',bd=1)
 
    newname = tk.StringVar()
 

	
 
    def add_cmd():
 
        add_one_subterm(newname.get(), curveset, subterms, root, ssv, '')
 

	
 
    def reload_subs():
 
        dispatcher.send('reload all subs')
 

	
 
    tk.Button(f, text="reload subs", command=reload_subs).pack(side='left')
 
    tk.Button(f,text="new subterm named:", command=add_cmd).pack(side='left')
 
    tk.Entry(f,textvariable=newname).pack(side='left',fill='x',exp=1)
 
    return f
 
@@ -256,7 +260,7 @@ csv.pack(side='top',fill='both',exp=1)
 
ssv = SubtermSetView(root)
 
ssv.pack(side='top', fill='x')
 

	
 
root.title("Curemaster 2000MX - %s" % song)
 
root.title("Curvemaster 3000MX - %s" % song)
 

	
 
musicfilename = showconfig.songFilename(song)
 
maxtime = wavelength(musicfilename)
 
@@ -265,7 +269,8 @@ dispatcher.connect(lambda: maxtime, "get
 
curveset.load(basename=os.path.join(showconfig.curvesDir(),song))
 

	
 
subterms = []
 
subterm_adder(root, curveset, subterms, root, ssv).pack(side='top',fill='x')
 
sub_commands_tk(root, curveset, subterms, root, ssv).pack(side='top',fill='x')
 

	
 
for line in file(showconfig.subtermsForSong(song)):
 
    try:
 
        subname,expr = line.strip().split(" ",1)
 
@@ -286,7 +291,6 @@ def savekey(*args):
 
    curveset.save(basename=os.path.join(showconfig.curvesDir(),song))
 
    print "saved"
 

	
 
    
 
root.bind("<Control-Key-s>",savekey)
 

	
 
create_status_lines(root)
light9/Submaster.py
Show inline comments
 
@@ -2,6 +2,7 @@ from __future__ import division
 
import os
 
from light9.TLUtility import dict_scale, dict_max
 
from light9 import Patch, showconfig
 
import dispatch.dispatcher as dispatcher
 

	
 
class Submaster:
 
    "Contain a dictionary of levels, but you didn't need to know that"
 
@@ -12,11 +13,13 @@ class Submaster:
 
            self.levels = leveldict
 
        else:
 
            self.levels = {}
 
            self.reload()
 
    def reload(self):
 
            self.reload(quiet=True)
 
        dispatcher.connect(self.reload, 'reload all subs')
 
    def reload(self, quiet=False):
 
        if self.temporary:
 
            return
 
        try:
 
            oldlevels = self.levels.copy()
 
            self.levels.clear()
 
            subfile = file(showconfig.subFile(self.name))
 
            for line in subfile.readlines():
 
@@ -30,6 +33,9 @@ class Submaster:
 
                except ValueError:
 
                    print "(%s) Error with this line: %s" % (self.name, 
 
                        line[:-1])
 

	
 
                if (not quiet) and (oldlevels != self.levels):
 
                    print "sub %s changed" % self.name
 
        except IOError:
 
            print "Can't read file for sub: %s" % self.name
 
    def save(self):
0 comments (0 inline, 0 general)