Printing in wxPython

Anand B Pillai abpillai at lycos.com
Mon Mar 31 12:49:28 CEST 2003


Hi Lexy

   I figured it out quite soon after I posted this. As you said,
I have to use self.base_OnBeginDocument() and self.GetDC(). Now
it works and I have posted the code on my website. Yeah I fixed
the scaling problems also.

Thanks
http://members.fortunecity.com/anandpillai

Anand

PS: Quite out of context, but your second name is russian but first name
    sounds american :-)

"Lexy Zhitenev" <zhitenev at cs.vsu.ru> wrote in message news:<b63q9c$mrl$1 at serv.vrn.ru>...
> "Anand B Pillai" <abpillai at lycos.com> wrote in message:
> news:bd993a2f.0303280717.3f7a19d at posting.google.com...
> > Hi
> 
> Hi, also
> <snip>
> >   Moreover the python interpreter gives a NameError for the methods
> > wxPrintout_GetDC() and wxPrintout_OnBeginDocument(). What I am trying
> 
> Certainly, wxPrintout_GetDC() doesn't exist. You can get a dc by issuing
> self.GetDC(), or wxPrintout.GetDC(self).
> Neither wxPrintout_OnBeginDocument()
> 
> <snip>
> 
> >  wxPython note: If this method is overridden in a Python class then
> > the base class version can be called by using the
> > methodbase_OnBeginDocument(startPage, endPage).
> A bit mistaken: <Quote>
> wxPython note: If this method is overridden in a Python class then the base
> class version can be called by using the method
> base_OnBeginDocument(startPage, endPage).
> </Quote>
> 
> Note the ' ' between method and base. You have to call method which name is
> 'base_OnBeginDocument(startPage, endPage)'. Don't be confused.
> 
> 
> >  The printing example given is also very confusing. It is not very clear
> > how the device context of the current window is passed to the printer.
> > It would be helpful if anyone who has got it right could enlighten. :-)
> 
> You don't need to pass a device context to your document dc. You have to
> _draw_ on this dc.
> You issue BeginDoc, draw on a printer DC, issue EndDoc, and after that
> printer prints what you have drawn on this DC between BeginDoc and EndDoc.
> In your particular example, you have to copy the information from your
> panel's DC to Printer DC. See DC method Blit. I can give you only a rough
> example:
> 
> def OnPrintPage(self, pgno):
>            dc = self.GetDC()
>            pandc = self.panel1.GetDC()
>            sz = pandc.GetSizeTuple()
>            dc.Blit(0,0, sz[0], sz[1], 0, 0, pandc)
> 
> This should print the content of your panel without zooming (if there are no
> errors). Remember that screen resolution and printer resolution are very
> different (72dpi and 300 dpi, e.g.). You may have to zoom your drawings. See
> also wxDC.SetUserScale and wxMemoryDC.
> 
> > Thanks for your help,
> 
> I am glad to help you.
> 
> > Anand Pillai
> 
> Regards, Lexy.




More information about the Python-list mailing list