comparison light8/Fader.py @ 52:065896b0913c

emergency commit
author dmcc
date Mon, 08 Jul 2002 03:25:42 +0000
parents 71489bb71528
children 032b2b67bc10
comparison
equal deleted inserted replaced
51:71489bb71528 52:065896b0913c
1 from Tix import * 1 from Tix import *
2 from time import time # time is on my side
3 from util import subsetdict
4
5 # statuses are:
6 # stopped - no cue is loaded
7 # running - cue is running, not complete
8 # halted - cue stops wherever it was, can't continue
9 # finished - cue is finished, next is loaded
2 10
3 stdfont = ('Arial', 10) 11 stdfont = ('Arial', 10)
4 12
5 class Fader(Frame): 13 class Fader(Frame):
6 'User interface for cue fader' 14 'User interface for cue fader'
10 self.scalelevels = scalelevels 18 self.scalelevels = scalelevels
11 self.init_layout() 19 self.init_layout()
12 def init_layout(self): 20 def init_layout(self):
13 Frame.__init__(self, self.master) 21 Frame.__init__(self, self.master)
14 22
23 # info variables
15 self.cuename = StringVar() 24 self.cuename = StringVar()
16 self.cuelength = DoubleVar() 25 self.cuelength = DoubleVar()
17 self.cueend = StringVar() 26 self.cuetarget = StringVar()
27
28 # info about a running cue
29 self.cuestatus = StringVar() # text description
30 self.cuestatus.set("stopped")
31
32 self.cuepercent = DoubleVar() # percent complete
33 self.cuepercent.set(0)
34 self.cuetime = StringVar() # time left
35 self.cuetime.set('0 / 0')
18 36
19 buttonframe = Frame(self) 37 buttonframe = Frame(self)
20 38
21 self.listbox = ScrolledListBox(buttonframe) 39 self.listbox = ScrolledListBox(buttonframe)
22 self.listbox.listbox.configure({'exportselection' : 0}) 40 self.listbox.listbox.configure({'exportselection' : 0})
28 Button(buttonframe, text="Clear").pack(side=LEFT) 46 Button(buttonframe, text="Clear").pack(side=LEFT)
29 47
30 infoframe = Frame(self) 48 infoframe = Frame(self)
31 Label(infoframe, textvariable=self.cuename, 49 Label(infoframe, textvariable=self.cuename,
32 font=('Arial', 12), bg='lightBlue').grid(columnspan=2, sticky=NE+SW) 50 font=('Arial', 12), bg='lightBlue').grid(columnspan=2, sticky=NE+SW)
51
33 Label(infoframe, text="Length", font=stdfont, 52 Label(infoframe, text="Length", font=stdfont,
34 bg='lightPink').grid(row=1, sticky=NE+SW) 53 bg='lightPink').grid(row=1, sticky=NE+SW)
35 Label(infoframe, textvariable=self.cuelength, 54 Label(infoframe, textvariable=self.cuelength,
36 font=stdfont).grid(row=1, column=1, sticky=NE+SW) 55 font=stdfont).grid(row=1, column=1, sticky=NE+SW)
56
37 Label(infoframe, text="Target", font=stdfont, 57 Label(infoframe, text="Target", font=stdfont,
38 bg='lightPink').grid(row=2, sticky=NE+SW) 58 bg='lightPink', wraplength=50).grid(row=2, sticky=NE+SW)
39 Label(infoframe, textvariable=self.cueend, 59 Label(infoframe, textvariable=self.cuetarget,
40 font=stdfont).grid(row=2, column=1, sticky=NE+SW) 60 font=stdfont).grid(row=2, column=1, sticky=NE+SW)
61
62 Label(infoframe, text="Status", font=stdfont,
63 bg='lightPink').grid(row=3, sticky=NE+SW)
64 Label(infoframe, textvariable=self.cuestatus,
65 font=stdfont).grid(row=3, column=1, sticky=NE+SW)
66
67 Label(infoframe, text="Time", font=stdfont,
68 bg='lightPink').grid(row=4, sticky=NE+SW)
69 Label(infoframe, textvariable=self.cuetime,
70 font=stdfont).grid(row=4, column=1, sticky=NE+SW)
71
72 Label(infoframe, text="Percent Complete", font=stdfont,
73 bg='lightPink').grid(row=5, sticky=NE+SW)
74 Label(infoframe, textvariable=self.cuepercent,
75 font=stdfont).grid(row=5, column=1, sticky=NE+SW)
76
41 infoframe.pack(side=RIGHT, fill=BOTH, expand=1) 77 infoframe.pack(side=RIGHT, fill=BOTH, expand=1)
42 buttonframe.pack(side=BOTTOM) 78 buttonframe.pack(side=BOTTOM)
43 79
44 self.listbox.listbox.select_set(0) 80 self.listbox.listbox.select_set(0)
45 self.update_selection() 81 self.update_selection()
46 def update_selection(self): 82 def update_selection(self):
47 print self.listbox.listbox.curselection()
48 selection = int(self.listbox.listbox.curselection()[0]) # blech 83 selection = int(self.listbox.listbox.curselection()[0]) # blech
49 self.current = self.cues[selection] 84 self.current = self.cues[selection]
50 self.cuename.set(self.current.name) 85 self.cuename.set(self.current.name)
51 self.cuelength.set(self.current.dur) 86 self.cuelength.set(self.current.dur)
52 self.cueend.set(str(self.current.get_end_levels())) 87 self.cuetarget.set(str(self.current.get_end_levels()))
53 def go(self): 88 def go(self):
54 print 'Fade to', self.current.name 89 print 'Fade to', self.current.name
90 self.cuestatus.set("running")
91 self.time_start = time()
92 startlevels = dict([(k, v.get()) for k, v in self.scalelevels.items()])
93 self.current.start(startlevels, self.time_start)
94 self.running_loop()
95 def running_loop(self):
96 curtime = time()
97 if (curtime - self.time_start) > self.current.dur:
98 return
99 newlevels = self.current.get_levels(time())
100 print newlevels
101 self.after(30, self.running_loop)