(self, layout)
Apply layout configuration
Apply layout configuration
Apply layout configuration
def create_layout(self, layout):
        """Apply layout configuration"""
        if 'children' not in layout:
            err('layout specifies no children: %s' % layout)
            return

        children = layout['children']
        if len(children) != 2:
            # Paned widgets can only have two children
            err('incorrect number of children for Paned: %s' % layout)
            return

        keys = []

        # FIXME: This seems kinda ugly. All we want here is to know the order
        # of children based on child['order']
        try:
            child_order_map = {}
            for child in children:
                key = children[child]['order']
                child_order_map[key] = child
            map_keys = list(child_order_map.keys())
            map_keys.sort()
            for map_key in map_keys:
                keys.append(child_order_map[map_key])
        except KeyError:
            # We've failed to figure out the order. At least give the terminals
            # in the wrong order
            keys = list(children.keys())

        num = 0
        for child_key in keys:
            child = children[child_key]
            dbg('Making a child of type: %s' % child['type'])
            if child['type'] == 'Terminal':
                pass
            elif child['type'] == 'VPaned':
                if num == 0:
                    terminal = self.get_child1()
                else:
                    terminal = self.get_child2()
                self.split_axis(terminal, True)
            elif child['type'] == 'HPaned':
                if num == 0:
                    terminal = self.get_child1()
                else:
                    terminal = self.get_child2()
                self.split_axis(terminal, False)
            else:
                err('unknown child type: %s' % child['type'])
            num = num + 1

        self.get_child1().create_layout(children[keys[0]])
        self.get_child2().create_layout(children[keys[1]])

        # Set the position with ratio. For some reason more reliable than by pos.
        if 'ratio' in layout:
            self.ratio = float(layout['ratio'])
            self.set_position_by_ratio()
def create_layout ( self , layout ) : if 'children' not in layout : err ( 'layout specifies no children: %s' % layout ) return children = layout [ 'children' ] if len ( children ) != 2 : # Paned widgets can only have two children err ( 'incorrect number of children for Paned: %s' % layout ) return keys = [ ] # FIXME: This seems kinda ugly. All we want here is to know the order # of children based on child['order'] try : child_order_map = { } for child in children : key = children [ child ] [ 'order' ] child_order_map [ key ] = child map_keys = list ( child_order_map . keys ( ) ) map_keys . sort ( ) for map_key in map_keys : keys . append ( child_order_map [ map_key ] ) except KeyError : # We've failed to figure out the order. At least give the terminals # in the wrong order keys = list ( children . keys ( ) ) num = 0 for child_key in keys : child = children [ child_key ] dbg ( 'Making a child of type: %s' % child [ 'type' ] ) if child [ 'type' ] == 'Terminal' : pass elif child [ 'type' ] == 'VPaned' : if num == 0 : terminal = self . get_child1 ( ) else : terminal = self . get_child2 ( ) self . split_axis ( terminal , True ) elif child [ 'type' ] == 'HPaned' : if num == 0 : terminal = self . get_child1 ( ) else : terminal = self . get_child2 ( ) self . split_axis ( terminal , False ) else : err ( 'unknown child type: %s' % child [ 'type' ] ) num = num + 1 self . get_child1 ( ) . create_layout ( children [ keys [ 0 ] ] ) self . get_child2 ( ) . create_layout ( children [ keys [ 1 ] ] ) # Set the position with ratio. For some reason more reliable than by pos. if 'ratio' in layout : self . ratio = float ( layout [ 'ratio' ] ) self . set_position_by_ratio ( )