no more crash when press ok in a empty choicebox
[enigma2.git] / lib / python / Screens / ChoiceBox.py
index a20983e61bf43db7eb93636b122381d1ef1bd8ad..b1d74ad54db88960ed29025e1834fb5aacbd56f3 100644 (file)
@@ -1,14 +1,10 @@
-from enigma import *
 from Screens.Screen import Screen
 from Screens.MessageBox import MessageBox
 from Components.ActionMap import NumberActionMap
 from Components.Label import Label
 from Components.MenuList import MenuList
-from Components.GUIComponent import *
 from Components.ChoiceList import ChoiceEntryComponent, ChoiceList
 
-import os
-
 class ChoiceBox(Screen):
        def __init__(self, session, title = "", list = [], keys = None, selection = 0):
                Screen.__init__(self, session)
@@ -78,7 +74,11 @@ class ChoiceBox(Screen):
 
        # runs the current selected entry
        def go(self):
-               self.goEntry(self["list"].l.getCurrentSelection()[0])
+               cursel = self["list"].l.getCurrentSelection()
+               if cursel:
+                       self.goEntry(cursel[0])
+               else:
+                       self.cancel()
 
        # runs a specific entry
        def goEntry(self, entry):