aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-01-29 04:36:01 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-01-29 04:36:01 +0000
commit2590d97005eecab111a4bf8476da9eb1c700654c (patch)
treea220d519aae546a2cd6481004117e3de1d9a5c32
parentcd621fe499141885e5a0d8b4e42a0f8a7f41a9ac (diff)
downloadenigma2-2590d97005eecab111a4bf8476da9eb1c700654c.tar.gz
enigma2-2590d97005eecab111a4bf8476da9eb1c700654c.zip
- minor bugfix (allow empty content)
- allow tuples as list elements - fake main menu
-rw-r--r--components.py15
-rw-r--r--lib/gui/elistbox.cpp3
-rw-r--r--lib/gui/elistboxcontent.cpp4
-rw-r--r--mytest.py2
-rw-r--r--screens.py44
5 files changed, 51 insertions, 17 deletions
diff --git a/components.py b/components.py
index 52c94606..76423387 100644
--- a/components.py
+++ b/components.py
@@ -224,23 +224,20 @@ class VolumeBar(HTMLComponent, GUIComponent, VariableValue):
g.setRange(0, 100)
return g
+
class MenuList(HTMLComponent, GUIComponent):
- def __init__(self):
+ def __init__(self, list):
GUIComponent.__init__(self)
+ self.l = eListboxPythonStringContent()
+ self.l.setList(list)
def getCurrent(self):
-# return self.l.getCurrentSelection()
- return "none"
+ return self.l.getCurrentSelection()
def GUIcreateInstance(self, priv, parent, skindata):
g = eListbox(parent)
- # BIG BIG HACK. :( we have to ensure that the eListboxPythonStringContent doesn't get destroyed.
- # we really have to take a look at the GC stuff
- l = eListboxPythonStringContent()
- l.setList(["Test Object 1", "Item #2", "Item #3", "nun kommt eine Zahl:", 15, "Bla fasel", "lulabla"])
- g.setContent(l)
+ g.setContent(self.l)
return g
def GUIdeleteInstance(self, g):
g.setContent(None)
- #del self.l
diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp
index e06ab3e6..5a9ee4d6 100644
--- a/lib/gui/elistbox.cpp
+++ b/lib/gui/elistbox.cpp
@@ -10,7 +10,8 @@ void eListbox::setContent(iListboxContent *content)
{
m_content = content;
invalidate();
- m_content->cursorHome();
+ if (m_content)
+ m_content->cursorHome();
m_top = 0;
m_selected = 0;
}
diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp
index 2f05f5dc..d3a2e77a 100644
--- a/lib/gui/elistboxcontent.cpp
+++ b/lib/gui/elistboxcontent.cpp
@@ -337,6 +337,10 @@ void eListboxPythonStringContent::paint(gPainter &painter, eWindowStyle &style,
{
PyObject *item = PyList_GetItem(m_list, m_cursor); // borrowed reference!
painter.setFont(fnt);
+
+ /* the user can supply tuples, in this case the first one will be displayed. */
+ if (PyTuple_Check(item))
+ item = PyTuple_GetItem(item, 0);
const char *string = PyString_Check(item) ? PyString_AsString(item) : "<not-a-string>";
diff --git a/mytest.py b/mytest.py
index e4a722ac..edaf24a5 100644
--- a/mytest.py
+++ b/mytest.py
@@ -70,7 +70,7 @@ class Session:
self.currentDialog = None
def processDelay(self):
- self.currentDialog.close()
+ self.currentDialog.doClose()
if self.currentWindow != None:
self.currentWindow.hide()
diff --git a/screens.py b/screens.py
index cf1dac10..a04772db 100644
--- a/screens.py
+++ b/screens.py
@@ -8,15 +8,34 @@ def doGlobal(screen):
class Screen(dict, HTMLSkin, GUISkin):
""" bla """
- def close(self):
+ # never call this directly - it will be called from the session!
+ def doClose(self):
GUISkin.close(self)
+ def close(self, retval=None):
+ self.session.close()
+
# a test dialog
class testDialog(Screen):
def testDialogClick(self):
- self["title"].setText(self["menu"].getCurrent())
-
- self.tries += 1
+ selection = self["menu"].getCurrent()
+ selection[1]()
+
+ def goMain(self):
+# self.close(0)
+ self["title"].setText("you selected the main menu!");
+
+ def goEmu(self):
+# self.close(1)
+ self["title"].setText("EMUs ARE ILLEGAL AND NOT SUPPORTED!");
+
+ def goTimeshift(self):
+# self.close(2)
+ self["title"].setText("JUST PRESS THE YELLOW BUTTON!");
+
+ def goHDTV(self):
+# self.close(3)
+ self["title"].setText("HDTV GREEN FLASHES: ENABLED");
def __init__(self):
GUISkin.__init__(self)
@@ -24,10 +43,23 @@ class testDialog(Screen):
b.onClick = [ self.testDialogClick ]
self["okbutton"] = b
self["title"] = Header("Test Dialog - press ok to leave!")
- self["menu"] = MenuList()
+ self["menu"] = MenuList(
+ [
+ ("MAIN MENU", self.goMain),
+ ("EMU SETUP", self.goEmu),
+ ("TIMESHIFT SETUP", self.goTimeshift),
+ ("HDTV PIP CONFIG", self.goHDTV)
+ ])
+
+
+class MainMenu(Screen):
+ def __init__(self):
+ GUISkin.__init__(self)
- self.tries = 0
+ self["ok"] = Button("ok")
+ self["ok"].onClick = [ self.close ]
+
# a clock display dialog
class clockDisplay(Screen):
def okbutton(self):