class_docstr: The module sizer uses the maximum best width of the setting
  edit controls to compute the column widths, then it sets the text
  controls to wrap within the remaining space, then it uses the best
  height of each text control to lay out the rows.
class_docstr_tok: ["The","module","sizer","uses","the","maximum","best","width","of","the","setting","edit","controls","to","compute","the","column","widths",",","then","it","sets","the","text","controls","to","wrap","within","the","remaining","space",",","then","it","uses","the","best","height","of","each","text","control","to","lay","out","the","rows","."]
docstr: Recalculate the sizes of our items, resizing the text boxes
  as we go.
docstr_tok: ["Recalculate","the","sizes","of","our","items",",","resizing","the","text","boxes","as","we","go","."]
code: def RecalcSizes(self):
      """Recalculate the sizes of our items, resizing the text boxes
      as we go.
      """
      if self.__rows * self.__cols == 0:
          return
      try:
          size = self.GetSize()
          width = size[0] - 20
          edit_width = self.calc_edit_size()[0]
          help_width = self.calc_help_size()[0]
          max_text_width = self.calc_max_text_width()
          if edit_width + help_width + max_text_width < width:
              edit_width = width - max_text_width - help_width
          elif edit_width * 4 < width:
              edit_width = width / 4
          text_width = max(
              [width - edit_width - help_width, self.__min_text_width]
          )
          widths = [text_width, edit_width, help_width]
          #
          # Change all static text controls to wrap at the text width. Then
          # ask the items how high they are and do the layout of the line.
          #
          height = self.__height_padding
          panel = self.GetContainingWindow()
          for i in range(self.__rows):
              text_item = self.get_item(0, i)
              edit_item = self.get_item(1, i)
              if edit_item is None:
                  continue
              inner_text_width = text_width - 2 * text_item.GetBorder()
              control = text_item.GetWindow()
              assert isinstance(control, wx.StaticText), (
                  "Control at column 0, %d of grid is not StaticText: %s"
                  % (i, str(control))
              )
              text = control.GetLabel()
              edit_control = edit_item.GetWindow()
              height_border = max(
                  [x.GetBorder() for x in (edit_item, text_item)]
              )
              if (
                  isinstance(edit_control, wx.StaticLine)
                  and len(text) == 0
              ):
                  #
                  # A line spans both columns
                  #
                  text_item.Show(False)
                  # make the divider height the same as a text row plus some
                  item_height = self.get_row_height(i)
                  assert isinstance(edit_item, wx.SizerItem)
                  border = edit_item.GetBorder()
                  third_width = (
                      text_width + edit_width - 2 * border
                  ) / 3
                  item_location = wx.Point(
                      text_width - third_width / 2,
                      height + border + item_height / 2,
                  )
                  item_size = wx.Size(
                      third_width, edit_item.GetSize()[1]
                  )
                  item_location = panel.CalcScrolledPosition(
                      item_location
                  )
                  edit_item.SetDimension(item_location, item_size)
              else:
                  text_item.Show(True)
                  if text_width > self.__min_text_width and (
                      text.find("\n") != -1
                      or control.GetFullTextExtent(text)[0]
                      > inner_text_width
                  ):
                      text = text.replace("\n", " ")
                      control.SetLabel(text)
                      control.Wrap(inner_text_width)
                  row_height = self.get_row_height(i)
                  for j in range(self.__cols):
                      item = self.get_item(j, i)
                      item_x = sum(widths[0:j])
                      item_y = height
                      if (item.Flag & wx.EXPAND) == 0:
                          item_size = item.CalcMin()
                          if item.Flag & wx.ALIGN_CENTER_VERTICAL:
                              item_y = (
                                  height
                                  + (row_height - item_size[1]) / 2
                              )
                          if item.Flag & wx.ALIGN_CENTER_HORIZONTAL:
                              item_x += (widths[j] - item_size[0]) / 2
                          elif item.Flag & wx.ALIGN_RIGHT:
                              item_x += widths[j] - item_size[0]
                      else:
                          item_size = wx.Size(
                              widths[j], item.CalcMin()[1]
                          )
                      item_location = wx.Point(item_x, item_y)
                      item_location = panel.CalcScrolledPosition(
                          item_location
                      )
                      item.SetDimension(item_location, item_size)
              height += self.get_row_height(i) + 2 * height_border
      except:
          # This happens, hopefully transiently, on the Mac
          if not self.__printed_exception:
              LOGGER.warning("Detected WX error", exc_info=True)
              self.__printed_exception = True
  
file_path: CellProfiler/src/frontend/cellprofiler/gui/module_view/_module_sizer.py
imports: import logging
  import wx
label_desc: Use image node_id 11 for calling the ModuleSizer obj's underlying member method code with example usage: obj.RecalcSizes() without return types