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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Conrad

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


    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:



    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 DrawFrameContro l doc, which looks like
    this:

    _______________ ___________
    PyCDC.DrawFrame Control

    DrawFrameContro l(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::DrawFrameC ontr

    _______________ ___________

    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


  • Conrad

    #2
    Re: PythonWin gurus - PyCDC.DrawText( ) help - bad doc?

    On Fri, 24 Oct 2003 16:54:38 +0000, Conrad wrote:
    [color=blue]
    >
    > 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/doc...Text_meth.html
    >
    > says:
    >
    > _______________ __________
    > PyCDC.DrawText
    >
    > s,rc,forat = DrawText()
    >
    > Formats text in the given rectangle
    >
    > Return Value
    > Height of text in pixels
    >
    > _______________ __________
    >[/color]


    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.SetMapMod e )

    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.CreateD C()
    dc.CreatePrinte rDC() # 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(w in32con.MM_TWIP S)


    # Centers "TEST" about an inch down on page
    dc.DrawText('TE ST', (0,INCH*-1,INCH*8,INCH*-2), win32con.DT_CEN TER )

    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



    Comment

    Working...