# HG changeset patch # User David McClosky # Date 2005-06-17 19:57:29 # Node ID 5bfcf309e1ad7bc734a46d0cde412a0e9ffb32f5 # Parent d20fda03a04128d670d6dee1f52184f1f73453db 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!" diff --git a/bin/curvecalc b/bin/curvecalc --- a/bin/curvecalc +++ b/bin/curvecalc @@ -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) @@ -285,7 +290,6 @@ def savekey(*args): savesubterms(showconfig.subtermsForSong(song),subterms) curveset.save(basename=os.path.join(showconfig.curvesDir(),song)) print "saved" - root.bind("",savekey) diff --git a/light9/Submaster.py b/light9/Submaster.py --- a/light9/Submaster.py +++ b/light9/Submaster.py @@ -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):