class_docstr: Syntax highlighter for the Python language.
      
code: def __init__(self, document):
      QSyntaxHighlighter.__init__(self, document)
  
      # Multi-line strings (expression, flag, style)
      # FIXME: The triple-quotes in these two lines will mess up the
      # syntax highlighting from this point onward
      self.tri_single = (QRegExp("'''"), 1, "string2")
      self.tri_double = (QRegExp('"""'), 2, "string2")
  
      rules = []
  
      # Keyword, operator, and brace rules
      rules += [
          (r"\b%s\b" % w, 0, "keyword")
          for w in PythonHighlighter.keywords
      ]
      rules += [
          (r"%s" % o, 0, "operator")
          for o in PythonHighlighter.operators
      ]
      rules += [
          (r"%s" % b, 0, "brace") for b in PythonHighlighter.braces
      ]
  
      # All other rules
      rules += [
          # 'self'
          (r"\bself\b", 0, "self"),
          # 'def' followed by an identifier
          (r"\bdef\b\s*(\w+)", 1, "defclass"),
          # 'class' followed by an identifier
          (r"\bclass\b\s*(\w+)", 1, "defclass"),
          # Numeric literals
          (r"\b[+-]?[0-9]+[lL]?\b", 0, "numbers"),
          (r"\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b", 0, "numbers"),
          (
              r"\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b",
              0,
              "numbers",
          ),
          # Double-quoted string, possibly containing escape sequences
          (r'"[^"\\]*(\\.[^"\\]*)*"', 0, "string"),
          # Single-quoted string, possibly containing escape sequences
          (r"'[^'\\]*(\\.[^'\\]*)*'", 0, "string"),
          # From '#' until a newline
          (r"#[^\n]*", 0, "comment"),
      ]
  
      # Build a QRegExp for each pattern
      self.rules = [
          (QRegExp(pat), index, fmt) for (pat, index, fmt) in rules
      ]
  
file_path: pyqtgraph/pyqtgraph/examples/syntax.py
imports: from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
label_desc: Use image node_id 1 to create a new PythonHighlighter object from inherited base classes: QSyntaxHighlighter with example: obj = PythonHighlighter(document)