parameters: (self, indx, page, text, select=True, imageId=-1)
return_statement: return True
docstring: Inserts a new page at the specified position.
  
          @param indx: Specifies the position of the new page.
          @param page: Specifies the new page.
          @param text: Specifies the text for the new page.
          @param select: Specifies whether the page should be selected.
          @param imageId: Specifies the optional image index for the new page.
          
          Return value:
          True if successful, False otherwise.
docstring_summary: Inserts a new page at the specified position.
docstring_tokens: Inserts a new page at the specified position .
function: def InsertPage(self, indx, page, text, select=True, imageId=-1):
          """
          Inserts a new page at the specified position.
  
          @param indx: Specifies the position of the new page.
          @param page: Specifies the new page.
          @param text: Specifies the text for the new page.
          @param select: Specifies whether the page should be selected.
          @param imageId: Specifies the optional image index for the new page.
          
          Return value:
          True if successful, False otherwise.
          """     
  
          # sanity check
          if not page:
              return False
  
          # reparent the window to us
          page.Reparent(self)
  
          if not self._windows:
          
              self.AddPage(page, text, select, imageId)
              return True
  
          # Insert tab
          bSelected = select or not self._windows
          curSel = self._pages.GetSelection()
          
          indx = max(0, min(indx, len(self._windows)))
  
          if indx <= len(self._windows):
          
              self._windows.insert(indx, page)
          
          else:
          
              self._windows.append(page)
  
          if bSelected:
          
              bSelected = False
              
              # Check for selection and send events
              oldSelection = self._pages._iActivePage
              
              event = FlatNotebookEvent(wxEVT_FLATNOTEBOOK_PAGE_CHANGING, self.GetId())
              event.SetSelection(indx)
              event.SetOldSelection(oldSelection)
              event.SetEventObject(self)
              
              if not self.GetEventHandler().ProcessEvent(event) or event.IsAllowed() or len(self._windows) == 0:
                  bSelected = True            
          
          self._pages.InsertPage(indx, text, bSelected, imageId)
          
          if indx <= curSel:
              curSel = curSel + 1
  
          self.Freeze()
  
          # Check if a new selection was made
          if bSelected:
          
              if curSel >= 0:
              
                  # Remove the window from the main sizer
                  self._mainSizer.Detach(self._windows[curSel])
                  self._windows[curSel].Hide()
              
              self._pages.SetSelection(indx)
  
              # Fire a wxEVT_FLATNOTEBOOK_PAGE_CHANGED event
              event.SetEventType(wxEVT_FLATNOTEBOOK_PAGE_CHANGED)
              event.SetOldSelection(oldSelection)
              self.GetEventHandler().ProcessEvent(event)
          
          else:
          
              # Hide the page
              page.Hide()
  
          self.Thaw()
          self._mainSizer.Layout()        
          self.Refresh()
  
          return True
function_tokens: def InsertPage ( self , indx , page , text , select = True , imageId = - 1 ) : # sanity check if not page : return False # reparent the window to us page . Reparent ( self ) if not self . _windows : self . AddPage ( page , text , select , imageId ) return True # Insert tab bSelected = select or not self . _windows curSel = self . _pages . GetSelection ( ) indx = max ( 0 , min ( indx , len ( self . _windows ) ) ) if indx <= len ( self . _windows ) : self . _windows . insert ( indx , page ) else : self . _windows . append ( page ) if bSelected : bSelected = False # Check for selection and send events oldSelection = self . _pages . _iActivePage event = FlatNotebookEvent ( wxEVT_FLATNOTEBOOK_PAGE_CHANGING , self . GetId ( ) ) event . SetSelection ( indx ) event . SetOldSelection ( oldSelection ) event . SetEventObject ( self ) if not self . GetEventHandler ( ) . ProcessEvent ( event ) or event . IsAllowed ( ) or len ( self . _windows ) == 0 : bSelected = True self . _pages . InsertPage ( indx , text , bSelected , imageId ) if indx <= curSel : curSel = curSel + 1 self . Freeze ( ) # Check if a new selection was made if bSelected : if curSel >= 0 : # Remove the window from the main sizer self . _mainSizer . Detach ( self . _windows [ curSel ] ) self . _windows [ curSel ] . Hide ( ) self . _pages . SetSelection ( indx ) # Fire a wxEVT_FLATNOTEBOOK_PAGE_CHANGED event event . SetEventType ( wxEVT_FLATNOTEBOOK_PAGE_CHANGED ) event . SetOldSelection ( oldSelection ) self . GetEventHandler ( ) . ProcessEvent ( event ) else : # Hide the page page . Hide ( ) self . Thaw ( ) self . _mainSizer . Layout ( ) self . Refresh ( ) return True