Printing

Craig Ringer craig at postnewspapers.com.au
Tue Dec 21 02:34:16 EST 2004


On Tue, 2004-12-21 at 06:45, Jim & Joanne Collins wrote:
> I've completed a semester of computer programming in Python and one
> thing we didn't learn was how to send data to a windows printer
> instead of the screen.

It would be helpful to know what graphical toolkit and canvas widget you
are using, as this may well be significant.

> Any help would be greatly appreciated!

My usual approach is actually to generate a PDF document using ReportLab
and send that to the printer. Under *nix this is easy - if available,
CUPS can handle PDF directly, or you use acroread -toPostScript to
generate postscript and send that. Under Windows, I expect you can use
COM to call acrobat if there isn't a simpler method.

If you're using an existing canvas widget for your drawing, it depends
on the canvas widget. Some can be saved to a bitmap, some can save
vector data, etc.

If you could explain how you're doing your screen drawing, that would
help a lot.

> Also, is there any way to send a shell command to access some function
> of the basic windows operating system such as sort?

import os
help(os.system)
help(os.popen)

for more advanced use, COM is an option.

> Or to do a DOS directory and send it directly to a file to be accessed
> as needed?

I'm afraid I just don't understand that. "Do" a DOS directory?  If you
want to list the contents of a directory, see help(os.listdir) .

--
Craig Ringer




More information about the Python-list mailing list