def __init__(self, question, candidates, other=False, default=None, **kwargs): self._candidates = candidates self._other = other self._selected, other_value = self._get_default_selected(default) self._candidate_control = ChoiceCandidatesControl( candidates, self._selected) if self.has_other: buf = Buffer(accept_handler=self._buffer_handler, multiline=False, **kwargs) buf.document = Document(other_value) self._other_value_control = BufferControl(buf) self._other_label_control = ChoiceOtherLabelControl( self.other_selected, self._other if isinstance(self._other, str) else None, ) super().__init__(question)
def __init__(self, question, default=None, **kwargs): self._kwargs = kwargs buf = Buffer(multiline=False, accept_handler=self._accept, **self._kwargs) self._buf_control = BufferControl(buf) if default is not None: buf.document = Document(default) super().__init__(question)