better resizing
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 2 Mar 2006 00:53:47 +0000 (00:53 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 2 Mar 2006 00:53:47 +0000 (00:53 +0000)
data/skin.xml
lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py
lib/python/Screens/ChoiceBox.py

index 4367b41..2d920f8 100644 (file)
                </screen>
                <screen name="ChoiceBox" position="100,100" size="550,400" title="Input" >
                        <widget name="text" position="0,0" size="550,25" font="Regular;20" />
-                       <widget name="list" position="0,30" size="550,335" />
+                       <widget name="list" position="0,30" size="550,335" scrollbarMode="showOnDemand" />
                        <applet type="onLayoutFinish">
 # this should be factored out into some helper code, but currently demonstrates applets.
 from enigma import eSize, ePoint
@@ -358,11 +358,14 @@ textsize = self["text"].getSize()
 
 # y size still must be fixed in font stuff...
 textsize = (textsize[0] + 50, textsize[1] + 50)
-offset = 60
+count = len(self.list)
+if count > 6:
+       count = 6
+offset = 30 * count
 wsizex = textsize[0] + 60
 wsizey = textsize[1] + offset
-if (280 > wsizex):
-       wsizex = 280
+if (400 > wsizex):
+       wsizex = 400
 wsize = (wsizex, wsizey)
 
 
@@ -373,7 +376,7 @@ self.instance.resize(eSize(*wsize))
 self["text"].instance.resize(eSize(*textsize))
 
 # move list
-listsize = (wsizex, 50)
+listsize = (wsizex, 30 * len(self.list))
 self["list"].instance.move(ePoint(0, textsize[1]))
 self["list"].instance.resize(eSize(*listsize))
 
index d4d24f3..c4e28fe 100644 (file)
@@ -69,7 +69,7 @@ class Test(Screen):
                self["text"].number(number)
 
 def main(session):
-       session.openWithCallback(test, ChoiceBox, title="Hallo", list=[(_("yes"), "yes"), (_("no"), "no")])
+       session.openWithCallback(test, ChoiceBox, title="Delete everything on this Dreambox?", list=[(_("yes"), "yes"), (_("no"), "no"), (_("perhaps"), "perhaps"), (_("ask me tomorrow"), "ask me tomorrow"), (_("leave me alone with this s§&$!"), "yes")])
        
 def test(returnValue):
        print "You entered", returnValue
index 533e78d..cc6afb1 100644 (file)
@@ -9,11 +9,12 @@ from Components.GUIComponent import *
 import os
 
 class ChoiceBox(Screen):
-       def __init__(self, session, title = "", **kwargs):
+       def __init__(self, session, title = "", list = []):
                Screen.__init__(self, session)
 
                self["text"] = Label(title)
-               self["list"] = MenuList(**kwargs)
+               self.list = list
+               self["list"] = MenuList(list)
                                
                self["actions"] = NumberActionMap(["WizardActions", "InputActions"], 
                {