| 3514 | |
| 3515 | |
| 3516 | class Datalist(Container): |
| 3517 | def __init__(self, options=None, *args, **kwargs): |
| 3518 | super(Datalist, self).__init__(*args, **kwargs) |
| 3519 | self.type = 'datalist' |
| 3520 | self.css_display = 'none' |
| 3521 | if options: |
| 3522 | self.append(options) |
| 3523 | |
| 3524 | def append(self, options, key=''): |
| 3525 | if type(options) in (list, tuple, dict): |
| 3526 | if type(options) == dict: |
| 3527 | for k in options.keys(): |
| 3528 | self.append(options[k], k) |
| 3529 | return options.keys() |
| 3530 | keys = [] |
| 3531 | for child in options: |
| 3532 | keys.append(self.append(child)) |
| 3533 | return keys |
| 3534 | |
| 3535 | if not isinstance(options, DatalistItem): |
| 3536 | raise ValueError('options should be an Option or an iterable of Option(otherwise use add_child(key,other)') |
| 3537 | |
| 3538 | key = options.identifier if key == '' else key |
| 3539 | self.add_child(key, options) |
| 3540 | return key |
| 3541 | |
| 3542 | |
| 3543 | class DatalistItem(Widget, _MixinTextualWidget): |