Esempio n. 1
0
    def setItems(self, items=None):
        """
            Set a list of items for the item pager to page-through
        """
        itemsPerPage = int(self.itemsPerPage)
        if iterableLength(items) <= itemsPerPage:
            self.showAllButton.remove()
        elif self.showAllButton.toggled():
            itemsPerPage = iterableLength(items)

        self._pages_ = PositionController(items=items or [], startIndex=self._index_.value(),
                                          itemsPerPage=itemsPerPage,
                                          pagesShownAtOnce=int(self.pagesShownAtOnce))
        self._index_.setValue(self._pages_.startIndex)
Esempio n. 2
0
    def setItems(self, items=None):
        """
            Set a list of items for the item pager to page-through
        """
        itemsPerPage = int(self.itemsPerPage)
        if iterableLength(items) <= itemsPerPage:
            self.showAllButton.remove()
        elif self.showAllButton.toggled():
            itemsPerPage = iterableLength(items)

        self._pages_ = PositionController(items=items or [],
                                          startIndex=self._index_.value(),
                                          itemsPerPage=itemsPerPage,
                                          pagesShownAtOnce=int(
                                              self.pagesShownAtOnce))
        self._index_.setValue(self._pages_.startIndex)
    def __init__(self, items=[], startIndex=0, itemsPerPage=25, pagesShownAtOnce=15):
        """
            Constructs a new Position Controller Object:

            allItems = a python list, you are trying to retrieve sections from
            startIndex = where to start getting list elements from
            itemsPerPage = How many list elements to get on each page

            usage:
                positionController = PositionController(databaseQueryResults, startIndex, )
        """
        self.pagesShownAtOnce = pagesShownAtOnce
        self.allItems = items
        self.length = iterableLength(self.allItems)
        self.empty = not self.length
        self.itemsPerPage = itemsPerPage

        self.numberOfPages = self.length / self.itemsPerPage
        if self.numberOfPages < (float(self.length) / float(self.itemsPerPage)):
            self.numberOfPages += 1

        self.allPages = []
        for count in range(self.numberOfPages):
            self.allPages.append(self.pageIndex(count))

        self.lastPageIndex = 0
        if self.length > self.itemsPerPage:
            self.lastPageIndex = self.allPages[-1]

        self.setIndex(startIndex)