Skip to content

PageRanges

Base classes

Name Children Inherits
QPageRanges
PySide6.QtGui
QPageRanges(self, /) -> None

⋔ Inheritance diagram

graph TD
  57725069["gui.PageRanges"]
  2460816066["QtGui.QPageRanges"]
  37984305["Shiboken.Object"]
  2751680898["builtins.object"]
  2460816066 --> 57725069
  37984305 --> 2460816066
  2751680898 --> 37984305

🛈 DocStrings

Bases: QPageRanges

Represents a collection of page ranges.

Source code in prettyqt/gui/pageranges.py
class PageRanges(QtGui.QPageRanges):
    """Represents a collection of page ranges."""

    def __bool__(self):
        return not self.isEmpty()

    def __getitem__(self, index: int):
        return self.get_range_list()[index]

    def __str__(self):
        return self.toString()

    def __repr__(self):
        return get_repr(self, self.get_range_list())

    def __contains__(self, other: int):
        return self.contains(other)

    def __add__(self, other: int | tuple[int, int]):
        if isinstance(other, int):
            self.addPage(other)
        else:
            self.addRange(*other)
        return self

    def __len__(self):
        return self.lastPage() - self.firstPage()

    def get_range_list(self) -> list[tuple[int, int]]:
        return [(i.from_, i.to) for i in self.toRangeList()]

:fa-brands-github: Show source on GitHub