class_docstr: :param get_size: A callable which returns the `Size` of the output terminal.
  :param stdout: Any object with has a `write` and `flush` method + an 'encoding' property.
  :param term: The terminal environment variable. (xterm, xterm-256color, linux, ...)
  :param enable_cpr: When `True` (the default), send "cursor position
      request" escape sequences to the output in order to detect the cursor
      position. That way, we can properly determine how much space there is
      available for the UI (especially for drop down menus) to render. The
      `Renderer` will still try to figure out whether the current terminal
      does respond to CPR escapes. When `False`, never attempt to send CPR
      requests.
class_docstr_tok: [":","param","get_size",":","A","callable","which","returns","the","`","Size","`","of","the","output","terminal",".",":","param","stdout",":","Any","object","with","has","a","`","write","`","and","`","flush","`","method","+","an","'encoding","'","property",".",":","param","term",":","The","terminal","environment","variable",".","(","xterm",",","xterm-256color",",","linux",",","...",")",":","param","enable_cpr",":","When","`","True","`","(","the","default",")",",","send","``","cursor","position","request","''","escape","sequences","to","the","output","in","order","to","detect","the","cursor","position",".","That","way",",","we","can","properly","determine","how","much","space","there","is","available","for","the","UI","(","especially","for","drop","down","menus",")","to","render",".","The","`","Renderer","`","will","still","try","to","figure","out","whether","the","current","terminal","does","respond","to","CPR","escapes",".","When","`","False","`",",","never","attempt","to","send","CPR","requests","."]
docstr: Create an Output class from a pseudo terminal.
  (This will take the dimensions by reading the pseudo
  terminal attributes.)
docstr_tok: ["Create","an","Output","class","from","a","pseudo","terminal",".","(","This","will","take","the","dimensions","by","reading","the","pseudo","terminal","attributes",".",")"]
code: def from_pty(
      cls,
      stdout: TextIO,
      term: str | None = None,
      default_color_depth: ColorDepth | None = None,
      enable_bell: bool = True,
  ) -> Vt100_Output:
      """
      Create an Output class from a pseudo terminal.
      (This will take the dimensions by reading the pseudo
      terminal attributes.)
      """
      fd: int | None
      # Normally, this requires a real TTY device, but people instantiate
      # this class often during unit tests as well. For convenience, we print
      # an error message, use standard dimensions, and go on.
      try:
          fd = stdout.fileno()
      except io.UnsupportedOperation:
          fd = None
  
      if not stdout.isatty() and (
          fd is None or fd not in cls._fds_not_a_terminal
      ):
          msg = "Warning: Output is not a terminal (fd=%r).\n"
          sys.stderr.write(msg % fd)
          sys.stderr.flush()
          if fd is not None:
              cls._fds_not_a_terminal.add(fd)
  
      def get_size() -> Size:
          # If terminal (incorrectly) reports its size as 0, pick a
          # reasonable default.  See
          # https://github.com/ipython/ipython/issues/10071
          rows, columns = (None, None)
  
          # It is possible that `stdout` is no longer a TTY device at this
          # point. In that case we get an `OSError` in the ioctl call in
          # `get_size`. See:
          # https://github.com/prompt-toolkit/python-prompt-toolkit/pull/1021
          try:
              rows, columns = _get_size(stdout.fileno())
          except OSError:
              pass
          return Size(rows=rows or 24, columns=columns or 80)
  
      return cls(
          stdout,
          get_size,
          term=term,
          default_color_depth=default_color_depth,
          enable_bell=enable_bell,
      )
  
imports: from __future__ import annotations
  import io
  import os
  import sys
  from typing import Callable, Dict, Hashable, Iterable, Sequence, TextIO, Tuple
  from prompt_toolkit.cursor_shapes import CursorShape
  from prompt_toolkit.data_structures import Size
  from prompt_toolkit.output import Output
  from prompt_toolkit.styles import ANSI_COLOR_NAMES, Attrs
  from prompt_toolkit.utils import is_dumb_terminal
  from .color_depth import ColorDepth
  from .flush_stdout import flush_stdout
label_desc: Use image node_id 2 for calling the Vt100_Output obj's underlying member method code with example usage: obj.from_pty(cls, stdout, term, default_color_depth, enable_bell) and returns: cls, Size