annotate light8/util.py @ 161:0803fb42109d

we now have TkCueList, which is really cool. it doesn't provide editing we now have TkCueList, which is really cool. it doesn't provide editing yet, but you could almost nearly probably maybe run a show with it. heck, i hope so. some of the shifting/drawing problems were probably fixed. cuelist1 got more bogus data to help populate the TkCueList.
author dmcc
date Mon, 07 Jul 2003 17:18:26 +0000
parents 71489bb71528
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 def maxes(dicts):
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 '''
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 ({'a' : 5, 'b' : 9}, {'a' : 10, 'b' : 943})
45b12307c695 Initial revision
drewp
parents:
diff changeset
4 '''
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 newdict = {}
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 for d in dicts:
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 for k,v in d.items():
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 newdict[k] = max(v, newdict.get(k, 0))
45b12307c695 Initial revision
drewp
parents:
diff changeset
9 return newdict
45b12307c695 Initial revision
drewp
parents:
diff changeset
10
45b12307c695 Initial revision
drewp
parents:
diff changeset
11 def scaledict(d,scl):
45b12307c695 Initial revision
drewp
parents:
diff changeset
12 # scales all values in dict and returns a new dict
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 return dict([(k,v*scl) for k,v in d.items()])
45b12307c695 Initial revision
drewp
parents:
diff changeset
14
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 # class Setting that scales, maxes
45
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
16
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
17 def subsetdict(d, dkeys, default=0):
51
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 45
diff changeset
18 """Subset of dictionary d: only the keys in dkeys. If you plan on omitting
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 45
diff changeset
19 keys, make sure you like the default."""
45
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
20 newd = {} # dirty variables!
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
21 for k in dkeys:
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
22 newd[k] = d.get(k, default)
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
23 return newd