PythonWin gurus - PyCDC.DrawText() help - bad doc?

C

Conrad

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

_________________________

This looks more than a little odd to me.
For one, the text specifies what is probably
a return type of int (height in pixels),
but the template (s,rc,forat = DrawText())
shows a totally different type of return.
Additionally, DrawText apparently takes no
aguments. Very odd.

I would have expected something more like
the DrawFrameControl doc, which looks like
this:

__________________________
PyCDC.DrawFrameControl

DrawFrameControl(rect, typ, state)

Draws a frame control of the specified type and style.

Parameters

rect : (left, top, right, bottom)

Specifies the bounding rectangle, in logical units.

typ : int

state : int

MFC References

CDC::DrawFrameContr

__________________________

Does anyone out there have an example of
using DrawText to right or center justify
text? And who do I contact regarding the
suspect doc?

Many thanks,

Conrad
 
C

Conrad

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top