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='')
| 1260 | self.append(children) |
| 1261 | |
| 1262 | def append(self, value, key=''): |
| 1263 | """Adds a child widget, generating and returning a key if not provided |
| 1264 | |
| 1265 | In order to access to the specific child in this way container.children[key]. |
| 1266 | |
| 1267 | Args: |
| 1268 | value (Widget, or iterable of Widgets): The child to be appended. In case of a dictionary, |
| 1269 | each item's key is used as 'key' param for the single append. |
| 1270 | key (str): The unique string identifier for the child. Ignored in case of iterable 'value' |
| 1271 | param. |
| 1272 | |
| 1273 | Returns: |
| 1274 | str: a key used to refer to the child for all future interaction, or a list of keys in case |
| 1275 | of an iterable 'value' param |
| 1276 | """ |
| 1277 | if type(value) in (list, tuple, dict): |
| 1278 | if type(value) == dict: |
| 1279 | for k in value.keys(): |
| 1280 | self.append(value[k], k) |
| 1281 | return value.keys() |
| 1282 | keys = [] |
| 1283 | for child in value: |
| 1284 | keys.append(self.append(child)) |
| 1285 | return keys |
| 1286 | |
| 1287 | if not isinstance(value, Widget): |
| 1288 | raise ValueError('value should be a Widget (otherwise use add_child(key,other)') |
| 1289 | |
| 1290 | key = value.identifier if key == '' else key |
| 1291 | self.add_child(key, value) |
| 1292 | |
| 1293 | if self.layout_orientation == Container.LAYOUT_HORIZONTAL: |
| 1294 | if not self.children[key].css_float is None: |
| 1295 | if not (self.children[key].css_float == 'none'): |
| 1296 | self.children[key].css_float = 'left' |
| 1297 | else: |
| 1298 | self.children[key].css_float = 'left' |
| 1299 | |
| 1300 | return key |
| 1301 | |
| 1302 | def set_layout_orientation(self, layout_orientation): |
| 1303 | """For the generic Container, this function allows to setup the children arrangement. |