Next / Previous / Contents / Shipman's homepage

3. How to use a PageTurner widget

To add a PageTurner widget to your Tkinter application, use this procedure:

  1. Instantiate the widget in some parent window, and grid it. Let's call the instance PT. Here's the general form of the constructor:

    PT = PageTurner ( master=None, size=None )
    PT.grid(...)
    

    master is the parent widget in which you want to create the PageTurner widget. If you omit the size argument, the page viewing area will be resized for each page as it is displayed. If you want the page viewing area to have a minimum size, use an argument of the form size=(w, h) where w is the width and h the width of the area, expressed in pixels.

  2. If you want to display anything between the button frame and the page viewing area, place the material into the Frame widget PT.headFrame.

  3. Create Frame widgets for each content page; each such widget should have Pt as its parent. Then for each content page frame f, call the PT.addPage(f) method to add the frame as the next page.

    Do not grid these widgets as you create them. Until the next step, nothing will appear in the page viewing area.

  4. Use the method PT.setPageNo(n) to display page n, counting from 1. The default value for n is 1, the first content page.