473,480 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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:

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

_________________________

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
Jul 18 '05 #1
1 3000
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/doc...Text_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

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3003
by: Martin Bless | last post by:
IMHO PythonWin is great help in developing. How can I do something like: if detect("running on PythonWin"): pass # fake arguments ... else: "proceed normal"
14
2860
by: Jive | last post by:
I've un-installed Python 2.4, re-installed Python 2.3 and PythonWin for 2.3, but it's still broke. When I start PythonWin, sometimes it looks like it is going to be okay. But as soon as I open...
4
2593
by: Chris P. | last post by:
I've been having a problem with PythonWin that seemed to start completely spontaneously and I don't even know where to START to find the answer. The only thing I can think of that marks the point...
1
1308
by: DrDevious | last post by:
Maybe I am doing something wrong but has anyone else here noticed a difference in the positioning of text between the Graphics.DrawString method and the Win32 GDI DrawText function? My text is...
7
1666
by: DF | last post by:
DrawText is overloaded - one of which accepts a ByVal rect and the other accepts a ByRef rect. I get a "no accessible 'DrawText' is most specific" error. How can I resolve this problem by forcing VB...
2
4877
by: Alex C. Barberi | last post by:
I'm using VB.NET 2005 and DX9 SDK (Apr 2006). I created an instance of the Direct3D.Font, and when I try to call DrawText it says: 'DrawText' is ambiguous because multiple kinds of members with...
1
1676
by: sirithvasa | last post by:
Hi there, I've the problem, that the DrawText function cover the below graphic elemets, so it isn't transparent. Is there any way, to get the printout of the DrawText function transparent? ...
3
2964
by: archaegeo | last post by:
I am getting started in Python, and I have looked on both the stackless page and python.org and cannot find the answer to what I think is a simple problem. If I start the python command line or...
0
3690
by: MrT | last post by:
Hi there, I was just wondering if anyone had any ideas why this doesn't work on a php page! exec("/usr/bin/ffmpeg -i Movie.avi -vhook 'lib/vhook/drawtext.so -f fonts/tahomabd.TTF -x 10 -y 10...
0
7046
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7048
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7088
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6741
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5342
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4783
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2986
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.