class_docstr: Widget for proportionally dividing its internal area into a grid.
  
  This widget will automatically set the position and size of child widgets
  according to provided constraints.
  
  Parameters
  ----------
  spacing : int
      Spacing between widgets.
  **kwargs : dict
      Keyword arguments to pass to `Widget`.
code: def _add_stretch_constraints(
      solver, width_grid, height_grid, grid_widgets, widget_grid
  ):
      xmax = len(height_grid)
      ymax = len(width_grid)
  
      stretch_widths = [[] for _ in range(0, ymax)]
      stretch_heights = [[] for _ in range(0, xmax)]
  
      for y, x, ys, xs, widget in grid_widgets.values():
          for ws in width_grid[y : y + ys]:
              total_w = np.sum(ws[x : x + xs])
  
              for sw in stretch_widths[y : y + ys]:
                  sw.append((total_w, widget.stretch[0]))
  
          for hs in height_grid[x : x + xs]:
              total_h = np.sum(hs[y : y + ys])
  
              for sh in stretch_heights[x : x + xs]:
                  sh.append((total_h, widget.stretch[1]))
  
      for x, xs in enumerate(widget_grid):
          for y, widget in enumerate(xs):
              if widget is None:
                  stretch_widths[y].append((width_grid[y][x], 1))
                  stretch_heights[x].append((height_grid[x][y], 1))
  
      for sws in stretch_widths:
          if len(sws) <= 1:
              continue
  
          comparator = sws[0][0] / sws[0][1]
  
          for stretch_term, stretch_val in sws[1:]:
              solver.addConstraint(
                  (comparator == stretch_term / stretch_val) | "weak"
              )
  
      for sws in stretch_heights:
          if len(sws) <= 1:
              continue
  
          comparator = sws[0][0] / sws[0][1]
  
          for stretch_term, stretch_val in sws[1:]:
              solver.addConstraint(
                  (comparator == stretch_term / stretch_val) | "weak"
              )
  
imports: from __future__ import division
  import numpy
  from vispy.geometry import Rect
  from .widget import Widget
  from .viewbox import ViewBox
  from kiwisolver import Solver, Variable, UnsatisfiableConstraint
label_desc: Use image node_id 17 for calling the Grid obj's underlying member method code with example usage: obj._add_stretch_constraints(solver, width_grid, height_grid, grid_widgets, widget_grid) without return types