(self, parent=None, parent_pos=(0, 0),
parent_inner=False, name='', ncols=1, nrows=1,
h_pad=None, w_pad=None, width_ratios=None,
height_ratios=None)
| 34 | """ |
| 35 | |
| 36 | def __init__(self, parent=None, parent_pos=(0, 0), |
| 37 | parent_inner=False, name='', ncols=1, nrows=1, |
| 38 | h_pad=None, w_pad=None, width_ratios=None, |
| 39 | height_ratios=None): |
| 40 | Variable = kiwi.Variable |
| 41 | self.parent_pos = parent_pos |
| 42 | self.parent_inner = parent_inner |
| 43 | self.name = name + seq_id() |
| 44 | if isinstance(parent, LayoutGrid): |
| 45 | self.name = f'{parent.name}.{self.name}' |
| 46 | self.nrows = nrows |
| 47 | self.ncols = ncols |
| 48 | self.height_ratios = np.atleast_1d(height_ratios) |
| 49 | if height_ratios is None: |
| 50 | self.height_ratios = np.ones(nrows) |
| 51 | self.width_ratios = np.atleast_1d(width_ratios) |
| 52 | if width_ratios is None: |
| 53 | self.width_ratios = np.ones(ncols) |
| 54 | |
| 55 | sn = self.name + '_' |
| 56 | if not isinstance(parent, LayoutGrid): |
| 57 | # parent can be a rect if not a LayoutGrid |
| 58 | # allows specifying a rectangle to contain the layout. |
| 59 | self.solver = kiwi.Solver() |
| 60 | else: |
| 61 | parent.add_child(self, *parent_pos) |
| 62 | self.solver = parent.solver |
| 63 | # keep track of artist associated w/ this layout. Can be none |
| 64 | self.artists = np.empty((nrows, ncols), dtype=object) |
| 65 | self.children = np.empty((nrows, ncols), dtype=object) |
| 66 | |
| 67 | self.margins = {} |
| 68 | self.margin_vals = {} |
| 69 | # all the boxes in each column share the same left/right margins: |
| 70 | for todo in ['left', 'right', 'leftcb', 'rightcb']: |
| 71 | # track the value so we can change only if a margin is larger |
| 72 | # than the current value |
| 73 | self.margin_vals[todo] = np.zeros(ncols) |
| 74 | |
| 75 | sol = self.solver |
| 76 | |
| 77 | self.lefts = [Variable(f'{sn}lefts[{i}]') for i in range(ncols)] |
| 78 | self.rights = [Variable(f'{sn}rights[{i}]') for i in range(ncols)] |
| 79 | for todo in ['left', 'right', 'leftcb', 'rightcb']: |
| 80 | self.margins[todo] = [Variable(f'{sn}margins[{todo}][{i}]') |
| 81 | for i in range(ncols)] |
| 82 | for i in range(ncols): |
| 83 | sol.addEditVariable(self.margins[todo][i], 'strong') |
| 84 | |
| 85 | for todo in ['bottom', 'top', 'bottomcb', 'topcb']: |
| 86 | self.margins[todo] = np.empty((nrows), dtype=object) |
| 87 | self.margin_vals[todo] = np.zeros(nrows) |
| 88 | |
| 89 | self.bottoms = [Variable(f'{sn}bottoms[{i}]') for i in range(nrows)] |
| 90 | self.tops = [Variable(f'{sn}tops[{i}]') for i in range(nrows)] |
| 91 | for todo in ['bottom', 'top', 'bottomcb', 'topcb']: |
| 92 | self.margins[todo] = [Variable(f'{sn}margins[{todo}][{i}]') |
| 93 | for i in range(nrows)] |
nothing calls this directly
no test coverage detected