Breaking/Wrapping lines "automatically"

Fredrik Lundh fredrik at pythonware.com
Thu Mar 23 08:50:21 EST 2006


Jorge Godoy wrote:
> Is there something I can do in PIL to restrict a line to a certain size and
> have it to break/wrap into a newline automatically?  (Or by using some
> code, of course...)

there's no standard function for this purpose, no.

here's a somewhat rough implementation, based on a WCK demo:

http://effbot.python-hosting.com/file/stuff/sandbox/pil/textwrap.py

a somewhat better approach would be to use collect words as long as
they fit, and write each line as a single string.

</F> 






More information about the Python-list mailing list