Adds a child widget, generating and returning a key if not provided In order to access to the specific child in this way container.children[key]. Args: value (Widget, or iterable of Widgets): The child to be appended. In case of a dictionary, each item's
(self, value, key='')
| 1749 | self.css_grid_template_areas = ''.join("'%s'" % (' '.join(x)) for x in matrix) |
| 1750 | |
| 1751 | def append(self, value, key=''): |
| 1752 | """Adds a child widget, generating and returning a key if not provided |
| 1753 | |
| 1754 | In order to access to the specific child in this way container.children[key]. |
| 1755 | |
| 1756 | Args: |
| 1757 | value (Widget, or iterable of Widgets): The child to be appended. In case of a dictionary, |
| 1758 | each item's key is used as 'key' param for the single append. |
| 1759 | key (str): The unique string identifier for the child. Ignored in case of iterable 'value' |
| 1760 | param. The key have to correspond to a an element provided in the 'define_grid' method param. |
| 1761 | |
| 1762 | Returns: |
| 1763 | str: a key used to refer to the child for all future interaction, or a list of keys in case |
| 1764 | of an iterable 'value' param |
| 1765 | """ |
| 1766 | if type(value) in (list, tuple, dict): |
| 1767 | if type(value) == dict: |
| 1768 | for k in value.keys(): |
| 1769 | self.append(value[k], k) |
| 1770 | return value.keys() |
| 1771 | keys = [] |
| 1772 | for child in value: |
| 1773 | keys.append(self.append(child)) |
| 1774 | return keys |
| 1775 | |
| 1776 | if not isinstance(value, Widget): |
| 1777 | raise ValueError('value should be a Widget (otherwise use add_child(key,other)') |
| 1778 | |
| 1779 | key = value.identifier if key == '' else key |
| 1780 | self.add_child(key, value) |
| 1781 | value.style['grid-area'] = key |
| 1782 | value.css_position = 'static' |
| 1783 | |
| 1784 | return key |
| 1785 | |
| 1786 | def remove_child(self, child): |
| 1787 | if 'grid-area' in child.style.keys(): |