def __init__(self, abortable, required, default, choice): InputWidget.__init__(self, abortable, required) from input import InputError self.single_choice = [] self.string_choice = [] self.range_choice = [] prompt = [] for c in choice: if type(c) in (StringType, UnicodeType): if len(c) == 1: self.single_choice.append(c) else: self.string_choice.append(c) if c == default: prompt.append(c.upper()) else: prompt.append(c) elif type(c) is IntType: self.range_choice.append(xrange(c, c + 1)) prompt.append(str(c)) elif type(c) is XRangeType: self.range_choice.append(c) p = "%i-%i" % (c[0], c[-1]) if default in c: p += "(%i)" % (default, ) prompt.append(p) else: raise InputError, "Bad choice value: %r" % (c, ) self.prompt = u" [%s]: " % (string.join(prompt, "/")) self.content = u"" self.default = default self.pos = 0
def __init__(self, abortable, required, default, values, multi=0): self.__logger = logging.getLogger("cjc.ui.ListInput") InputWidget.__init__(self, abortable, required) self.capture_rest = 0 self.multi = multi if type(values) in (TupleType, ListType): values = dict([(a, a) for a in values]) self.keys = values.keys() self.keys.sort() self.values = values if not multi: try: self.choice = self.keys.index(default) except ValueError: self.choice = -1 else: self.choice = 0 self.selected = [0] * len(self.keys) if default: for k in default: try: i = self.keys.index(k) except ValueError: continue self.selected[i] = 1
def __init__(self,abortable,required,default,choice): InputWidget.__init__(self,abortable,required) from input import InputError self.single_choice=[] self.string_choice=[] self.range_choice=[] prompt=[] for c in choice: if type(c) in (StringType,UnicodeType): if len(c)==1: self.single_choice.append(c) else: self.string_choice.append(c) if c==default: prompt.append(c.upper()) else: prompt.append(c) elif type(c) is IntType: self.range_choice.append(xrange(c,c+1)) prompt.append(str(c)) elif type(c) is XRangeType: self.range_choice.append(c) p="%i-%i" % (c[0],c[-1]) if default in c: p+="(%i)" % (default,) prompt.append(p) else: raise InputError,"Bad choice value: %r" % (c,) self.prompt=u" [%s]: " % (string.join(prompt,"/")) self.content=u"" self.default=default self.pos=0
def __init__(self,abortable,required,default,values,multi=0): self.__logger = logging.getLogger("cjc.ui.ListInput") InputWidget.__init__(self,abortable,required) self.capture_rest=0 self.multi=multi if type(values) in (TupleType,ListType): values=dict([(a,a) for a in values]) self.keys=values.keys() self.keys.sort() self.values=values if not multi: try: self.choice=self.keys.index(default) except ValueError: self.choice=-1 else: self.choice=0 self.selected=[0]*len(self.keys) if default: for k in default: try: i=self.keys.index(k) except ValueError: continue self.selected[i]=1
def __init__(self, abortable, required, default=None): InputWidget.__init__(self, abortable, required) self.content = u"" if default == True: self.prompt = "[Y/n]: " elif default == False: self.prompt = "[y/N]: " else: self.prompt = "[y/n]: " default = None self.default = default
def __init__(self,abortable,required,default=None): InputWidget.__init__(self,abortable,required) self.content=u"" if default == True: self.prompt="[Y/n]: " elif default == False: self.prompt="[y/N]: " else: self.prompt="[y/n]: " default=None self.default=default
def __init__(self,abortable,required,default=u"",history_len=0, private=False): InputWidget.__init__(self,abortable,required) self.capture_rest=0 self.content=default self.pos=0 self.offset=0 self.history_len=history_len self.history=[] self.history_pos=0 self.saved_content=None self.completing=0 self.private = private
def set_parent(self, parent): InputWidget.set_parent(self, parent) if parent: keytable.activate("bool-input", self, input_window=self.win) else: keytable.deactivate("bool-input", self)
def set_parent(self,parent): InputWidget.set_parent(self,parent) if parent: keytable.activate("choice-input",self,self.keypressed,self.win) else: keytable.deactivate("choice-input",self)
def set_parent(self, parent): InputWidget.set_parent(self, parent) if parent: keytable.activate("choice-input", self, self.keypressed, self.win) else: keytable.deactivate("choice-input", self)
def set_parent(self,parent): InputWidget.set_parent(self,parent) if parent: keytable.activate("list-input",self,input_window=self.win) else: keytable.deactivate("list-input",self)