Changeset - 6c5753bad783
[Not reviewed]
default
0 2 0
dmcc - 21 years ago 2003-07-08 07:10:20

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)
2 files changed with 200 insertions and 81 deletions:
0 comments (0 inline, 0 general)
flax/CueFaders.py
Show inline comments
 
@@ -14,7 +14,7 @@ cue_state_indicator_colors = {
 
class LabelledScale(Tk.Frame):
 
    """Scale with two labels: a name and current value"""
 
    def __init__(self, master, label, **opts):
 
        Tk.Frame.__init__(self, master, bd=2, relief='raised')
 
        Tk.Frame.__init__(self, master, bd=2, relief='raised', bg='black')
 
        opts.setdefault('variable', Tk.DoubleVar())
 
        opts.setdefault('showvalue', 0)
 

	
 
@@ -25,9 +25,9 @@ class LabelledScale(Tk.Frame):
 
        self.scale_var = opts['variable']
 
        self.scale = Tk.Scale(self, **opts)
 
        self.scale.pack(side='top', expand=1, fill='both')
 
        self.name = Tk.Label(self, text=label)
 
        self.name = Tk.Label(self, text=label, bg='black', fg='white')
 
        self.name.pack(side='bottom')
 
        self.scale_value = Tk.Label(self, width=6)
 
        self.scale_value = Tk.Label(self, width=6, bg='black', fg='white')
 
        self.scale_value.pack(side='bottom')
 
        self.scale_var.trace('w', self.update_value_label)
 
        self.update_value_label()
 
@@ -54,15 +54,17 @@ class LabelledScale(Tk.Frame):
 
class TimedGoButton(Tk.Frame):
 
    """Go button, fade time entry, and time fader"""
 
    def __init__(self, master, name, scale_to_fade, **kw):
 
        Tk.Frame.__init__(self, master)
 
        Tk.Frame.__init__(self, master, bg='black')
 
        self.name = name
 
        self.scale_to_fade = scale_to_fade
 
        self.button = Tk.Button(self, text=name, command=self.start_fade, **kw)
 
        self.button.pack(fill='both', expand=1, side='left')
 
        self.timer_var = Tk.StringVar()
 
        self.timer_entry = Tk.Entry(self, textvariable=self.timer_var, width=5)
 

	
 
        self.timer_var = Tk.DoubleVar()
 
        self.timer_entry = Tk.Control(self, step=0.5, min=0, integer=0)
 
        self.timer_entry.entry.configure(textvariable=self.timer_var, width=5, 
 
            bg='black', fg='white')
 
        self.timer_entry.pack(fill='y', side='left')
 
        self.timer_var.set("2")
 
        self.disabled = (self.button['state'] == 'disabled')
 
    def start_fade(self, end_level=1):
 
        try:
 
@@ -97,10 +99,12 @@ class TimedGoButton(Tk.Frame):
 
        if self.disabled:
 
            self.button['state'] = 'normal'
 
            self.disabled = 0
 
    def set_time(self, time):
 
        self.timer_var.set(time)
 

	
 
class CueFader(Tk.Frame):
 
    def __init__(self, master, cuelist):
 
        Tk.Frame.__init__(self, master)
 
        Tk.Frame.__init__(self, master, bg='black')
 
        self.cuelist = cuelist
 
        self.auto_shift = Tk.IntVar()
 
        self.auto_shift.set(1)
 
@@ -115,7 +119,7 @@ class CueFader(Tk.Frame):
 
        self.shift_buttons = {}
 
        self.go_buttons = {}
 
        
 
        topframe = Tk.Frame(self)
 
        topframe = Tk.Frame(self, bg='black')
 

	
 
        self.set_prev_button = Tk.Button(topframe, text='Set Prev',
 
            command=lambda: cuelist.set_selection_as_prev(),
 
@@ -124,7 +128,7 @@ class CueFader(Tk.Frame):
 

	
 
        self.auto_shift_checkbutton = Tk.Checkbutton(topframe, 
 
            variable=self.auto_shift, text='Autoshift', 
 
            command=self.toggle_autoshift)
 
            command=self.toggle_autoshift, bg='black', fg='white')
 
        self.auto_shift_checkbutton.pack(side='left')
 

	
 
        self.set_next_button = Tk.Button(topframe, text='Set Next',
 
@@ -134,11 +138,11 @@ class CueFader(Tk.Frame):
 

	
 
        topframe.pack(side='top')
 

	
 
        faderframe = Tk.Frame(self)
 
        faderframe = Tk.Frame(self, bg='black')
 
        self.direction_info = (('Prev', 1, 0, 'left', 'blue'),
 
                               ('Next', 0, 1, 'right', 'red'))
 
        for name, start, end, side, color in self.direction_info:
 
            frame = Tk.Frame(self)
 
            frame = Tk.Frame(self, bg='black')
 
            scale = LabelledScale(frame, name, from_=start, to_=end, 
 
                res=0.0001, orient='horiz', flashtroughcolor=color)
 
            scale.pack(fill='x', expand=0)
 
@@ -290,6 +294,7 @@ class CueList:
 
    def __del__(self):
 
        self.save()
 
    def save(self):
 
        print "Saving cues to", self.filename
 
        self.treedict.save(self.filename)
 
    def reload(self):
 
        # TODO: we probably will need to make sure that indices still make
 
@@ -299,15 +304,22 @@ class CueList:
 
class TkCueList(CueList, Tk.Frame):
 
    def __init__(self, master, filename):
 
        CueList.__init__(self, filename)
 
        Tk.Frame.__init__(self, master)
 
        Tk.Frame.__init__(self, master, bg='black')
 
        
 
        self.edit_tl = Tk.Toplevel()
 
        self.editor = CueEditron(self.edit_tl, changed_callback=self.redraw_cue)
 
        self.editor.pack(fill='both', expand=1)
 

	
 
        def edit_cue(index):
 
            index = int(index)
 
            self.editor.set_cue_to_edit(self.cues[index])
 
            
 
        self.columns = ('name', 'time', 'page', 'desc')
 
            
 
        self.scrolled_hlist = Tk.ScrolledHList(self,
 
            options='hlist.columns %d hlist.header 1' % len(self.columns))
 
        self.hlist = self.scrolled_hlist.hlist
 
        self.hlist.configure(fg='white', bg='black', 
 
            command=self.select_callback)
 
            command=self.select_callback, browsecmd=edit_cue)
 
        self.scrolled_hlist.pack(fill='both', expand=1)
 

	
 
        boldfont = self.tk.call('tix', 'option', 'get', 
 
@@ -323,8 +335,27 @@ class TkCueList(CueList, Tk.Frame):
 
        for count, cue in enumerate(self.cues):
 
            self.display_cue(count, cue)
 
        self.update_cue_indicators()
 
    def display_cue(self, cue_count, cue):
 
        # cue_count is the path in the hlist -- this probably isn't ideal
 

	
 
    def redraw_cue(self, cue):
 
        if 0:
 
            # TODO: this is really inefficient
 
            self.hlist.delete_all()
 
            for count, cue in enumerate(self.cues):
 
                self.display_cue(count, cue)
 
            self.update_cue_indicators()
 
        else:
 
            path = self.cues.index(cue)
 
            for col, header in enumerate(self.columns):
 
                try:
 
                    text = getattr(cue, header)
 
                except AttributeError:
 
                    text = ''
 

	
 
                if col == 0:
 
                    self.cue_label_windows[path]['text'] = text
 
                else:
 
                    self.hlist.item_configure(path, col, text=text)
 
    def display_cue(self, path, cue):
 
        for col, header in enumerate(self.columns):
 
            try:
 
                text = getattr(cue, header)
 
@@ -334,15 +365,15 @@ class TkCueList(CueList, Tk.Frame):
 
            if col == 0:
 
                lab = Tk.Label(self.hlist, text=text, fg='white', bg='black')
 
                def select_and_highlight(event):
 
                    self.select_callback(cue_count)
 
                    self.select_callback(path)
 
                    self.hlist.selection_clear()
 
                    self.hlist.selection_set(cue_count)
 
                    self.hlist.selection_set(path)
 

	
 
                lab.bind("<Double-1>", select_and_highlight)
 
                self.hlist.add(cue_count, itemtype='window', window=lab)
 
                self.cue_label_windows[cue_count] = lab
 
                self.hlist.add(path, itemtype='window', window=lab)
 
                self.cue_label_windows[path] = lab
 
            else:
 
                self.hlist.item_create(cue_count, col, text=text)
 
                self.hlist.item_create(path, col, text=text)
 
    def reset_cue_indicators(self, cue_indices=None):
 
        """If cue_indices is None, we'll reset all of them."""
 
        cue_indices = cue_indices or self.cue_label_windows.keys()
 
@@ -387,16 +418,70 @@ class TkCueList(CueList, Tk.Frame):
 
        if sel:
 
            self.set_next(int(sel[0]))
 

	
 
class CueEditron(Tk.Frame):
 
    def __init__(self, master, changed_callback=None, cue=None):
 
        Tk.Frame.__init__(self, master, bg='black')
 
        self.master = master
 
        self.cue = cue
 
        self.changed_callback = changed_callback
 
        self.enable_callbacks = 1
 

	
 
        self.setup_editing_forms()
 
        self.set_cue_to_edit(cue)
 
    def set_cue_to_edit(self, cue):
 
        if cue != self.cue:
 
            self.cue = cue
 
            self.fill_in_cue_info()
 
            self.set_title()
 
    def set_title(self):
 
            try:
 
                self.master.title("Editing '%s'" % self.cue.name)
 
            except AttributeError:
 
                pass
 
    def setup_editing_forms(self):
 
        self.variables = {}
 
        for row, field in enumerate(('name', 'time', 'page', 'desc')):
 
            lab = Tk.Label(self, text=field, fg='white', bg='black')
 
            lab.grid(row=row, column=0, sticky='nsew')
 

	
 
            entryvar = Tk.StringVar()
 
            entry = Tk.Entry(self, fg='white', bg='black', 
 
                textvariable=entryvar)
 
            entry.grid(row=row, column=1, sticky='nsew')
 

	
 
            self.variables[field] = entryvar
 

	
 
            def field_changed(x, y, z, field=field, entryvar=entryvar):
 
                if self.cue:
 
                    setattr(self.cue, field, entryvar.get())
 
                    if self.enable_callbacks and self.changed_callback:
 
                        self.changed_callback(self.cue)
 
                if field == 'name':
 
                    self.set_title()
 

	
 
            entryvar.trace('w', field_changed)
 
        self.columnconfigure(1, weight=1)
 
    def fill_in_cue_info(self):
 
        self.enable_callbacks = 0
 
        for row, field in enumerate(('name', 'time', 'page', 'desc')):
 
            text = ''
 
            if self.cue:
 
                try:
 
                    text = getattr(self.cue, field)
 
                except AttributeError:
 
                    pass
 
            self.variables[field].set(text)
 
        self.enable_callbacks = 1
 

	
 
if __name__ == "__main__":
 
    root = Tk.Tk()
 
    root.title("ShowMaster 9000")
 
    cl = TkCueList(root, 'cues/cuelist1')
 
    cl.pack(fill='both', expand=1)
 

	
 
    # to populate cue list
 
    if 0:
 
        for x in range(20):
 
            cl.add_cue(Cue('cue %d' % x, time=x, some_attribute=3))
 

	
 
    fader = CueFader(root, cl)
 
    fader.pack(fill='both', expand=1)
 
    Tk.mainloop()
 
    try:
 
        Tk.mainloop()
 
    except KeyboardInterrupt:
 
        root.destroy()
flax/cues/cuelist1
Show inline comments
 
<?xml version="1.0"?>
 
<!DOCTYPE PyObject SYSTEM "PyObjects.dtd">
 
<PyObject family="obj" type="builtin_wrapper"  class="_EmptyClass">
 
<attr name="__toplevel__" family="map" type="__compound__" extra="None TreeDict" id="138321692" >
 
<attr name="__toplevel__" family="map" type="__compound__" extra="None TreeDict" id="138329300" >
 
  <entry>
 
    <key type="string" value="cues" />
 
    <val type="list" id="140057044" >
 
      <item type="PyObject" id="139705788" class="Cue">
 
    <val type="list" id="139739116" >
 
      <item type="PyObject" id="139739148" class="Cue">
 
        <attr name="desc" type="string" value="whoa - this works" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 0" />
 
        <attr name="time" type="numeric" value="0" />
 
        <attr name="name" type="string" value="tevya special" />
 
        <attr name="page" type="string" value="3.2" />
 
        <attr name="time" type="string" value="0" />
 
      </item>
 
      <item type="PyObject" id="138399700" class="Cue">
 
      <item type="PyObject" id="140193340" class="Cue">
 
        <attr name="desc" type="string" value="music flourish" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 1" />
 
        <attr name="time" type="numeric" value="1" />
 
        <attr name="name" type="string" value="lady luck" />
 
        <attr name="page" type="string" value="1.1.5" />
 
        <attr name="time" type="string" value="1" />
 
      </item>
 
      <item type="PyObject" id="139651028" class="Cue">
 
      <item type="PyObject" id="139732196" class="Cue">
 
        <attr name="desc" type="string" value="tevya: &quot;what&apos;s happening to the tradition?&quot;" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 2" />
 
        <attr name="time" type="numeric" value="2" />
 
        <attr name="name" type="string" value="dolly solo" />
 
        <attr name="page" type="string" value="1.2.10" />
 
        <attr name="time" type="string" value="2" />
 
      </item>
 
      <item type="PyObject" id="139651716" class="Cue">
 
      <item type="PyObject" id="139670412" class="Cue">
 
        <attr name="desc" type="string" value="the third cue" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 3" />
 
        <attr name="time" type="numeric" value="3" />
 
        <attr name="page" type="string" value="1.2.14" />
 
        <attr name="time" type="string" value="41" />
 
      </item>
 
      <item type="PyObject" id="140056788" class="Cue">
 
        <attr name="time" type="numeric" value="4" />
 
      <item type="PyObject" id="139670188" class="Cue">
 
        <attr name="time" type="string" value="42" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 4" />
 
        <attr name="name" type="string" value="heart" />
 
        <attr name="page" type="string" value="1.3.13" />
 
        <attr name="desc" type="string" value="&quot;you&apos;ve gotta have heart&quot;" />
 
      </item>
 
      <item type="PyObject" id="139731244" class="Cue">
 
        <attr name="time" type="numeric" value="5" />
 
      <item type="PyObject" id="140189388" class="Cue">
 
        <attr name="time" type="string" value="5" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 5" />
 
        <attr name="name" type="string" value="more musical refs" />
 
        <attr name="page" type="string" value="1.3.17" />
 
        <attr name="desc" type="string" value="etc." />
 
      </item>
 
      <item type="PyObject" id="139724292" class="Cue">
 
        <attr name="time" type="numeric" value="6" />
 
      <item type="PyObject" id="139668940" class="Cue">
 
        <attr name="time" type="string" value="6" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 6" />
 
        <attr name="name" type="string" value="rainbow shimmer" />
 
        <attr name="page" type="string" value="1.4.2" />
 
        <attr name="desc" type="string" value="curtain close" />
 
      </item>
 
      <item type="PyObject" id="138615364" class="Cue">
 
        <attr name="time" type="numeric" value="7" />
 
      <item type="PyObject" id="139669364" class="Cue">
 
        <attr name="time" type="string" value="7" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 7" />
 
        <attr name="name" type="string" value="fade up" />
 
        <attr name="page" type="string" value="2.1.1" />
 
        <attr name="desc" type="string" value="stage manager: &quot;worklights, please&quot;" />
 
      </item>
 
      <item type="PyObject" id="139653716" class="Cue">
 
        <attr name="time" type="numeric" value="8" />
 
      <item type="PyObject" id="139669612" class="Cue">
 
        <attr name="time" type="string" value="8" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 8" />
 
        <attr name="name" type="string" value="blackout" />
 
        <attr name="page" type="string" value="2.1.2" />
 
        <attr name="desc" type="string" value="&quot;lights out!&quot;" />
 
      </item>
 
      <item type="PyObject" id="140059964" class="Cue">
 
        <attr name="time" type="numeric" value="9" />
 
      <item type="PyObject" id="140191124" class="Cue">
 
        <attr name="time" type="string" value="4.2" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 9" />
 
        <attr name="name" type="string" value="sill" />
 
        <attr name="page" type="string" value="2.2.4" />
 
        <attr name="desc" type="string" value="another description" />
 
      </item>
 
      <item type="PyObject" id="139654716" class="Cue">
 
      <item type="PyObject" id="139659252" class="Cue">
 
        <attr name="desc" type="string" value="mr. cue 10" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 10" />
 
        <attr name="time" type="numeric" value="10" />
 
        <attr name="name" type="string" value="front only" />
 
        <attr name="page" type="string" value="2.7.3" />
 
        <attr name="time" type="string" value="10" />
 
      </item>
 
      <item type="PyObject" id="139654900" class="Cue">
 
      <item type="PyObject" id="139668700" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 11" />
 
        <attr name="time" type="numeric" value="11" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="11" />
 
      </item>
 
      <item type="PyObject" id="139655084" class="Cue">
 
      <item type="PyObject" id="140191524" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 12" />
 
        <attr name="time" type="numeric" value="12" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="12" />
 
      </item>
 
      <item type="PyObject" id="139655124" class="Cue">
 
      <item type="PyObject" id="140192284" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 13" />
 
        <attr name="time" type="numeric" value="13" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="13" />
 
      </item>
 
      <item type="PyObject" id="139655364" class="Cue">
 
      <item type="PyObject" id="136493292" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 14" />
 
        <attr name="time" type="numeric" value="14" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="14" />
 
      </item>
 
      <item type="PyObject" id="139655548" class="Cue">
 
      <item type="PyObject" id="140192468" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 15" />
 
        <attr name="time" type="numeric" value="15" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="15" />
 
      </item>
 
      <item type="PyObject" id="139655588" class="Cue">
 
      <item type="PyObject" id="140183372" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 16" />
 
        <attr name="time" type="numeric" value="16" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="16" />
 
      </item>
 
      <item type="PyObject" id="140051868" class="Cue">
 
      <item type="PyObject" id="138407588" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 17" />
 
        <attr name="time" type="numeric" value="17" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="17" />
 
      </item>
 
      <item type="PyObject" id="139652364" class="Cue">
 
      <item type="PyObject" id="139668204" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 18" />
 
        <attr name="time" type="numeric" value="18" />
 
        <attr name="name" type="string" value="some name" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="18" />
 
      </item>
 
      <item type="PyObject" id="140041636" class="Cue">
 
      <item type="PyObject" id="140191596" class="Cue">
 
        <attr name="desc" type="string" value="" />
 
        <attr name="some_attribute" type="numeric" value="3" />
 
        <attr name="name" type="string" value="cue 19" />
 
        <attr name="time" type="numeric" value="19" />
 
        <attr name="page" type="string" value="" />
 
        <attr name="time" type="string" value="19" />
 
      </item>
 
    </val>
 
  </entry>
0 comments (0 inline, 0 general)