I saw a similar question already asked (a couple of years ago), and it related to the print of a Tkinter Canvas.
I need instead to print the content of a Text
widget, which may contain also images.
I was surprised/horrified to discover that maybe there isn't a way to do it. I could live with a PDF export.
PDFlib
seemed to have many drawbacks, but it might be tackled:
Price is high
Then I noticed this PDFLib Lite, which seems to have all I need.
Difficult install with a configure and make step that didn't want to setup the Python bindings.
Then I found out that a simple: yum install pdflib-lite-python
.
In any case, you should install the source, because it contains many Python examples.
The is no support in the text widget for printing, or exporting to a print-friendly format.
That being said, if you don't have embedded widgets or images then it should be pretty easy to take the contents of a text widget and convert it to pdf using something like pdflib. While the text widget doesn't directly support rich text formats, it has very good introspection capabilities.