[Tutor] A Newbie Printing Question

Alan Gauld alan.gauld at freenet.co.uk
Tue Mar 29 19:37:07 CEST 2005


> I have little experience with programming.  I have Python installed
on a
>   Windows XP system.  What code do I need to use to send output from
a
> Python script to a local printer attached to my workstation?  to a
> network printer?

Printing in windows is inordinately difficult although there are some
modules around to help. In essence you have to draw the window as if
you were drawing in a canvas object on the screen but using a printer
device context. This is much too much like hard work and I generally
do one of two things:

1) For plain text use the old DOS trick of sending output direct
   to the PRN: file/device - I can't remember if this still works
   in XP but I can't think why not...

2) For anything else generate HTML and then use the command line
   switches in the browser to generate the outpur using the default
printer.

Another option but its much more work is to create a PDF file for
which
task a 3rd party module exists somewhere.

A lot depends on how complex your output needs to be. Text, Graphics
or both.
And how critical is the precision of your layout?

HTH,

Alan G.



More information about the Tutor mailing list