printing with Python/Windows

Roger Burnham roger.burnham at gte.net
Wed Jul 21 15:43:46 EDT 1999


On Tue, 20 Jul 1999 21:12:03 -0800, Voynow, Sasha <sasha at tunes.com> wrote:

>
>Thanks for the help.
>
>Once I started digging into solving this problem my mind
>was boggled by what
>seemed to be a whole  lot of extra overhead involved in
>what was essentially
>a simple scripting task (i.e. doing some batch image
>processing with PIL and
>sending the results to a printer). But I guess that's life
>under Windows...
>I'll have to take a look at this script and see if I can
>modify it for
>"unattended" execution, as that is what I'm really after.
>

Okay, done.  See my web site:

http://starship.python.net/crew/roger/

for DisplayImage.py.  From the doc:


Image Display and Printing demo.

Demonstrates a number of techniques for displaying and printing images using
the PythonWin MFC framework.  This method of printing is suitable for
"automatic" printing, and so, uses the default printer settings.

As this was ripped out of a larger app, I left some other stuff in as well:
    *) The pixel value under the cursor is displayed in the title bar.
    *) You can draw up to four circles on the image using the mouse.
    *) After four circles are drawn, you can drag them to new locations.
    *) You can delete a circle with the delete or backspace key.
    *) Right click on the image to get an options menu (print only for now).

Usage:
    from the windows command line:
        PythonWin.exe /app path/DisplayImage.py [-p -m mag] [imagePath]
        where:
            path:      The directory containing this script.
            -p:        If present, print the image and exit.
            -m mag:    Only used if -p present, the magnification to print at,
                       defaults to 3.
            imagePath: The image to open and display.
        You may need to supply the PythonWin.exe path as well.
        If you use the -p option, you must supply the imagePath as well.
        If no imagePath is given, an open file dialog is used to get the image.

    from the Python/PythonWin command prompt (or, within a script):
        import DisplayImage
        DisplayImage.displayImage() # Use file dialog to get and display an
                                    # image
        DisplayImage.displayImage(imgPath) # display given image
        DisplayImage.printImage(imgPath, mag) # print image at mag.
        
Requires:  PIL (Python Imaging Library)
           PythonWin (Build 125 or later)



Cheers,
 

Roger Burnham   
Cambridge Research & Instrumentation   
rburnham at cri-inc.com   
http://www.cri-inc.com/   
http://starship.python.net/crew/roger/   
PGP Key: http://www.nai.com/default_pgp.asp   
PGP Fingerprint: 5372 729A 9557 5F36 177F  084A 6C64 BE27 0BC4 CF2D   




More information about the Python-list mailing list