parameters: (self, max_available_width: int)
return_statement: return self._merge_dimensions(
              dimension=to_dimension(self.width),
              get_preferred=preferred_content_width,
              dont_extend=self.dont_extend_width(),
          )
docstring: Calculate the preferred width for this window.
docstring_summary: Calculate the preferred width for this window.
docstring_tokens: Calculate the preferred width for this window .
function: def preferred_width(self, max_available_width: int) -> Dimension:
          """
          Calculate the preferred width for this window.
          """
  
          def preferred_content_width() -> Optional[int]:
              """Content width: is only calculated if no exact width for the
              window was given."""
              if self.ignore_content_width():
                  return None
  
              # Calculate the width of the margin.
              total_margin_width = self._get_total_margin_width()
  
              # Window of the content. (Can be `None`.)
              preferred_width = self.content.preferred_width(
                  max_available_width - total_margin_width
              )
  
              if preferred_width is not None:
                  # Include width of the margins.
                  preferred_width += total_margin_width
              return preferred_width
  
          # Merge.
          return self._merge_dimensions(
              dimension=to_dimension(self.width),
              get_preferred=preferred_content_width,
              dont_extend=self.dont_extend_width(),
          )
function_tokens: def preferred_width ( self , max_available_width : int ) -> Dimension : def preferred_content_width ( ) -> Optional [ int ] : """Content width: is only calculated if no exact width for the
              window was given.""" if self . ignore_content_width ( ) : return None # Calculate the width of the margin. total_margin_width = self . _get_total_margin_width ( ) # Window of the content. (Can be `None`.) preferred_width = self . content . preferred_width ( max_available_width - total_margin_width ) if preferred_width is not None : # Include width of the margins. preferred_width += total_margin_width return preferred_width # Merge. return self . _merge_dimensions ( dimension = to_dimension ( self . width ) , get_preferred = preferred_content_width , dont_extend = self . dont_extend_width ( ) , )