add additional argument to the configElement constructor to make configElements,...
[enigma2.git] / lib / python / Screens / TimerEdit.py
1 from Screen import Screen
2 from Components.TimerList import TimerList, TimerEntry
3 from Components.ActionMap import ActionMap
4 from Components.TimeInput import TimeInput
5 from Components.Label import Label
6 from Components.Button import Button
7 from Components.TextInput import TextInput
8
9 class TimerEdit(Screen):
10         def __init__(self, session, entry):
11                 Screen.__init__(self, session)
12
13                 self["actions"] = ActionMap(["OkCancelActions"], 
14                         {
15                                 "ok": self.apply,
16                                 "cancel": self.close
17                         })
18                 
19                 self["shortcuts"] = ActionMap(["ShortcutActions"],
20                         {
21                                 "red": self.beginFocus,
22                                 "yellow": self.endFocus,
23                                 "green": self.descFocus
24                         })
25                 
26                 self.entry = entry
27                 # begin, end, description, service
28                 self["begin"] = TimeInput()
29                 self["end"] = TimeInput()
30                 
31                 self["lbegin"] = Label("Begin")
32                 self["lend"] = Label("End")
33                 
34                 self["description"] = TextInput()
35                 self["apply"] = Button("Apply")
36                 self["service"] = Button()
37                 
38                 self["description"].setText(entry.description);
39         
40         def beginFocus(self):
41                 self.setFocus(self["begin"])
42         
43         def endFocus(self):
44                 self.setFocus(self["end"])
45         
46         def descFocus(self):
47                 self.setFocus(self["description"])
48         
49         def apply(self):
50                 print "applied!"
51         
52 class TimerEditList(Screen):
53         def __init__(self, session):
54                 Screen.__init__(self, session)
55                 
56                 list = [ ]
57                 for timer in session.nav.RecordTimer.timer_list:
58                         list.append(TimerEntry(timer, 0))
59                 
60                 for timer in session.nav.RecordTimer.processed_timers:
61                         list.append(TimerEntry(timer, 1))
62                 
63                 self["timerlist"] = TimerList(list)
64
65                 self["actions"] = ActionMap(["OkCancelActions"], 
66                         {
67                                 "ok": self.openEdit,
68                                 "cancel": self.close
69                         })
70
71         def openEdit(self):
72                 self.session.open(TimerEdit, self["timerlist"].getCurrent()[0])