Skip to content

DataFrameHolderMixin

Sub classes

Name Children Inherits
CategoryModel
cutepandas.pandasmodels.categorymodel
One row per category of a column, with its code and number of rows, read-only.
DataFrameModel
cutepandas.pandasmodels.dataframemodel
Virtual table model for pandas, pyarrow and polars frames.
    VerticalHeaderModel
    cutepandas.pandasmodels.dataframemodel
    Row labels: one column per pandas index level; row numbers for other backends.
      HorizontalHeaderModel
      cutepandas.pandasmodels.dataframemodel
      Column labels: one row per pandas column level; one row for other backends.
        SchemaModel
        cutepandas.pandasmodels.schemamodel
        One row per column of a frame (any backend), read-only.
        PandasIndexListModel
        cutepandas.pandasmodels.pandascolumnlistmodel
        Index levels of a pandas frame: name, index type, monotonic (editable).
          CornerLevelModel
          cutepandas.pandaswidgets.gridviewer
          Top-left corner model showing pandas index & column level names.

            🛈 DocStrings

            Model mixin: keeps self.df in a (possibly shared) DataFrameHolder.

            Call _init_holder from __init__ after the Qt base class is initialized. Assigning self.df replaces the holder's frame; the model itself is then expected to emit the matching signals (e.g. inside change_layout()), while all other models of the holder are reset.

            Source code in src/cutepandas/pandasmodels/dataframeholder.py
            class DataFrameHolderMixin:
                """Model mixin: keeps `self.df` in a (possibly shared) DataFrameHolder.
            
                Call `_init_holder` from `__init__` after the Qt base class is initialized.
                Assigning `self.df` replaces the holder's frame; the model itself is then expected
                to emit the matching signals (e.g. inside `change_layout()`), while all other
                models of the holder are reset.
                """
            
                _holder: DataFrameHolder
            
                def _init_holder(self, df: Any):
                    if isinstance(df, DataFrameHolder):
                        holder = df
                    else:
                        holder = DataFrameHolder(df, parent=self)
                    self._holder = holder
                    holder.about_to_change.connect(self._on_holder_about_to_change)
                    holder.changed.connect(self._on_holder_changed)
            
                @property
                def holder(self) -> DataFrameHolder:
                    return self._holder
            
                @property
                def df(self) -> Any:
                    return self._holder.df
            
                @df.setter
                def df(self, df: Any):
                    self._holder.set_df(df, origin=self)
            
                @property
                def source(self) -> FrameSource | None:
                    return self._holder.source
            
                def _on_holder_about_to_change(self, origin: Any):
                    if origin is not self:
                        self.beginResetModel()  # ty: ignore[missing-attribute]
            
                def _on_holder_changed(self, origin: Any):
                    if origin is not self:
                        self.endResetModel()  # ty: ignore[missing-attribute]
            

            :fa-brands-github: Show source on GitHub