diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2005-05-14 15:23:23 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2005-05-14 15:23:23 +0000 |
| commit | 7bc4a59528ab13f3062dc1520e76f9ecedd87400 (patch) | |
| tree | 9d6e91be12147eee77d82ec5b49c24ae44f85bd3 /lib/python | |
| parent | ab8d418f82b2835c267d88ded5d748a6f0e8a852 (diff) | |
| download | enigma2-7bc4a59528ab13f3062dc1520e76f9ecedd87400.tar.gz enigma2-7bc4a59528ab13f3062dc1520e76f9ecedd87400.zip | |
- work on timers
- add eInput widget
- add python/Tools
- add flexible listbox content
Diffstat (limited to 'lib/python')
| -rw-r--r-- | lib/python/Components/TimeInput.py | 18 | ||||
| -rw-r--r-- | lib/python/Components/TimerList.py | 57 | ||||
| -rw-r--r-- | lib/python/Components/__init__.py | 2 | ||||
| -rw-r--r-- | lib/python/Screens/Menu.py | 4 | ||||
| -rw-r--r-- | lib/python/Screens/Screen.py | 1 | ||||
| -rw-r--r-- | lib/python/Screens/TimerEdit.py | 54 | ||||
| -rw-r--r-- | lib/python/Screens/__init__.py | 3 | ||||
| -rw-r--r-- | lib/python/Tools/.cvsignore | 1 | ||||
| -rw-r--r-- | lib/python/Tools/FuzzyDate.py | 39 | ||||
| -rw-r--r-- | lib/python/Tools/XMLTools.py | 17 | ||||
| -rw-r--r-- | lib/python/Tools/__init__.py | 1 | ||||
| -rw-r--r-- | lib/python/enigma_python.i | 3 |
12 files changed, 196 insertions, 4 deletions
diff --git a/lib/python/Components/TimeInput.py b/lib/python/Components/TimeInput.py new file mode 100644 index 00000000..c520fdf5 --- /dev/null +++ b/lib/python/Components/TimeInput.py @@ -0,0 +1,18 @@ +from HTMLComponent import * +from GUIComponent import * +from VariableText import * + +from enigma import eInput, eInputContentNumber + +class TimeInput(HTMLComponent, GUIComponent): + def __init__(self): + GUIComponent.__init__(self) + self.content = eInputContentNumber(12, 0, 15) + + def GUIcreate(self, parent, skindata): + self.instance = eInput(parent) + self.instance.setContent(self.content) + + def GUIdelete(self): + self.instance.setContent(None) + self.instance = None diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py new file mode 100644 index 00000000..da005b01 --- /dev/null +++ b/lib/python/Components/TimerList.py @@ -0,0 +1,57 @@ +from HTMLComponent import * +from GUIComponent import * + +from Tools.FuzzyDate import FuzzyTime + +from enigma import eListboxPythonMultiContent, eListbox, gFont + + +RT_HALIGN_LEFT = 0 +RT_HALIGN_RIGHT = 1 +RT_HALIGN_CENTER = 2 +RT_HALIGN_BLOCK = 4 + +RT_VALIGN_TOP = 0 +RT_VALIGN_CENTER = 8 +RT_VALIGN_BOTTOM = 16 + +RT_WRAP = 32 + + +# +# | <Service> <Name of the Timer> | +# | <start> <end> | +# +def TimerEntry(timer, processed): + res = [ ] + + res.append((0, 0, 400, 30, 0, RT_HALIGN_LEFT, timer.service_ref.getServiceName())) + res.append((0, 30, 200, 20, 1, RT_HALIGN_LEFT, "%s, %s" % FuzzyTime(timer.begin))) + + if processed: + res.append((200, 30, 200, 20, 1, RT_HALIGN_RIGHT, FuzzyTime(timer.end)[1])) + else: + res.append((200, 30, 200, 20, 1, RT_HALIGN_RIGHT, "done")) + return res + +class TimerList(HTMLComponent, GUIComponent): + def __init__(self, list): + GUIComponent.__init__(self) + self.l = eListboxPythonMultiContent() + self.l.setList(list) + self.l.setFont(0, gFont("Arial", 20)) + self.l.setFont(1, gFont("Arial", 18)) + + def getCurrent(self): + return self.l.getCurrentSelection() + + def GUIcreate(self, parent, skindata): + self.instance = eListbox(parent) + self.instance.setContent(self.l) + self.instance.setItemHeight(50) + + def GUIdelete(self): + self.instance.setContent(None) + self.instance = None + + diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py index 8a064b22..d7cd406b 100644 --- a/lib/python/Components/__init__.py +++ b/lib/python/Components/__init__.py @@ -3,5 +3,5 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo", "GUIComponent", "GUISkin", "HTMLComponent", "HTMLSkin", "Header", "Label", "MenuList", "PerServiceDisplay", "ProgressBar", "ServiceList", "ServiceName", "ServiceScan", "VariableText", "VariableValue", "VolumeBar", - "components", "config"] + "components", "config", "TimerList", "TimeInput" ] diff --git a/lib/python/Screens/Menu.py b/lib/python/Screens/Menu.py index ce73a954..c3809318 100644 --- a/lib/python/Screens/Menu.py +++ b/lib/python/Screens/Menu.py @@ -11,6 +11,8 @@ from Components.Label import Label from Components.ProgressBar import ProgressBar from ConfigMenu import * +from TimerEdit import * + from enigma import quitMainloop import xml.dom.minidom @@ -32,7 +34,7 @@ mdom = xml.dom.minidom.parseString( <item text="Radio-Mode">self.setModeRadio()</item> <item text="File-Mode">self.setModeFile()</item> <item text="Scart">self.openDialog(ScartLoopThrough)</item> - <item text="Timer"></item> + <item text="Timer">self.openDialog(TimerEditList)</item> <menu text="Setup"> <menu text="Service Organising"> <item text="New Bouquets"></item> diff --git a/lib/python/Screens/Screen.py b/lib/python/Screens/Screen.py index ef9b2bb0..1b42141a 100644 --- a/lib/python/Screens/Screen.py +++ b/lib/python/Screens/Screen.py @@ -29,7 +29,6 @@ class Screen(dict, HTMLSkin, GUISkin): del self.session for (name, val) in self.items(): - print "%s -> %d" % (name, sys.getrefcount(val)) del self[name] def close(self, retval=None): diff --git a/lib/python/Screens/TimerEdit.py b/lib/python/Screens/TimerEdit.py new file mode 100644 index 00000000..41b6a12e --- /dev/null +++ b/lib/python/Screens/TimerEdit.py @@ -0,0 +1,54 @@ +from Screen import Screen +from Components.TimerList import TimerList, TimerEntry +from Components.ActionMap import ActionMap +from Components.TimeInput import TimeInput +from Components.Label import Label +from Components.Button import Button + +class TimerEdit(Screen): + def __init__(self, session, entry): + Screen.__init__(self, session) + + self["actions"] = ActionMap(["OkCancelActions"], + { + "ok": self.apply, + "cancel": self.close + }) + + self.entry = entry + # begin, end, description, service + self["begin"] = TimeInput() + self["end"] = TimeInput() + + self["lbegin"] = Label("Begin") + self["lend"] = Label("End") + + self["description"] = Label("bla") +# TextInput() + self["apply"] = Button("Apply") + self["service"] = Button() + + def apply(self): + print "applied!" + +class TimerEditList(Screen): + def __init__(self, session): + Screen.__init__(self, session) + + list = [ ] + for timer in session.nav.RecordTimer.timer_list: + list.append(TimerEntry(timer, 0)) + + for timer in session.nav.RecordTimer.processed_timers: + list.append(TimerEntry(timer, 1)) + + self["timerlist"] = TimerList(list) + + self["actions"] = ActionMap(["OkCancelActions"], + { + "ok": self.openEdit, + "cancel": self.close + }) + + def openEdit(self): + self.session.open(TimerEdit, self["timerlist"].getCurrent()) diff --git a/lib/python/Screens/__init__.py b/lib/python/Screens/__init__.py index 90b22c27..fbd2c173 100644 --- a/lib/python/Screens/__init__.py +++ b/lib/python/Screens/__init__.py @@ -1,3 +1,4 @@ __all__ = ["ChannelSelection", "ClockDisplay", "ConfigMenu", - "InfoBar", "Menu", "ScartLoopThrough", "Screen", "ServiceScan"] + "InfoBar", "Menu", "ScartLoopThrough", "Screen", "ServiceScan", + "TimerEdit"] diff --git a/lib/python/Tools/.cvsignore b/lib/python/Tools/.cvsignore new file mode 100644 index 00000000..0d20b648 --- /dev/null +++ b/lib/python/Tools/.cvsignore @@ -0,0 +1 @@ +*.pyc diff --git a/lib/python/Tools/FuzzyDate.py b/lib/python/Tools/FuzzyDate.py new file mode 100644 index 00000000..c5055baf --- /dev/null +++ b/lib/python/Tools/FuzzyDate.py @@ -0,0 +1,39 @@ +import time + +def FuzzyTime(t): + d = time.localtime(t) + nt = time.time() + n = time.localtime() + + if d[:3] == n[:3]: + # same day + date = "Today" + elif ((t - nt) < 7*86400) and (nt < t): + # same week + date = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")[d[6]] + elif d[0] == n[0]: + # same year + date = "%d.%d." % (d[2], d[1]) + else: + date = "%d.%d.%d" % (d[2], d[1], d[0]) + + timeres = "%d:%02d" % (d[3], d[4]) + + return (date, timeres) + +if __name__ == "__main__": + print "now: %s %s" % FuzzyDate(time.time()) + print "1 day: %s %s" % FuzzyDate(time.time() + 86400) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *2) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *3) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *4) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *5) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *6) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *7) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *8) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *9) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *10) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *11) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *12) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *13) + print "2 days: %s %s" % FuzzyDate(time.time() + 86400 *14) diff --git a/lib/python/Tools/XMLTools.py b/lib/python/Tools/XMLTools.py new file mode 100644 index 00000000..aaab4677 --- /dev/null +++ b/lib/python/Tools/XMLTools.py @@ -0,0 +1,17 @@ +import xml.dom.minidom + +def elementsWithTag(el, tag): + + """filters all elements of childNode with the specified function + example: nodes = elementsWithTag(childNodes, lambda x: x == "bla")""" + + # fiiixme! (works but isn't nice) + if isinstance(tag, str): + s = tag + tag = lambda x: x == s + + for x in el: + if x.nodeType != xml.dom.minidom.Element.nodeType: + continue + if tag(x.tagName): + yield x diff --git a/lib/python/Tools/__init__.py b/lib/python/Tools/__init__.py new file mode 100644 index 00000000..4ff7ce3c --- /dev/null +++ b/lib/python/Tools/__init__.py @@ -0,0 +1 @@ +all = ["FuzzyDate.py", "XMLTools.py"] diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 11faff1c..6062c7d2 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -48,6 +48,7 @@ is usually caused by not marking PSignals as immutable. #include <lib/gui/ewidget.h> #include <lib/gui/elabel.h> +#include <lib/gui/einput.h> #include <lib/gui/epixmap.h> #include <lib/gui/ebutton.h> #include <lib/gui/ewindow.h> @@ -92,6 +93,7 @@ extern PSignal1<void,int> &keyPressedSignal(); // TODO: embed these... %immutable eButton::selected; +%immutable eInput::changed; %immutable eComponentScan::statusChanged; %immutable pNavigation::m_event; @@ -101,6 +103,7 @@ extern PSignal1<void,int> &keyPressedSignal(); %include <lib/gdi/region.h> %include <lib/gui/ewidget.h> %include <lib/gui/elabel.h> +%include <lib/gui/einput.h> %include <lib/gui/epixmap.h> %include <lib/gui/ebutton.h> %include <lib/gui/ewindow.h> |
