Mercurial > code > home > repos > light9
annotate flax/CueFaders.py @ 167:79bc84310e80
changes from tonight's rehearsal:
changes from tonight's rehearsal:
- CueFader is closer to actually running the show, computes DMX levels
to send.
- KeyboardComposer is not a dummy. Use DMXDUMMY=1 to disable it.
- Submaster: subs can now be "temporary" -- i.e. they shouldn't be saved
or loaded. to save a temporary sub, make a copy of it with a proper name
since the computed name will be ugly.
Also, get_normalized_copy() and crossfade() methods added.
linear_fade helper (shouldn't be in Submaster, probably) added too.
- dmxchanedit: longer labels
- cuelist1 now has some bogus data in it and some crap removed
- dmxclient: now listens to the $DMXHOST and $DMXDUMMY env variables.
- patchdata: now up to date with this year's show
- danshow subs song{01..19}: removed. maybe we'll re-add them in an
archive directory.
author | dmcc |
---|---|
date | Tue, 08 Jul 2003 16:19:55 +0000 |
parents | e0c227168519 |
children | f8b5cb5fbeed |
rev | line source |
---|---|
0 | 1 from __future__ import division, nested_scopes |
2 import Tix as Tk | |
3 import time | |
4 from TreeDict import TreeDict, allow_class_to_be_pickled | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
5 from TLUtility import enumerate |
167 | 6 import Submaster |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
7 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
8 cue_state_indicator_colors = { |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
9 # bg fg |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
10 'prev' : ('blue', 'white'), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
11 'cur' : ('yellow', 'black'), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
12 'next' : ('red', 'white'), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
13 } |
0 | 14 |
15 class LabelledScale(Tk.Frame): | |
16 """Scale with two labels: a name and current value""" | |
17 def __init__(self, master, label, **opts): | |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
18 Tk.Frame.__init__(self, master, bd=2, relief='raised', bg='black') |
163 | 19 self.labelformatter = opts.get('labelformatter') |
20 try: | |
21 del opts['labelformatter'] | |
22 except KeyError: | |
23 pass | |
24 | |
0 | 25 opts.setdefault('variable', Tk.DoubleVar()) |
26 opts.setdefault('showvalue', 0) | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
27 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
28 self.normaltrough = opts.get('troughcolor', 'black') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
29 self.flashtrough = opts.get('flashtroughcolor', 'red') |
163 | 30 try: |
31 del opts['flashtroughcolor'] | |
32 except KeyError: | |
33 pass | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
34 |
0 | 35 self.scale_var = opts['variable'] |
36 self.scale = Tk.Scale(self, **opts) | |
37 self.scale.pack(side='top', expand=1, fill='both') | |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
38 self.name = Tk.Label(self, text=label, bg='black', fg='white') |
0 | 39 self.name.pack(side='bottom') |
163 | 40 self.scale_value = Tk.Label(self, bg='black', fg='white') |
0 | 41 self.scale_value.pack(side='bottom') |
42 self.scale_var.trace('w', self.update_value_label) | |
43 self.update_value_label() | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
44 self.disabled = (self.scale['state'] == 'disabled') |
0 | 45 def set_label(self, label): |
46 self.name['text'] = label | |
47 def update_value_label(self, *args): | |
48 val = self.scale_var.get() * 100 | |
163 | 49 if self.labelformatter: |
50 format = self.labelformatter(val) | |
51 else: | |
52 format = "%0.2f" % val | |
53 self.scale_value['text'] = format | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
54 if val != 0: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
55 self.scale['troughcolor'] = self.flashtrough |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
56 else: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
57 self.scale['troughcolor'] = self.normaltrough |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
58 def disable(self): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
59 if not self.disabled: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
60 self.scale['state'] = 'disabled' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
61 self.scale_var.set(0) |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
62 self.disabled = 1 |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
63 def enable(self): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
64 if self.disabled: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
65 self.scale['state'] = 'normal' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
66 self.disabled = 0 |
0 | 67 |
68 class TimedGoButton(Tk.Frame): | |
69 """Go button, fade time entry, and time fader""" | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
70 def __init__(self, master, name, scale_to_fade, **kw): |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
71 Tk.Frame.__init__(self, master, bg='black') |
0 | 72 self.name = name |
73 self.scale_to_fade = scale_to_fade | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
74 self.button = Tk.Button(self, text=name, command=self.start_fade, **kw) |
0 | 75 self.button.pack(fill='both', expand=1, side='left') |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
76 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
77 self.timer_var = Tk.DoubleVar() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
78 self.timer_entry = Tk.Control(self, step=0.5, min=0, integer=0) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
79 self.timer_entry.entry.configure(textvariable=self.timer_var, width=5, |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
80 bg='black', fg='white') |
0 | 81 self.timer_entry.pack(fill='y', side='left') |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
82 self.disabled = (self.button['state'] == 'disabled') |
167 | 83 self.fading = 0 |
0 | 84 def start_fade(self, end_level=1): |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
85 try: |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
86 fade_time = float(self.timer_var.get()) |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
87 except ValueError: |
167 | 88 # since we use a control now, i don't think we need to worry about |
89 # validation any more. | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
90 print "can't fade -- bad time" |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
91 return |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
92 |
0 | 93 self.start_time = time.time() |
94 self.start_level = self.scale_to_fade.scale_var.get() | |
95 self.end_level = end_level | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
96 self.fade_length = fade_time |
167 | 97 self.fading = 1 |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
98 self.do_fade() |
0 | 99 def do_fade(self): |
100 diff = time.time() - self.start_time | |
101 if diff < self.fade_length: | |
102 percent = diff / self.fade_length | |
103 newlevel = self.start_level + \ | |
104 (percent * (self.end_level - self.start_level)) | |
105 self.scale_to_fade.scale_var.set(newlevel) | |
106 | |
107 if newlevel != self.end_level: | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
108 self.after(10, self.do_fade) |
167 | 109 else: |
110 self.fading = 0 | |
0 | 111 else: |
112 self.scale_to_fade.scale_var.set(self.end_level) | |
167 | 113 self.fading = 0 |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
114 def disable(self): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
115 if not self.disabled: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
116 self.button['state'] = 'disabled' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
117 self.disabled = 1 |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
118 def enable(self): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
119 if self.disabled: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
120 self.button['state'] = 'normal' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
121 self.disabled = 0 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
122 def set_time(self, time): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
123 self.timer_var.set(time) |
163 | 124 def get_time(self): |
125 return self.timer_var.get() | |
167 | 126 def is_fading(self): |
127 return self.fading | |
0 | 128 |
129 class CueFader(Tk.Frame): | |
130 def __init__(self, master, cuelist): | |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
131 Tk.Frame.__init__(self, master, bg='black') |
0 | 132 self.cuelist = cuelist |
155 | 133 self.auto_shift = Tk.IntVar() |
134 self.auto_shift.set(1) | |
0 | 135 |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
136 # this is a mechanism to stop Tk from autoshifting too much. |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
137 # if this variable is true, the mouse button is down. we don't want |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
138 # to shift until they release it. when it is released, we will |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
139 # set it to false and then call autoshift. |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
140 self.no_shifts_until_release = 0 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
141 |
0 | 142 self.scales = {} |
143 self.shift_buttons = {} | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
144 self.go_buttons = {} |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
145 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
146 topframe = Tk.Frame(self, bg='black') |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
147 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
148 self.set_prev_button = Tk.Button(topframe, text='Set Prev', |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
149 command=lambda: cuelist.set_selection_as_prev(), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
150 fg='white', bg='blue') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
151 self.set_prev_button.pack(side='left') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
152 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
153 self.auto_shift_checkbutton = Tk.Checkbutton(topframe, |
155 | 154 variable=self.auto_shift, text='Autoshift', |
163 | 155 command=self.toggle_autoshift, bg='black', fg='white', |
156 highlightbackground='black') | |
157 self.auto_shift_checkbutton.pack(fill='both', side='left') | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
158 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
159 self.set_next_button = Tk.Button(topframe, text='Set Next', |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
160 command=lambda: cuelist.set_selection_as_next(), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
161 fg='white', bg='red') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
162 self.set_next_button.pack(side='left') |
155 | 163 |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
164 topframe.pack(side='top') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
165 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
166 faderframe = Tk.Frame(self, bg='black') |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
167 self.direction_info = (('Prev', 1, 0, 'left', 'blue'), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
168 ('Next', 0, 1, 'right', 'red')) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
169 for name, start, end, side, color in self.direction_info: |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
170 frame = Tk.Frame(self, bg='black') |
0 | 171 scale = LabelledScale(frame, name, from_=start, to_=end, |
163 | 172 res=0.0001, orient='horiz', flashtroughcolor=color, |
173 labelformatter=lambda val, name=name: self.get_scale_desc(val, | |
174 name)) | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
175 scale.pack(fill='x', expand=0) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
176 go = TimedGoButton(frame, 'Go %s' % name, scale, bg=color, |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
177 fg='white') |
0 | 178 go.pack(fill='both', expand=1) |
179 frame.pack(side=side, fill='both', expand=1) | |
180 | |
155 | 181 shift = Tk.Button(frame, text="Shift %s" % name, state='disabled', |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
182 command=lambda name=name: self.shift(name), fg=color, |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
183 bg='black') |
155 | 184 |
0 | 185 self.scales[name] = scale |
186 self.shift_buttons[name] = shift | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
187 self.go_buttons[name] = go |
0 | 188 |
189 scale.scale_var.trace('w', \ | |
190 lambda x, y, z, name=name, scale=scale: self.xfade(name, scale)) | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
191 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
192 def button_press(event, name=name, scale=scale): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
193 self.no_shifts_until_release = 1 # prevent shifts until release |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
194 def button_release(event, name=name, scale=scale): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
195 self.no_shifts_until_release = 0 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
196 self.autoshift(name, scale) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
197 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
198 scale.scale.bind("<ButtonPress>", button_press) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
199 scale.scale.bind("<ButtonRelease>", button_release) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
200 faderframe.pack(side='bottom', fill='both', expand=1) |
167 | 201 self.cues_as_subs = {} |
163 | 202 def get_scale_desc(self, val, name): |
203 go_button = self.go_buttons.get(name) | |
204 if go_button: | |
205 time = go_button.get_time() | |
206 return "%0.2f%%, %0.1fs left" % (val, time - ((val / 100.0) * time)) | |
207 else: | |
208 return "%0.2f%%" % val | |
155 | 209 def toggle_autoshift(self): |
210 for name, button in self.shift_buttons.items(): | |
211 if not self.auto_shift.get(): | |
212 button.pack(side='bottom', fill='both', expand=1) | |
213 else: | |
214 button.pack_forget() | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
215 def shift(self, name): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
216 # to prevent overshifting |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
217 if self.no_shifts_until_release: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
218 return |
155 | 219 |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
220 for scale_name, scale in self.scales.items(): |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
221 scale.scale.set(0) |
0 | 222 self.cuelist.shift((-1, 1)[name == 'Next']) |
167 | 223 |
224 # now load the subs to fade between | |
225 for cue, name in zip(self.cuelist.get_current_cues(), | |
226 ('Prev', 'Cur', 'Next')): | |
227 self.cues_as_subs[name] = cue.get_levels_as_sub() | |
228 print "cues_as_subs", self.cues_as_subs | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
229 def autoshift(self, name, scale): |
0 | 230 scale_val = scale.scale_var.get() |
231 | |
232 if scale_val == 1: | |
155 | 233 if self.auto_shift.get(): |
0 | 234 self.shift(name) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
235 def xfade(self, name, scale): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
236 if self.auto_shift.get(): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
237 self.autoshift(name, scale) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
238 scale_val = scale.scale_var.get() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
239 else: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
240 scale_val = scale.scale_var.get() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
241 if scale_val == 1: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
242 self.shift_buttons[name]['state'] = 'normal' |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
243 else: |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
244 # disable any dangerous shifting |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
245 self.shift_buttons[name]['state'] = 'disabled' |
0 | 246 |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
247 d = self.opposite_direction(name) |
0 | 248 if scale_val != 0: |
249 # disable illegal three part crossfades | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
250 self.scales[d].disable() |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
251 self.go_buttons[d].disable() |
0 | 252 else: |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
253 # undo above work |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
254 self.scales[d].enable() |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
255 self.go_buttons[d].enable() |
167 | 256 |
257 cur_sub = self.cues_as_subs.get('Cur') | |
258 if cur_sub: | |
259 other_sub = self.cues_as_subs[name] | |
260 # print 'fade between %s and %s (%.2f)' % (cur_sub, other_sub, scale_val) | |
261 self.current_levels_as_sub = cur_sub.crossfade(other_sub, scale_val) | |
262 print "current levels", self.current_levels_as_sub.get_dmx_list() | |
263 # print | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
264 def opposite_direction(self, d): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
265 if d == 'Next': |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
266 return 'Prev' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
267 else: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
268 return 'Next' |
0 | 269 |
270 class Cue: | |
271 """A Cue has a name, a time, and any number of other attributes.""" | |
167 | 272 def __init__(self, name, time=3, sub_levels='', **attrs): |
0 | 273 self.name = name |
274 self.time = time | |
167 | 275 self.sub_levels = sub_levels |
0 | 276 self.__dict__.update(attrs) |
277 def __repr__(self): | |
278 return "<Cue %s, length %s>" % (self.name, self.time) | |
167 | 279 def get_levels_as_sub(self): |
280 """Get this Cue as a combined Submaster, normalized. This method | |
281 should not be called constantly, since it is somewhat expensive. It | |
282 will reload the submasters from disk, combine all subs together, and | |
283 then compute the normalized form.""" | |
284 subdict = {} | |
285 try: | |
286 print self, self.sub_levels | |
287 for line in self.sub_levels.split(','): | |
288 line = line.strip() | |
289 # print 'line', line | |
290 sub, scale = line.split(':') | |
291 # print 'sub', sub, 'scale', scale | |
292 sub = sub.strip() | |
293 scale = float(scale) | |
294 subdict[sub] = scale | |
295 # print 'subdict', subdict | |
296 except (ValueError, AttributeError): | |
297 print "parsing error when computing sub for", self | |
298 | |
299 s = Submaster.Submasters() | |
300 newsub = Submaster.sub_maxes(*[s[sub] * scale | |
301 for sub, scale in subdict.items()]) | |
302 return newsub.get_normalized_copy() | |
0 | 303 |
304 empty_cue = Cue('empty') | |
305 | |
306 allow_class_to_be_pickled(Cue) | |
307 | |
308 class CueList: | |
309 """Persistent list of Cues""" | |
310 def __init__(self, filename): | |
311 self.filename = filename | |
312 self.treedict = TreeDict() | |
313 try: | |
314 self.treedict.load(filename) | |
315 except IOError: | |
316 self.treedict.cues = [] | |
317 self.cues = self.treedict.cues | |
167 | 318 self.current_cue_index = -1 |
319 self.next_pointer = 0 | |
0 | 320 self.prev_pointer = None |
321 | |
322 import atexit | |
323 atexit.register(self.save) | |
324 def add_cue(self, cue, index=None): | |
325 """Adds a Cue object to the list. If no index is specified, | |
326 the cue will be added to the end.""" | |
327 index = index or len(self.cues) | |
328 self.cues.insert(index, cue) | |
329 def shift(self, diff): | |
330 """Shift through cue history""" | |
331 old_index = self.current_cue_index | |
332 self.current_cue_index = None | |
333 if diff < 0: # if going backwards | |
334 if self.prev_pointer: # use a prev pointer if we have one | |
335 self.current_cue_index = self.prev_pointer | |
336 self.next_pointer = old_index | |
337 self.prev_pointer = None | |
338 else: | |
339 if self.next_pointer: # use a next pointer if we have one | |
340 self.current_cue_index = self.next_pointer | |
341 self.next_pointer = None | |
342 self.prev_pointer = old_index | |
343 if not self.current_cue_index: | |
344 self.current_cue_index = old_index + diff | |
345 def set_next(self, index): | |
346 self.next_pointer = index | |
347 def set_prev(self, index): | |
348 self.prev_pointer = index | |
349 def bound_index(self, index): | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
350 if not self.cues: |
0 | 351 return None |
352 else: | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
353 return max(0, min(index, len(self.cues) - 1)) |
0 | 354 def get_current_cue_indices(self): |
355 cur = self.current_cue_index | |
356 return [self.bound_index(index) for index in | |
357 (self.prev_pointer or cur - 1, | |
358 cur, | |
359 self.next_pointer or cur + 1)] | |
360 def get_current_cues(self): | |
361 return [self.get_cue_by_index(index) | |
362 for index in self.get_current_cue_indices()] | |
363 def get_cue_by_index(self, index): | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
364 if index: |
0 | 365 return self.cues[self.bound_index(index)] |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
366 else: |
0 | 367 return empty_cue |
368 def __del__(self): | |
369 self.save() | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
370 def save(self): |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
371 print "Saving cues to", self.filename |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
372 self.treedict.save(self.filename) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
373 def reload(self): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
374 # TODO: we probably will need to make sure that indices still make |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
375 # sense, etc. |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
376 self.treedict.load(self.filename) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
377 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
378 class TkCueList(CueList, Tk.Frame): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
379 def __init__(self, master, filename): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
380 CueList.__init__(self, filename) |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
381 Tk.Frame.__init__(self, master, bg='black') |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
382 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
383 self.edit_tl = Tk.Toplevel() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
384 self.editor = CueEditron(self.edit_tl, changed_callback=self.redraw_cue) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
385 self.editor.pack(fill='both', expand=1) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
386 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
387 def edit_cue(index): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
388 index = int(index) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
389 self.editor.set_cue_to_edit(self.cues[index]) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
390 |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
391 self.columns = ('name', 'time', 'page', 'desc') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
392 self.scrolled_hlist = Tk.ScrolledHList(self, |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
393 options='hlist.columns %d hlist.header 1' % len(self.columns)) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
394 self.hlist = self.scrolled_hlist.hlist |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
395 self.hlist.configure(fg='white', bg='black', |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
396 command=self.select_callback, browsecmd=edit_cue) |
163 | 397 self.hlist.bind("<4>", self.wheelscroll) |
398 self.hlist.bind("<5>", self.wheelscroll) | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
399 self.scrolled_hlist.pack(fill='both', expand=1) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
400 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
401 boldfont = self.tk.call('tix', 'option', 'get', |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
402 'bold_font') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
403 header_style = Tk.DisplayStyle('text', refwindow=self, |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
404 anchor='center', padx=8, pady=2, font=boldfont) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
405 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
406 for count, header in enumerate(self.columns): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
407 self.hlist.header_create(count, itemtype='text', |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
408 text=header, style=header_style) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
409 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
410 self.cue_label_windows = {} |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
411 for count, cue in enumerate(self.cues): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
412 self.display_cue(count, cue) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
413 self.update_cue_indicators() |
163 | 414 def wheelscroll(self, evt): |
415 """Perform mouse wheel scrolling""" | |
416 amount = 2 | |
417 if evt.num == 4: | |
418 amount = -2 | |
419 self.hlist.yview('scroll', amount, 'units') | |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
420 def redraw_cue(self, cue): |
163 | 421 path = self.cues.index(cue) |
422 for col, header in enumerate(self.columns): | |
423 try: | |
424 text = getattr(cue, header) | |
425 except AttributeError: | |
426 text = '' | |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
427 |
163 | 428 if col == 0: |
429 self.cue_label_windows[path]['text'] = text | |
430 else: | |
431 self.hlist.item_configure(path, col, text=text) | |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
432 def display_cue(self, path, cue): |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
433 for col, header in enumerate(self.columns): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
434 try: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
435 text = getattr(cue, header) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
436 except AttributeError: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
437 text = '' |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
438 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
439 if col == 0: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
440 lab = Tk.Label(self.hlist, text=text, fg='white', bg='black') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
441 def select_and_highlight(event): |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
442 self.select_callback(path) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
443 self.hlist.selection_clear() |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
444 self.hlist.selection_set(path) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
445 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
446 lab.bind("<Double-1>", select_and_highlight) |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
447 self.hlist.add(path, itemtype='window', window=lab) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
448 self.cue_label_windows[path] = lab |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
449 else: |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
450 self.hlist.item_create(path, col, text=text) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
451 def reset_cue_indicators(self, cue_indices=None): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
452 """If cue_indices is None, we'll reset all of them.""" |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
453 cue_indices = cue_indices or self.cue_label_windows.keys() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
454 for key in cue_indices: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
455 window = self.cue_label_windows[key] |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
456 window.configure(fg='white', bg='black') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
457 def update_cue_indicators(self): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
458 states = dict(zip(self.get_current_cue_indices(), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
459 ('prev', 'cur', 'next'))) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
460 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
461 for count, state in states.items(): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
462 window = self.cue_label_windows[count] |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
463 bg, fg = cue_state_indicator_colors[state] |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
464 window.configure(bg=bg, fg=fg) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
465 def shift(self, diff): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
466 self.reset_cue_indicators(self.get_current_cue_indices()) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
467 CueList.shift(self, diff) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
468 self.update_cue_indicators() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
469 # try to see all indices, but next takes priority over all, and cur |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
470 # over prev |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
471 for index in self.get_current_cue_indices(): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
472 self.hlist.see(index) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
473 def select_callback(self, index): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
474 new_next = int(index) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
475 self.set_next(new_next) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
476 def set_next(self, index): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
477 prev, cur, next = self.get_current_cue_indices() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
478 self.reset_cue_indicators((next,)) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
479 CueList.set_next(self, index) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
480 self.update_cue_indicators() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
481 def set_prev(self, index): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
482 prev, cur, next = self.get_current_cue_indices() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
483 self.reset_cue_indicators((prev,)) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
484 CueList.set_prev(self, index) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
485 self.update_cue_indicators() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
486 def set_selection_as_prev(self): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
487 sel = self.hlist.info_selection() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
488 if sel: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
489 self.set_prev(int(sel[0])) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
490 def set_selection_as_next(self): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
491 sel = self.hlist.info_selection() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
492 if sel: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
493 self.set_next(int(sel[0])) |
0 | 494 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
495 class CueEditron(Tk.Frame): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
496 def __init__(self, master, changed_callback=None, cue=None): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
497 Tk.Frame.__init__(self, master, bg='black') |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
498 self.master = master |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
499 self.cue = cue |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
500 self.changed_callback = changed_callback |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
501 self.enable_callbacks = 1 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
502 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
503 self.setup_editing_forms() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
504 self.set_cue_to_edit(cue) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
505 def set_cue_to_edit(self, cue): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
506 if cue != self.cue: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
507 self.cue = cue |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
508 self.fill_in_cue_info() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
509 self.set_title() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
510 def set_title(self): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
511 try: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
512 self.master.title("Editing '%s'" % self.cue.name) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
513 except AttributeError: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
514 pass |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
515 def setup_editing_forms(self): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
516 self.variables = {} |
167 | 517 for row, field in enumerate(('name', 'time', 'page', 'desc', 'sub_levels')): |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
518 lab = Tk.Label(self, text=field, fg='white', bg='black') |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
519 lab.grid(row=row, column=0, sticky='nsew') |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
520 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
521 entryvar = Tk.StringVar() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
522 entry = Tk.Entry(self, fg='white', bg='black', |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
523 textvariable=entryvar) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
524 entry.grid(row=row, column=1, sticky='nsew') |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
525 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
526 self.variables[field] = entryvar |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
527 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
528 def field_changed(x, y, z, field=field, entryvar=entryvar): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
529 if self.cue: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
530 setattr(self.cue, field, entryvar.get()) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
531 if self.enable_callbacks and self.changed_callback: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
532 self.changed_callback(self.cue) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
533 if field == 'name': |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
534 self.set_title() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
535 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
536 entryvar.trace('w', field_changed) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
537 self.columnconfigure(1, weight=1) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
538 def fill_in_cue_info(self): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
539 self.enable_callbacks = 0 |
167 | 540 for row, field in enumerate(('name', 'time', 'page', 'desc', 'sub_levels')): |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
541 text = '' |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
542 if self.cue: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
543 try: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
544 text = getattr(self.cue, field) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
545 except AttributeError: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
546 pass |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
547 self.variables[field].set(text) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
548 self.enable_callbacks = 1 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
549 |
0 | 550 if __name__ == "__main__": |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
551 root = Tk.Tk() |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
552 root.title("ShowMaster 9000") |
163 | 553 root.geometry("500x555") |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
554 cl = TkCueList(root, 'cues/cuelist1') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
555 cl.pack(fill='both', expand=1) |
0 | 556 |
157 | 557 fader = CueFader(root, cl) |
558 fader.pack(fill='both', expand=1) | |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
559 try: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
560 Tk.mainloop() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
561 except KeyboardInterrupt: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
562 root.destroy() |