Python and Tkinter Programming by John Grayson

Arndt Roger Schneider arndt.roger at addcom.de
Mon May 31 13:04:42 EDT 2010


Pradeep B schrieb:

>On Sat, May 29, 2010 at 7:33 PM, Kevin Walzer <kw at codebykevin.com> wrote:
>
>  
>
>>Tkinter doesn't wrap native printing API's. There are a few extensions that
>>do it, but they are platform specific and not complete.
>>
>>The usual ways of printing are like this:
>>
>>1. If you're outputting data from the text widget, write that to a temporary
>>text file and print via lpr.
>>
>>2. If you're outputting data from the canvas, write that to a temporary
>>postscript file and print via lpr.
>>
>>This is on Unix/MacOS. Not sure what the equivalent API on Windows is.
>>
>>--Kevin
>>
>>--
>>Kevin Walzer
>>Code by Kevin
>>http://www.codebykevin.com
>>--
>>http://mail.python.org/mailman/listinfo/python-list
>>
>>    
>>
>
>
>Thanx Kevin.
>
>Anybody can throw light on how to do the same in Windows ?
>
>-pradeep
>
>
>  
>
The conventional --crude-- way is to take the bitmap of a
window and to stretchDIBBitBlt it onto the printer device in windows
and osx. Native printer dialogs do exist for both platforms ...

When you do not need a printer dialog:
Convert the Tk-GUI to SVG, then wrap it into a fo-xml wrapper
--fo accepts inline SVG-- and use fop for printing.
This approach works cross-platform, albeit you need a Java
intallation (fop is a Java application).

You can use http://jeszra.sourceforge.net to generate SVG for a complete 
Tk-GUI.
In addition. there is a python/tkinter SVG export project for the Tk canvas
--search the tkinter wiki.


-roger




More information about the Python-list mailing list