MCPcopy Index your code
hub / github.com/rawpython/remi / Container

Class Container

remi/gui.py:1229–1308  ·  view source on GitHub ↗

Container can be used as generic container. You can add children by the append(value, key) function. Container can be arranged in absolute positioning (assigning style['top'] and style['left'] attributes to the children or in a simple auto-alignment. You can decide the horizontal or

Source from the content-addressed store, hash-verified

1227
1228
1229class Container(Widget):
1230 """
1231 Container can be used as generic container. You can add children by the append(value, key) function.
1232 Container can be arranged in absolute positioning (assigning style['top'] and style['left'] attributes to the children
1233 or in a simple auto-alignment.
1234 You can decide the horizontal or vertical arrangement by the function set_layout_orientation(layout_orientation)
1235 passing as parameter Container.LAYOUT_HORIZONTAL or Container.LAYOUT_VERTICAL.
1236
1237 Tips:
1238 In html, it is a DIV tag
1239 The self.type attribute specifies the HTML tag representation
1240 The self.attributes[] attribute specifies the HTML attributes like 'style' 'class' 'id'
1241 The self.style[] attribute specifies the CSS style content like 'font' 'color'. It will be packed together with
1242 'self.attributes'.
1243 """
1244
1245 # constants
1246 LAYOUT_HORIZONTAL = True
1247 LAYOUT_VERTICAL = False
1248
1249 def __init__(self, children=None, *args, **kwargs):
1250 """
1251 Args:
1252 children (Widget, or iterable of Widgets): The child to be appended. In case of a dictionary,
1253 each item's key is used as 'key' param for the single append.
1254 layout_orientation (Container.LAYOUT_VERTICAL, Container.LAYOUT_HORIZONTAL): Container layout
1255 """
1256 super(Container, self).__init__(*args, **kwargs)
1257
1258 self.set_layout_orientation(kwargs.get('layout_orientation', Container.LAYOUT_VERTICAL))
1259 if children:
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

Callers 6

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
populate_folder_itemsMethod · 0.85
mainMethod · 0.85
mainMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected