Skip to content

FrameInfoModel

Qt Base Class: QAbstractTableModel

Signature: QAbstractTableModel(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
ListMixin
prettyqt.itemmodels.listmixin
AbstractTableModel
prettyqt.core.abstracttablemodel

โ‹” Inheritance diagram

graph TD
  1473245439168["itemmodels.FrameInfoModel"]
  1473299910672["itemmodels.ListMixin"]
  140713234304496["builtins.object"]
  1473299901888["core.AbstractTableModel"]
  1473299900912["core.AbstractTableModelMixin"]
  1473299890176["core.AbstractItemModelMixin"]
  1473299815024["core.ObjectMixin"]
  1473289054032["QtCore.QAbstractTableModel"]
  1473289050128["QtCore.QAbstractItemModel"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473299910672 --> 1473245439168
  140713234304496 --> 1473299910672
  1473299901888 --> 1473245439168
  1473299900912 --> 1473299901888
  1473299890176 --> 1473299900912
  1473299815024 --> 1473299890176
  140713234304496 --> 1473299815024
  1473289054032 --> 1473299901888
  1473289050128 --> 1473289054032
  1473288842240 --> 1473289050128
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

๐Ÿ›ˆ DocStrings

Bases: ListMixin, AbstractTableModel

Model to display a list of inspect.Frameinfos / inspect.Tracebacks.

Source code in prettyqt\itemmodels\frameinfomodel.py
class FrameInfoModel(itemmodels.ListMixin, core.AbstractTableModel):
    """Model to display a list of inspect.Frameinfos / inspect.Tracebacks."""

    HEADER = ["Filename", "Line number", "Function", "Code context", "Index", "Positions"]
    SUPPORTS = Sequence[inspect.FrameInfo | inspect.Traceback]

    @classmethod
    def supports(cls, instance) -> bool:
        match instance:
            case (inspect.FrameInfo(), *_) | (inspect.Traceback(), *_):
                return True
            case _:
                return False

    def columnCount(self, parent=None) -> int:
        return len(self.HEADER)

    def headerData(
        self,
        section: int,
        orientation: constants.Orientation,
        role: constants.ItemDataRole = constants.DISPLAY_ROLE,
    ) -> str | None:
        match orientation, role:
            case constants.HORIZONTAL, constants.DISPLAY_ROLE:
                return self.HEADER[section]
            case constants.VERTICAL, constants.DISPLAY_ROLE:
                return str(section)

    def data(
        self,
        index: core.ModelIndex,
        role: constants.ItemDataRole = constants.DISPLAY_ROLE,
    ):
        if not index.isValid():
            return None
        field = self.items[index.row()]
        match role, index.column():
            case constants.DISPLAY_ROLE, 0:
                return field.filename
            case constants.DISPLAY_ROLE, 1:
                return field.lineno
            case constants.DISPLAY_ROLE, 2:
                return field.function
            case constants.DISPLAY_ROLE, 3:
                lines = []
                pretty = ""
                for line in field.code_context:
                    while line.startswith(" "):
                        pretty += "ยท"
                        line = line[1:]
                    pretty += line
                    lines.append(pretty)
                return "\n".join(lines)
            case constants.FONT_ROLE, 3:
                return SOURCE_FONT
            case constants.DISPLAY_ROLE, 4:
                return field.index
            case constants.DISPLAY_ROLE, 5:
                p = field.positions
                return f"{p.lineno} - {p.end_lineno}, {p.col_offset} {p.end_col_offset}"
            case constants.ALIGNMENT_ROLE, _:
                return constants.ALIGN_CENTER_LEFT

Info

Supported data type: collections.abc.Sequence[inspect.FrameInfo | inspect.Traceback]

โŒ— Property table

Qt Property Type Doc
objectName QString