simple code to print a jpeg?

I've been attempting to print a jpeg for a few days now and am mostly at my wit's end. I've been using the PrintFramework example in the wxPython demos as a starting point, but am not making much progress.

Can anyone point me toward a code example that simply prints a jpeg? Like the example, I do need the Page Setup, Print Preview, and Print, and need to set margins, so the HTML printing won't work for me.

Thanks gigantically for any help.

Hi Alec,

I've been attempting to print a jpeg for a few days now and am mostly at my wit's end. I've been using the PrintFramework example in the wxPython demos as a starting point, but am not making much progress.

Can anyone point me toward a code example that simply prints a jpeg? Like the example, I do need the Page Setup, Print Preview, and Print, and need to set margins, so the HTML printing won't work for me.

Thanks gigantically for any help.

I think the way I ended up doing something like this was to just put the image in a PDF using the reportlab module. Then I could use my PDF viewer program (i.e. Adobe Reader or some such) to do a print preview, etc. I've also done it with the HTML printing thing, but I think I was using a png file at the time. Unfortunately, the last time I tried using the print framework, I didn't get anywhere.

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4101 (20090525) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Alec Bennett wrote:

I've been attempting to print a jpeg for a few days now and am mostly at my wit's end. I've been using the PrintFramework example in the wxPython demos as a starting point, but am not making much progress.

Can anyone point me toward a code example that simply prints a jpeg? Like the example, I do need the Page Setup, Print Preview, and Print, and need to set margins, so the HTML printing won't work for me.

In a nutshell, the PrintFramework operates by having you draw a page at a time. So in your case you simply need to draw a page with a bitmap on it, almost exactly the same as you would draw it on the screen. The tricky part is getting the scaling right, but that can all be calculated based on the PPI.

Please make a small sample that shows how you are trying to do it and describe in what ways it is not working. It will be easier for us to help you if we have somethings to start with. See http://wiki.wxpython.org/MakingSampleApps

···

--
Robin Dunn
Software Craftsman