Appends child items to the ListView. The items are accessible by list.children[key]. Args: value (ListItem, or iterable of ListItems): The child to be appended. In case of a dictionary, each item's key is used as 'key' param for the single append. key
(self, value, key='')
| 2602 | return obj |
| 2603 | |
| 2604 | def append(self, value, key=''): |
| 2605 | """Appends child items to the ListView. The items are accessible by list.children[key]. |
| 2606 | |
| 2607 | Args: |
| 2608 | value (ListItem, or iterable of ListItems): The child to be appended. In case of a dictionary, |
| 2609 | each item's key is used as 'key' param for the single append. |
| 2610 | key (str): The unique string identifier for the child. Ignored in case of iterable 'value' |
| 2611 | param. |
| 2612 | """ |
| 2613 | if isinstance(value, type('')) or isinstance(value, type(u'')): |
| 2614 | value = ListItem(value) |
| 2615 | |
| 2616 | keys = super(ListView, self).append(value, key=key) |
| 2617 | if type(value) in (list, tuple, dict): |
| 2618 | for k in keys: |
| 2619 | if self.EVENT_ONCLICK not in self.children[k].attributes: |
| 2620 | self.children[k].onclick.connect(self.onselection) |
| 2621 | self.children[k].attributes['selected'] = False |
| 2622 | else: |
| 2623 | # if an event listener is already set for the added item, it will not generate a selection event |
| 2624 | if self.EVENT_ONCLICK not in value.attributes: |
| 2625 | value.onclick.connect(self.onselection) |
| 2626 | value.attributes['selected'] = False |
| 2627 | return keys |
| 2628 | |
| 2629 | def empty(self): |
| 2630 | """Removes all children from the list""" |