Hi, I have written a simple image viewer that I now want to expand to
print what ever image that it currently has loaded. it really should
just be a full size print, and I'll add scaling to a user chosen size
later. How do I do this?
I have looked at the "Print Framework" in the demo, but I'm not sure
what should be my canvas.
If you need to see some code, just ask.
Update:
I have started to use my head a little bit more, and now I need to
know if a wxPanel or wxImage can be a "canvas".
···
On Feb 1, 8:37 am, mpnordland <mpnordl...@gmail.com> wrote:
Hi, I have written a simple image viewer that I now want to expand to
print what ever image that it currently has loaded. it really should
just be a full size print, and I'll add scaling to a user chosen size
later. How do I do this?
I have looked at the "Print Framework" in the demo, but I'm not sure
what should be my canvas.
If you need to see some code, just ask.
If you look at the wxPython demo, it uses a ScrolledWindow. That makes
me think that frames and panels are probably fine. Note that I have
not used the PrintFramework, just the easy HTML printing.
···
On Feb 1, 9:43 am, mpnordland <mpnordl...@gmail.com> wrote:
On Feb 1, 8:37 am, mpnordland <mpnordl...@gmail.com> wrote:> Hi, I have written a simple image viewer that I now want to expand to
> print what ever image that it currently has loaded. it really should
> just be a full size print, and I'll add scaling to a user chosen size
> later. How do I do this?
> I have looked at the "Print Framework" in the demo, but I'm not sure
> what should be my canvas.
> If you need to see some code, just ask.Update:
I have started to use my head a little bit more, and now I need to
know if a wxPanel or wxImage can be a "canvas".
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
PyCon 2010 Atlanta Feb 19-21 http://us.pycon.org/
mpnordland wrote:
I have started to use my head a little bit more, and now I need to
know if a wxPanel or wxImage can be a "canvas".
I'm not sure what you mean by "Canvas", but yes, you can draw arbitrary stuff to a wx.Panel (or wx.Window).
I haven't poked into the print framework for a while, but somewhere int here there will be a DC to draw to, and you can draw your image with DC.DrawBitmap.
you'll have to do a bit of math to scale the Image to make the right size bitmap, as DrawBitmap works in pixel cords, so you'll have to figure out what the pixel coords are of the paper in the PrintDC.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
You don't really need a window to be your 'canvas' (in the terms of that sample.) The print framework is centered around the Printout class, and it is your class derived from wx.Printout that does all the real work. In the demo we have it using the ScrolledWindow sample as a 'canvas' simply to save needing to have its own drawing code, and so that sample could focus on the printing aspects only.
In your app you'll just need to have your OnPrintPage method set up the scaling and then draw your image and anything else you want to appear on the page. It really doesn't have to be any more complex than that.
···
On 2/1/10 5:37 AM, mpnordland wrote:
Hi, I have written a simple image viewer that I now want to expand to
print what ever image that it currently has loaded. it really should
just be a full size print, and I'll add scaling to a user chosen size
later. How do I do this?
I have looked at the "Print Framework" in the demo, but I'm not sure
what should be my canvas.
--
Robin Dunn
Software Craftsman
ok, the printing is mostly working, but most of the times i have it
print, the printer doesn't print the image, in my programs preview,
the image is there, but it doesn't print on the printer.
ps, i only experience this with my hardware printer, with a program
such as PDFcreator, it works just fine.