class_docstr: Syntax highlighter for the Python language.
      
code: def __init__(self, document, dark=False):
      QSyntaxHighlighter.__init__(self, document)
  
      self.STYLES = DARK_STYLES if dark else LIGHT_STYLES
      document.parent().parent().setStyleSheet(
          f"""QPlainTextEdit{{
              font-family:'Consolas'; 
              color: {'#ccc' if dark else '#000'}; 
              background-color: transparent;}}"""
      )
  
      # 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, self.STYLES["string2"])
      self.tri_double = (QRegExp('"""'), 2, self.STYLES["string2"])
  
      rules = []
  
      # Keyword, operator, and brace rules
      rules += [
          (r"\b%s\b" % w, 0, self.STYLES["keyword"])
          for w in PythonHighlighter.keywords
      ]
      rules += [
          (r"%s" % o, 0, self.STYLES["operator"])
          for o in PythonHighlighter.operators
      ]
      rules += [
          (r"%s" % b, 0, self.STYLES["brace"])
          for b in PythonHighlighter.braces
      ]
  
      # All other rules
      rules += [
          # 'self'
          (r"\bself\b", 0, self.STYLES["self"]),
          # Double-quoted string, possibly containing escape sequences
          (r'"[^"\\]*(\\.[^"\\]*)*"', 0, self.STYLES["string"]),
          # Single-quoted string, possibly containing escape sequences
          (r"'[^'\\]*(\\.[^'\\]*)*'", 0, self.STYLES["string"]),
          # 'def' followed by an identifier
          (r"\bdef\b\s*(\w+)", 1, self.STYLES["defclass"]),
          # 'class' followed by an identifier
          (r"\bclass\b\s*(\w+)", 1, self.STYLES["defclass"]),
          # From '#' until a newline
          (r"#[^\n]*", 0, self.STYLES["comment"]),
          # Numeric literals
          (r"\b[+-]?[0-9]+[lL]?\b", 0, self.STYLES["numbers"]),
          (
              r"\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b",
              0,
              self.STYLES["numbers"],
          ),
          (
              r"\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b",
              0,
              self.STYLES["numbers"],
          ),
      ]
  
      # Build a QRegExp for each pattern
      self.rules = [
          (QRegExp(pat), index, fmt) for (pat, index, fmt) in rules
      ]
  
file_path: PandasGUI/pandasgui/widgets/python_highlighter.py
imports: from PyQt5 import QtWidgets
  from PyQt5.QtCore import QRegExp
  from PyQt5.QtGui import QColor, QTextCharFormat, QFont, QSyntaxHighlighter
label_desc: Use image node_id 1 to create a new PythonHighlighter object from inherited base classes: QSyntaxHighlighter with example: obj = PythonHighlighter(document, dark)