X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FComponents%2Fconfig.py;h=876e3a34a7b56683960a98981088ef409eb1bf35;hp=450c302e6bb0e1be39433ac6d7b6e14d7540a356;hb=18469e4dedcfe75e8128b489774f79fb790a23da;hpb=7560beb3e371704d798259ca1ea927bf4575306c diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 450c302..876e3a3 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -1017,6 +1017,42 @@ class ConfigPassword(ConfigText): ConfigText.onDeselect(self, session) self.hidden = True +# lets the user select between [min, min+stepwidth, min+(stepwidth*2)..., maxval] with maxval <= max depending +# on the stepwidth +# min, max, stepwidth, default are int values +# wraparound: pressing RIGHT key at max value brings you to min value and vice versa if set to True +class ConfigSelectionNumber(ConfigSelection): + def __init__(self, min, max, stepwidth, default = None, wraparound = False): + self.wraparound = wraparound + if default is None: + default = min + default = str(default) + choices = [] + step = min + while step <= max: + choices.append(str(step)) + step += stepwidth + + ConfigSelection.__init__(self, choices, default) + + def getValue(self): + return int(self.text) + + def setValue(self, val): + self.text = str(val) + + def handleKey(self, key): + if not self.wraparound: + if key == KEY_RIGHT: + if len(self.choices) == (self.choices.index(self.value) + 1): + return + if key == KEY_LEFT: + if self.choices.index(self.value) == 0: + return + ConfigSelection.handleKey(self, key) + + + class ConfigNumber(ConfigText): def __init__(self, default = 0): ConfigText.__init__(self, str(default), fixed_size = False)