I'm trying to make use of the wx print framework.
If I have a long string that I want to wrap and fit in a rectangle of a certain width when printed in a certain (probably proportional) font, how do I get it wrapped properly?
The Python textwrap routines are just character based.
Other than writing an iterative trial-and-error wrapping function, how can I get text wrapped in optimal fashion?
Thanks,
Michael
Michael Hipp wrote:
I'm trying to make use of the wx print framework.
If I have a long string that I want to wrap and fit in a rectangle of a certain width when printed in a certain (probably proportional) font, how do I get it wrapped properly?
The Python textwrap routines are just character based.
Other than writing an iterative trial-and-error wrapping function, how can I get text wrapped in optimal fashion?
Thanks,
Michael
I don't use the wx print framework. Instead, I create all my documents using reportlab. Neither one is well documented, but I found reportlab easier to figure out. You can use the easy html printing part of wx using common html code to control the formatting. If you need all the print dialogs though, you'll have to use the fully featured print framework.
Mike
Mike Driscoll wrote:
I don't use the wx print framework. Instead, I create all my documents using reportlab. Neither one is well documented, but I found reportlab easier to figure out. You can use the easy html printing part of wx using common html code to control the formatting. If you need all the print dialogs though, you'll have to use the fully featured print framework.
I use both the easy printing html framework and also reportlab.
The html printing framework is overall just too limited. It's sure nice in the cases where it can be used.
Reportlab I love. But it ... has ... one ... unbearable ... shortcoming.
It creates PDFs.
Which means that on MSW you're generally stuck with Adobe Reader. (shivers)
Michael
Andrea Gavana wrote:
If I have a long string that I want to wrap and fit in a rectangle of a
certain width when printed in a certain (probably proportional) font, how do
I get it wrapped properly?
The Python textwrap routines are just character based.
Other than writing an iterative trial-and-error wrapping function, how can I
get text wrapped in optimal fashion?
You might try to look at wx.lib.wordwrap, it does what you are looking for.
Thanks, Andrea. That looks to fit the bill.
Here's the direct link for any future seekers:
http://wxpython.org/docs/api/wx.lib.wordwrap-module.html
Michael
Michael Hipp wrote:
Mike Driscoll wrote:
I don't use the wx print framework. Instead, I create all my documents using reportlab. Neither one is well documented, but I found reportlab easier to figure out. You can use the easy html printing part of wx using common html code to control the formatting. If you need all the print dialogs though, you'll have to use the fully featured print framework.
I use both the easy printing html framework and also reportlab.
The html printing framework is overall just too limited. It's sure nice in the cases where it can be used.
Reportlab I love. But it ... has ... one ... unbearable ... shortcoming.
It creates PDFs.
Which means that on MSW you're generally stuck with Adobe Reader. (shivers)
Michael
Well, yes...but versions 8 and 9 are at least fast and not nearly as bloated as 6 and 7 were. And there's always Foxit: http://www.foxitsoftware.com/pdf/rd_intro.php
I forgot about the wordwrap thing...silly of me since I use it. Oh well...Andrea to the rescue!
···
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
Here is what I use within the ObjectListView printer.
Regards,
Phillip
WordWrapRenderer.py (8.5 KB)
···
------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper phillip_piper@bigfoot.com
A man's life does not consist in the abundance of his possessions
-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org
[mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Michael
Hipp
Sent: Monday, 12 January 2009 6:08 PM
To: wxPython-users@lists.wxwidgets.org
Subject: [wxpython-users] Text wrapping for print?
I'm trying to make use of the wx print framework.
If I have a long string that I want to wrap and fit in a rectangle of a
certain
width when printed in a certain (probably proportional) font, how do I get
it
wrapped properly?
The Python textwrap routines are just character based.
Other than writing an iterative trial-and-error wrapping function, how can I
get text wrapped in optimal fashion?
Thanks,
Michael
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users