Skip to content

CornerCellDelegate

Base classes

Name Children Inherits
_PaletteColorsMixin
cutepandas.pandaswidgets._viewer_style
Colours set by the viewer (`set_colors`), else derived from the palette.
StyledItemDelegate
prettyqt.widgets.styleditemdelegate

⋔ Inheritance diagram

graph TD
  3740541635["_viewer_style.CornerCellDelegate"]
  314031066["_viewer_style._PaletteColorsMixin"]
  2751680898["builtins.object"]
  4109708588["widgets.StyledItemDelegate"]
  3153451512["widgets.AbstractItemDelegateMixin"]
  3227531497["core.ObjectMixin"]
  4201154414["QtWidgets.QStyledItemDelegate"]
  3961416811["QtWidgets.QAbstractItemDelegate"]
  13951691["QtCore.QObject"]
  395147830["sip.wrapper"]
  46922758["sip.simplewrapper"]
  314031066 --> 3740541635
  2751680898 --> 314031066
  4109708588 --> 3740541635
  3153451512 --> 4109708588
  3227531497 --> 3153451512
  2751680898 --> 3227531497
  4201154414 --> 4109708588
  3961416811 --> 4201154414
  13951691 --> 3961416811
  395147830 --> 13951691
  46922758 --> 395147830
  2751680898 --> 46922758

🛈 DocStrings

Bases: _PaletteColorsMixin, StyledItemDelegate

Renderer for the top-left level-name corner table of the grid viewer.

Source code in src/cutepandas/pandaswidgets/_viewer_style.py
class CornerCellDelegate(_PaletteColorsMixin, widgets.StyledItemDelegate):
    """Renderer for the top-left level-name corner table of the grid viewer."""

    def __init__(self, parent: core.QObject | None = None):
        super().__init__(parent=parent)
        self._fonts = _FontCache()

    def paint(
        self,
        painter: Any,
        option: Any,
        index: core.ModelIndex,
    ):
        colors = self.colors_for(option.palette)
        rect = option.rect

        painter.save()
        painter.fillRect(rect, colors.header_outer_bg)
        model = index.model()
        last_row = model is None or index.row() == model.rowCount() - 1
        last_col = model is None or index.column() == model.columnCount() - 1
        _draw_grid_edges(
            painter,
            rect,
            colors.divider if last_col else colors.grid,
            colors.divider if last_row else colors.grid,
        )
        raw_text = index.data(constants.DISPLAY_ROLE)
        text = "" if raw_text is None else str(raw_text)
        text_rect = rect.adjusted(HEADER_HPAD, 0, -HEADER_HPAD, 0)
        if text and text_rect.width() > 0:
            painter.setFont(self._fonts.get(option.font, "medium", italic=True))
            painter.setPen(colors.muted_text)
            align = _align_value(index.data(constants.ALIGNMENT_ROLE), _ALIGN_HEADER_H)
            elided = painter.fontMetrics().elidedText(
                text, _ELIDE_RIGHT, text_rect.width()
            )
            painter.drawText(text_rect, align, elided)
        painter.restore()

:fa-brands-github: Show source on GitHub