Mercurial > code > home > repos > light9
annotate flax/CueFaders.py @ 162:6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
basic cue editing, darker colors, fade time selector is now a "TixControl"
(spin box)
author | dmcc |
---|---|
date | Tue, 08 Jul 2003 07:10:20 +0000 |
parents | 0803fb42109d |
children | e0c227168519 |
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 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
6 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
7 cue_state_indicator_colors = { |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
8 # bg fg |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
9 'prev' : ('blue', 'white'), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
10 'cur' : ('yellow', 'black'), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
11 'next' : ('red', 'white'), |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
12 } |
0 | 13 |
14 class LabelledScale(Tk.Frame): | |
15 """Scale with two labels: a name and current value""" | |
16 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
|
17 Tk.Frame.__init__(self, master, bd=2, relief='raised', bg='black') |
0 | 18 opts.setdefault('variable', Tk.DoubleVar()) |
19 opts.setdefault('showvalue', 0) | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
20 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
21 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
|
22 self.flashtrough = opts.get('flashtroughcolor', 'red') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
23 del opts['flashtroughcolor'] |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
24 |
0 | 25 self.scale_var = opts['variable'] |
26 self.scale = Tk.Scale(self, **opts) | |
27 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
|
28 self.name = Tk.Label(self, text=label, bg='black', fg='white') |
0 | 29 self.name.pack(side='bottom') |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
30 self.scale_value = Tk.Label(self, width=6, bg='black', fg='white') |
0 | 31 self.scale_value.pack(side='bottom') |
32 self.scale_var.trace('w', self.update_value_label) | |
33 self.update_value_label() | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
34 self.disabled = (self.scale['state'] == 'disabled') |
0 | 35 def set_label(self, label): |
36 self.name['text'] = label | |
37 def update_value_label(self, *args): | |
38 val = self.scale_var.get() * 100 | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
39 self.scale_value['text'] = "%0.2f" % val |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
40 if val != 0: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
41 self.scale['troughcolor'] = self.flashtrough |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
42 else: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
43 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
|
44 def disable(self): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
45 if not self.disabled: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
46 self.scale['state'] = 'disabled' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
47 self.scale_var.set(0) |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
48 self.disabled = 1 |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
49 def enable(self): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
50 if self.disabled: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
51 self.scale['state'] = 'normal' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
52 self.disabled = 0 |
0 | 53 |
54 class TimedGoButton(Tk.Frame): | |
55 """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
|
56 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
|
57 Tk.Frame.__init__(self, master, bg='black') |
0 | 58 self.name = name |
59 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
|
60 self.button = Tk.Button(self, text=name, command=self.start_fade, **kw) |
0 | 61 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
|
62 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
63 self.timer_var = Tk.DoubleVar() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
64 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
|
65 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
|
66 bg='black', fg='white') |
0 | 67 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
|
68 self.disabled = (self.button['state'] == 'disabled') |
0 | 69 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
|
70 try: |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
71 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
|
72 except ValueError: |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
73 # TODO figure out how to handle this |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
74 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
|
75 return |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
76 |
0 | 77 self.start_time = time.time() |
78 self.start_level = self.scale_to_fade.scale_var.get() | |
79 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
|
80 self.fade_length = fade_time |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
81 self.do_fade() |
0 | 82 def do_fade(self): |
83 diff = time.time() - self.start_time | |
84 if diff < self.fade_length: | |
85 percent = diff / self.fade_length | |
86 newlevel = self.start_level + \ | |
87 (percent * (self.end_level - self.start_level)) | |
88 self.scale_to_fade.scale_var.set(newlevel) | |
89 | |
90 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
|
91 self.after(10, self.do_fade) |
0 | 92 else: |
93 self.scale_to_fade.scale_var.set(self.end_level) | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
94 def disable(self): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
95 if not self.disabled: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
96 self.button['state'] = 'disabled' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
97 self.disabled = 1 |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
98 def enable(self): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
99 if self.disabled: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
100 self.button['state'] = 'normal' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
101 self.disabled = 0 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
102 def set_time(self, time): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
103 self.timer_var.set(time) |
0 | 104 |
105 class CueFader(Tk.Frame): | |
106 def __init__(self, master, cuelist): | |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
107 Tk.Frame.__init__(self, master, bg='black') |
0 | 108 self.cuelist = cuelist |
155 | 109 self.auto_shift = Tk.IntVar() |
110 self.auto_shift.set(1) | |
0 | 111 |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
112 # 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
|
113 # 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
|
114 # 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
|
115 # 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
|
116 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
|
117 |
0 | 118 self.scales = {} |
119 self.shift_buttons = {} | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
120 self.go_buttons = {} |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
121 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
122 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
|
123 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
124 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
|
125 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
|
126 fg='white', bg='blue') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
127 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
|
128 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
129 self.auto_shift_checkbutton = Tk.Checkbutton(topframe, |
155 | 130 variable=self.auto_shift, text='Autoshift', |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
131 command=self.toggle_autoshift, bg='black', fg='white') |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
132 self.auto_shift_checkbutton.pack(side='left') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
133 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
134 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
|
135 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
|
136 fg='white', bg='red') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
137 self.set_next_button.pack(side='left') |
155 | 138 |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
139 topframe.pack(side='top') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
140 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
141 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
|
142 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
|
143 ('Next', 0, 1, 'right', 'red')) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
144 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
|
145 frame = Tk.Frame(self, bg='black') |
0 | 146 scale = LabelledScale(frame, name, from_=start, to_=end, |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
147 res=0.0001, orient='horiz', flashtroughcolor=color) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
148 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
|
149 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
|
150 fg='white') |
0 | 151 go.pack(fill='both', expand=1) |
152 frame.pack(side=side, fill='both', expand=1) | |
153 | |
155 | 154 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
|
155 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
|
156 bg='black') |
155 | 157 |
0 | 158 self.scales[name] = scale |
159 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
|
160 self.go_buttons[name] = go |
0 | 161 |
162 scale.scale_var.trace('w', \ | |
163 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
|
164 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 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
|
169 self.autoshift(name, scale) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
170 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
171 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
|
172 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
|
173 faderframe.pack(side='bottom', fill='both', expand=1) |
155 | 174 def toggle_autoshift(self): |
175 for name, button in self.shift_buttons.items(): | |
176 if not self.auto_shift.get(): | |
177 button.pack(side='bottom', fill='both', expand=1) | |
178 else: | |
179 button.pack_forget() | |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
180 def shift(self, name): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
181 # to prevent overshifting |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
182 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
|
183 return |
155 | 184 |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
185 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
|
186 scale.scale.set(0) |
0 | 187 self.cuelist.shift((-1, 1)[name == 'Next']) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
188 def autoshift(self, name, scale): |
0 | 189 scale_val = scale.scale_var.get() |
190 | |
191 if scale_val == 1: | |
155 | 192 if self.auto_shift.get(): |
0 | 193 self.shift(name) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
194 def xfade(self, name, scale): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
195 if self.auto_shift.get(): |
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 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
|
198 else: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
199 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
|
200 if scale_val == 1: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
201 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
|
202 else: |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
203 # disable any dangerous shifting |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
204 self.shift_buttons[name]['state'] = 'disabled' |
0 | 205 |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
206 d = self.opposite_direction(name) |
0 | 207 if scale_val != 0: |
208 # 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
|
209 self.scales[d].disable() |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
210 self.go_buttons[d].disable() |
0 | 211 else: |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
212 # undo above work |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
213 self.scales[d].enable() |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
214 self.go_buttons[d].enable() |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
215 def opposite_direction(self, d): |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
216 if d == 'Next': |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
217 return 'Prev' |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
218 else: |
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
219 return 'Next' |
0 | 220 |
221 class Cue: | |
222 """A Cue has a name, a time, and any number of other attributes.""" | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
223 def __init__(self, name, time=3, **attrs): |
0 | 224 self.name = name |
225 self.time = time | |
226 self.__dict__.update(attrs) | |
227 def __repr__(self): | |
228 return "<Cue %s, length %s>" % (self.name, self.time) | |
229 | |
230 empty_cue = Cue('empty') | |
231 | |
232 allow_class_to_be_pickled(Cue) | |
233 | |
234 class CueList: | |
235 """Persistent list of Cues""" | |
236 def __init__(self, filename): | |
237 self.filename = filename | |
238 self.treedict = TreeDict() | |
239 try: | |
240 self.treedict.load(filename) | |
241 except IOError: | |
242 self.treedict.cues = [] | |
243 self.cues = self.treedict.cues | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
244 self.current_cue_index = 0 |
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
245 self.next_pointer = None |
0 | 246 self.prev_pointer = None |
247 | |
248 import atexit | |
249 atexit.register(self.save) | |
250 def add_cue(self, cue, index=None): | |
251 """Adds a Cue object to the list. If no index is specified, | |
252 the cue will be added to the end.""" | |
253 index = index or len(self.cues) | |
254 self.cues.insert(index, cue) | |
255 def shift(self, diff): | |
256 """Shift through cue history""" | |
257 old_index = self.current_cue_index | |
258 self.current_cue_index = None | |
259 if diff < 0: # if going backwards | |
260 if self.prev_pointer: # use a prev pointer if we have one | |
261 self.current_cue_index = self.prev_pointer | |
262 self.next_pointer = old_index | |
263 self.prev_pointer = None | |
264 else: | |
265 if self.next_pointer: # use a next pointer if we have one | |
266 self.current_cue_index = self.next_pointer | |
267 self.next_pointer = None | |
268 self.prev_pointer = old_index | |
269 if not self.current_cue_index: | |
270 self.current_cue_index = old_index + diff | |
271 def set_next(self, index): | |
272 self.next_pointer = index | |
273 def set_prev(self, index): | |
274 self.prev_pointer = index | |
275 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
|
276 if not self.cues: |
0 | 277 return None |
278 else: | |
158
5c7ac46e33d3
more disabling of stuff that make no sense at certain times and some
dmcc
parents:
157
diff
changeset
|
279 return max(0, min(index, len(self.cues) - 1)) |
0 | 280 def get_current_cue_indices(self): |
281 cur = self.current_cue_index | |
282 return [self.bound_index(index) for index in | |
283 (self.prev_pointer or cur - 1, | |
284 cur, | |
285 self.next_pointer or cur + 1)] | |
286 def get_current_cues(self): | |
287 return [self.get_cue_by_index(index) | |
288 for index in self.get_current_cue_indices()] | |
289 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
|
290 if index: |
0 | 291 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
|
292 else: |
0 | 293 return empty_cue |
294 def __del__(self): | |
295 self.save() | |
151
990a9474d0e7
early cue stuff. the CueList will supply the CueFader with the cues to
dmcc
parents:
0
diff
changeset
|
296 def save(self): |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
297 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
|
298 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
|
299 def reload(self): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
300 # 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
|
301 # sense, etc. |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
302 self.treedict.load(self.filename) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
303 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
304 class TkCueList(CueList, Tk.Frame): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
305 def __init__(self, master, filename): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
306 CueList.__init__(self, filename) |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
307 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
|
308 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
309 self.edit_tl = Tk.Toplevel() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
310 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
|
311 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
|
312 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
313 def edit_cue(index): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
314 index = int(index) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
315 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
|
316 |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 command=self.select_callback, browsecmd=edit_cue) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
323 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
|
324 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
325 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
|
326 'bold_font') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
327 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
|
328 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
|
329 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
330 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
|
331 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
|
332 text=header, style=header_style) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
333 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
334 self.cue_label_windows = {} |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
335 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
|
336 self.display_cue(count, cue) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
337 self.update_cue_indicators() |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
338 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
339 def redraw_cue(self, cue): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
340 if 0: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
341 # TODO: this is really inefficient |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
342 self.hlist.delete_all() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
343 for count, cue in enumerate(self.cues): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
344 self.display_cue(count, cue) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
345 self.update_cue_indicators() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
346 else: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
347 path = self.cues.index(cue) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
348 for col, header in enumerate(self.columns): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
349 try: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
350 text = getattr(cue, header) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
351 except AttributeError: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
352 text = '' |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
353 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
354 if col == 0: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
355 self.cue_label_windows[path]['text'] = text |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
356 else: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
357 self.hlist.item_configure(path, col, text=text) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
358 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
|
359 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
|
360 try: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
361 text = getattr(cue, header) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
362 except AttributeError: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
363 text = '' |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
364 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
365 if col == 0: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
366 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
|
367 def select_and_highlight(event): |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
368 self.select_callback(path) |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
369 self.hlist.selection_clear() |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
370 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
|
371 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
372 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
|
373 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
|
374 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
|
375 else: |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
376 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
|
377 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
|
378 """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
|
379 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
|
380 for key in cue_indices: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
381 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
|
382 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
|
383 def update_cue_indicators(self): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
384 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
|
385 ('prev', 'cur', 'next'))) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
386 |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
387 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
|
388 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
|
389 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
|
390 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
|
391 def shift(self, diff): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
392 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
|
393 CueList.shift(self, diff) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
394 self.update_cue_indicators() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
395 # 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
|
396 # over prev |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
397 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
|
398 self.hlist.see(index) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
399 def select_callback(self, index): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
400 new_next = int(index) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
401 self.set_next(new_next) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
402 def set_next(self, index): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
403 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
|
404 self.reset_cue_indicators((next,)) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
405 CueList.set_next(self, index) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
406 self.update_cue_indicators() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
407 def set_prev(self, index): |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
408 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
|
409 self.reset_cue_indicators((prev,)) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
410 CueList.set_prev(self, index) |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
411 self.update_cue_indicators() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
412 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
|
413 sel = self.hlist.info_selection() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
414 if sel: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
415 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
|
416 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
|
417 sel = self.hlist.info_selection() |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
418 if sel: |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
419 self.set_next(int(sel[0])) |
0 | 420 |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
421 class CueEditron(Tk.Frame): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
422 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
|
423 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
|
424 self.master = master |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
425 self.cue = cue |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
426 self.changed_callback = changed_callback |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
427 self.enable_callbacks = 1 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
428 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
429 self.setup_editing_forms() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
430 self.set_cue_to_edit(cue) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
431 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
|
432 if cue != self.cue: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
433 self.cue = cue |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
434 self.fill_in_cue_info() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
435 self.set_title() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
436 def set_title(self): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
437 try: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
438 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
|
439 except AttributeError: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
440 pass |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
441 def setup_editing_forms(self): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
442 self.variables = {} |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
443 for row, field in enumerate(('name', 'time', 'page', 'desc')): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
444 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
|
445 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
|
446 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
447 entryvar = Tk.StringVar() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
448 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
|
449 textvariable=entryvar) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
450 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
|
451 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
452 self.variables[field] = entryvar |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
453 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
454 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
|
455 if self.cue: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
456 setattr(self.cue, field, entryvar.get()) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
457 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
|
458 self.changed_callback(self.cue) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
459 if field == 'name': |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
460 self.set_title() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
461 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
462 entryvar.trace('w', field_changed) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
463 self.columnconfigure(1, weight=1) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
464 def fill_in_cue_info(self): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
465 self.enable_callbacks = 0 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
466 for row, field in enumerate(('name', 'time', 'page', 'desc')): |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
467 text = '' |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
468 if self.cue: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
469 try: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
470 text = getattr(self.cue, field) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
471 except AttributeError: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
472 pass |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
473 self.variables[field].set(text) |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
474 self.enable_callbacks = 1 |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
475 |
0 | 476 if __name__ == "__main__": |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
477 root = Tk.Tk() |
162
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
478 root.title("ShowMaster 9000") |
161
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
479 cl = TkCueList(root, 'cues/cuelist1') |
0803fb42109d
we now have TkCueList, which is really cool. it doesn't provide editing
dmcc
parents:
158
diff
changeset
|
480 cl.pack(fill='both', expand=1) |
0 | 481 |
157 | 482 fader = CueFader(root, cl) |
483 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
|
484 try: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
485 Tk.mainloop() |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
486 except KeyboardInterrupt: |
6c5753bad783
basic cue editing, darker colors, fade time selector is now a "TixControl"
dmcc
parents:
161
diff
changeset
|
487 root.destroy() |