PythonWin gurus - PyCDC.DrawText() help - bad doc?
Conrad
cwren1 at cfl!rr.com
Fri Oct 24 14:30:23 EDT 2003
On Fri, 24 Oct 2003 16:54:38 +0000, Conrad wrote:
>
> Greetings,
>
> I have some simple printing I need to do from Python
> on Windows, so I opted for the excellent PyCDC methods.
>
> I got stumped when I realized that I actually needed
> something other than left-justified printing for this
> project. PyCDC.DrawText appears to offer what I need,
> but the doc at:
>
> http://aspn.activestate.com/ASPN/docs/ActivePython/PythonWin/PyCDC__DrawText_meth.html
>
> says:
>
> _________________________
> PyCDC.DrawText
>
> s,rc,forat = DrawText()
>
> Formats text in the given rectangle
>
> Return Value
> Height of text in pixels
>
> _________________________
>
OK, problem solved, (I think). I would like to suggest
the following PythonWin doc change:
______________________________
PyCDC.DrawText
n = DrawText(s,rect,format)
Formats text in the given rectangle.
Parameters
s: The desired output string
rect: The bounding rectangle in the form:
(left, top, right, bottom)
expressed in logical units
(depending on selected coordinate
system - see PyCDC.SetMapMode )
format: specifies one or more bit-or'd
format values, such as:
DT_BOTTOM i
DT_CENTER
DT_RIGHT
DT_VCENTER, etc.
for a complete list, see ????? (win32con.py? check this!)
Return Value:
n : Height of text in pixels (logical??? check this!)
Example:
import win32ui
import win32con
INCH = 1440 # twips - 1440 per inch allows fine res
def drawtext_test():
dc = win32ui.CreateDC()
dc.CreatePrinterDC() # ties to default printer
dc.StartDoc('My Python Document')
dc.StartPage()
# note: upper left is 0,0 with x increasing to the right,
# and y decreasing (negative) moving down
dc.SetMapMode(win32con.MM_TWIPS)
# Centers "TEST" about an inch down on page
dc.DrawText('TEST', (0,INCH*-1,INCH*8,INCH*-2), win32con.DT_CENTER )
dc.EndPage()
dc.EndDoc()
del dc
drawtext_test()
___________________________________
I don't normally reply to myself, but my wife
says I don't do anything normal, and besides,
I talk to myself, so this should be OK.
Hope this helps someone, and I'd still like to
know who the PythonWin doc maintainer(s) is/are
so I can pass this on. Anybody?
Regards,
Conrad
More information about the Python-list
mailing list