Hi,
I am getting different results based on how I override the OnPrintPage
method (for wxPrintout.)
Below are two samples with only the essentials. They try to draw a circle
on
the page. The first one works fine - where the subclass redefines the
OnPrintPage. The next one which reassigns the function fails
This version - where the subclass redefines the OnPrintPage function works
fine.
#!/usr/bin/env python
from wxPython.wx import *
class MyPrintout (wxPrintout):
def __init__ (self, func): wxPrintout.__init__ (self); self.func = func
def OnPrintPage (self, n): return self.func (self, n)
def OnPrintPage (PrintOutObj, n):
dc = PrintOutObj.GetDC()
dc.BeginDrawing ()
dc.DrawCircle (100,100,100)
dc.EndDrawing ()
return true
app = wxPySimpleApp ()
frm = wxFrame (None, -1, "Main Frame")
frm.Show ()
prn = wxPrinter ()
po = MyPrintout (OnPrintPage)
prn.Print (None, po, true)
app.MainLoop ()
···
#####################
This is the second file
#####################
#!/usr/bin/env python
from wxPython.wx import *
class MyPrintout (wxPrintout):
def __init__ (self, func): wxPrintout.__init__ (self); self.func = func
def OnPrintPage (self, n): return self.func (self, n)
def OnPrintPage (PrintOutObj, n):
dc = PrintOutObj.GetDC()
dc.BeginDrawing ()
dc.DrawCircle (100,100,100)
dc.EndDrawing ()
return true
app = wxPySimpleApp ()
frm = wxFrame (None, -1, "Main Frame")
frm.Show ()
prn = wxPrinter ()
po = MyPrintout (OnPrintPage)
prn.Print (None, po, true)
app.MainLoop ()
#########
The 2nd version does not display anything on the page.
Even if I just add this line
po.OnPrintPage = lambda n: OnPrintPage (n)
to the first version just after "po = MyPrintout (OnPrintPage)" - i get a
blank page.
My examples using just python to get a difference in calling semantics for
subclassing functions vs. reassigning functions do not seem to bring out
the
difference.
Could someone throw some light on this?
Thanks,
Chirayu.
Email: thephoenix235@gmx.net
Web: http://cs.oregonstate.edu/~krishnch/ms.html
--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!