Next / Previous / Contents / Shipman's homepage

7.6. fosoxtest: buildStatic()

This function adds static-content elements to the page-sequence element. Each one defines the content of a header or footer in one of the simple-page-master elements.

fosoxtest
# - - -   b u i l d S t a t i c

def buildStatic(s):
    '''Set up all static content.

      [ s is a sox.Sox instance ->
          s  +:=  static-content elements that set up headers in
              regions ODD_BEFORE and EVEN_BEFORE and footers in
              regions ODD_AFTER and EVEN_AFTER ]
    '''  

On odd pages, the header is the text “Running head”, right-aligned, and the footer has the page number right-aligned.

fosoxtest
    #-- 1
    # [ s  +:=  a static-content element with fixed text in the
    #           ODD_BEFORE region ]
    oddHeader = f.staticContent(s, ODD_BEFORE)
    b = f.block(s, HEAD_FONT, f.dash(textAlign="right"), "Running head")
    b.end()
    oddHeader.end()

    #-- 2
    # [ s  +:=  a static-content element with the page number in
    #           the ODD_AFTER region ]
    oddFooter = f.staticContent(s, ODD_AFTER)
    b = f.block(s, FOOT_FONT, textAlign="right")
    s.leaf("page-number")
    b.end()
    oddFooter.end()

The even-page headers and footers have the same content, only left-aligned.

fosoxtest
    #-- 3
    # [ s  +:=  a static-content element with fixed text in the
    #           EVEN_BEFORE region ]
    evenHeader = f.staticContent(s, EVEN_BEFORE)
    b = f.block(s, HEAD_FONT, f.dash(textAlign="left"), "Running head")
    b.end()
    evenHeader.end()

    #-- 4
    # [ s  +:=  a static-content element with the page number in
    #           the EVEN_AFTER region ]
    evenFooter = f.staticContent(s, EVEN_AFTER)
    b = f.block(s, FOOT_FONT, textAlign="left")
    s.leaf("page-number")
    b.end()
    evenFooter.end()