Next / Previous / Contents / Shipman's homepage

13. PageTurner.addPage(): Add a new content page

The caller has created a Frame widget and wants us to add it to the list of content pages. First we add it to self.__pageList.

pageturner.py
# - - -   P a g e T u r n e r . a d d P a g e   - - -

    def addPage ( self, page ):
        """Add a new content page."""

        #-- 1 --
        # [ self.__pageList   +:=  page
        #   self.nPagesLabel  :=   1+len(self.__pageList) ]
        self.__pageList.append ( page )
        self.__nPagesVar.set ( str ( len(self.__pageList) ) )

If this is the first page to be added, we also call the .setPageNo() method so that the page gets displayed. This method also sets the page number, self.__pageNo.

pageturner.py
        #-- 2 --
        # [ if self.__pageNo == 0 ->
        #     self  :=  self with the first page displayed
        #   else -> I ]
        if  self.__pageNo == 0:
            self.setPageNo ( 1 )