Pythonwin (Version 2 beta 3)

Neil Hodgson neilh at hare.net.au
Sat Feb 26 08:21:38 EST 2000


  I have fixed PythonWin source code printing to print the last page. The
file is view.py located at:

\Program Files\Python\PythonWin\pywin\scintilla\view.py

  You can download the fixed file from

http://www.scintilla.org/view.py

   The problem is caused by having the last page in the starts array be
marked with the same value (length of document) that is also used as a
sentinel on the last page plus 1. When the sentinel is discovered, printing
stops.

   If you want to just patch the code, replace from line 507 which starts
with

if not pInfo.GetPreview()

to the end of the OnPrepareDC method with:

if not pInfo.GetPreview() and self.starts is not None:
    prevPage = pInfo.GetCurPage() - 1
    if prevPage > 0 and self.starts[prevPage] >= self.GetTextLength():
        # All finished.
        pInfo.SetContinuePrinting(0)
        return
    dc.SetMapMode(win32con.MM_TEXT);

(indenting as appropriate)

   A better approach in the code may be to choose a sentinel 1 greater than
any possible document index.

   Neil






More information about the Python-list mailing list