Changes to how overridable C++ methods are virtualized for Python.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37369 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -541,10 +541,10 @@ class SetPrintout(wx.Printout):
|
||||
self.end_pg = 1
|
||||
|
||||
def OnBeginDocument(self, start, end):
|
||||
return self.base_OnBeginDocument(start, end)
|
||||
return super(SetPrintout, self).OnBeginDocument(start, end)
|
||||
|
||||
def OnEndDocument(self):
|
||||
self.base_OnEndDocument()
|
||||
super(SetPrintout, self).OnEndDocument()
|
||||
|
||||
def HasPage(self, page):
|
||||
if page <= self.end_pg:
|
||||
@@ -564,7 +564,7 @@ class SetPrintout(wx.Printout):
|
||||
return (str_pg, end_pg, str_pg, end_pg)
|
||||
|
||||
def OnPreparePrinting(self):
|
||||
self.base_OnPreparePrinting()
|
||||
super(SetPrintout, self).OnPreparePrinting()
|
||||
|
||||
def OnBeginPrinting(self):
|
||||
dc = self.GetDC()
|
||||
@@ -581,7 +581,7 @@ class SetPrintout(wx.Printout):
|
||||
scaleY = float(h) / 1000
|
||||
self.printUserScale = min(scaleX, scaleY)
|
||||
|
||||
self.base_OnBeginPrinting()
|
||||
super(SetPrintout, self).OnBeginPrinting()
|
||||
|
||||
def GetSize(self):
|
||||
self.psizew, self.psizeh = self.GetPPIPrinter()
|
||||
|
@@ -11,15 +11,6 @@ class MyCellEditor(gridlib.PyGridCellEditor):
|
||||
grid editors. All the methods that can be overridden are shown here. The
|
||||
ones that must be overridden are marked with "*Must Override*" in the
|
||||
docstring.
|
||||
|
||||
Notice that in order to call the base class version of these special
|
||||
methods we use the method name preceded by "base_". This is because these
|
||||
methods are "virtual" in C++ so if we try to call wx.GridCellEditor.Create
|
||||
for example, then when the wxPython extension module tries to call
|
||||
ptr->Create(...) then it actually calls the derived class version which
|
||||
looks up the method in this class and calls it, causing a recursion loop.
|
||||
If you don't understand any of this, don't worry, just call the "base_"
|
||||
version instead.
|
||||
"""
|
||||
def __init__(self, log):
|
||||
self.log = log
|
||||
@@ -58,7 +49,7 @@ class MyCellEditor(gridlib.PyGridCellEditor):
|
||||
to set colours or fonts for the control.
|
||||
"""
|
||||
self.log.write("MyCellEditor: Show(self, %s, %s)\n" % (show, attr))
|
||||
self.base_Show(show, attr)
|
||||
super(MyCellEditor, self).Show(show, attr)
|
||||
|
||||
|
||||
def PaintBackground(self, rect, attr):
|
||||
@@ -126,7 +117,7 @@ class MyCellEditor(gridlib.PyGridCellEditor):
|
||||
self.log.write("MyCellEditor: IsAcceptedKey: %d\n" % (evt.GetKeyCode()))
|
||||
|
||||
## We can ask the base class to do it
|
||||
#return self.base_IsAcceptedKey(evt)
|
||||
#return super(MyCellEditor, self).IsAcceptedKey(evt)
|
||||
|
||||
# or do it ourselves
|
||||
return (not (evt.ControlDown() or evt.AltDown()) and
|
||||
@@ -172,7 +163,7 @@ class MyCellEditor(gridlib.PyGridCellEditor):
|
||||
def Destroy(self):
|
||||
"""final cleanup"""
|
||||
self.log.write("MyCellEditor: Destroy\n")
|
||||
self.base_Destroy()
|
||||
super(MyCellEditor, self).Destroy()
|
||||
|
||||
|
||||
def Clone(self):
|
||||
|
@@ -16,33 +16,25 @@ class MyHtmlWindow(html.HtmlWindow):
|
||||
def __init__(self, parent, id, log):
|
||||
html.HtmlWindow.__init__(self, parent, id, style=wx.NO_FULL_REPAINT_ON_RESIZE)
|
||||
self.log = log
|
||||
self.Bind(wx.EVT_SCROLLWIN, self.OnScroll )
|
||||
if "gtk2" in wx.PlatformInfo:
|
||||
self.SetStandardFonts()
|
||||
|
||||
def OnScroll( self, event ):
|
||||
#print 'event.GetOrientation()',event.GetOrientation()
|
||||
#print 'event.GetPosition()',event.GetPosition()
|
||||
event.Skip()
|
||||
|
||||
def OnLinkClicked(self, linkinfo):
|
||||
self.log.WriteText('OnLinkClicked: %s\n' % linkinfo.GetHref())
|
||||
|
||||
# Virtuals in the base class have been renamed with base_ on the front.
|
||||
self.base_OnLinkClicked(linkinfo)
|
||||
|
||||
super(MyHtmlWindow, self).OnLinkClicked(linkinfo)
|
||||
|
||||
def OnSetTitle(self, title):
|
||||
self.log.WriteText('OnSetTitle: %s\n' % title)
|
||||
self.base_OnSetTitle(title)
|
||||
super(MyHtmlWindow, self).OnSetTitle(title)
|
||||
|
||||
def OnCellMouseHover(self, cell, x, y):
|
||||
self.log.WriteText('OnCellMouseHover: %s, (%d %d)\n' % (cell, x, y))
|
||||
self.base_OnCellMouseHover(cell, x, y)
|
||||
super(MyHtmlWindow, self).OnCellMouseHover(cell, x, y)
|
||||
|
||||
def OnCellClicked(self, cell, x, y, evt):
|
||||
self.log.WriteText('OnCellClicked: %s, (%d %d)\n' % (cell, x, y))
|
||||
self.base_OnCellClicked(cell, x, y, evt)
|
||||
super(MyHtmlWindow, self).OnCellClicked(cell, x, y, evt)
|
||||
|
||||
|
||||
|
||||
# This filter doesn't really do anything but show how to use filters
|
||||
|
@@ -418,14 +418,6 @@ Pierre Hj
|
||||
less likely to get rusty because nobody cares about the C++ lib any
|
||||
more.
|
||||
|
||||
<p>The Python version should be mostly drop-in compatible with the
|
||||
wrapped C++ version, except for the location of the package
|
||||
(wx.lib.ogl instead of wx.ogl) and that the base class methods are
|
||||
called the normal Python way (superclass.Method(self, ...)) instead of the
|
||||
hacky way that had to be done to support overloaded methods with the
|
||||
old SWIG (self.base_Method(...))
|
||||
|
||||
|
||||
"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@@ -15,38 +15,38 @@ class MyPrintout(wx.Printout):
|
||||
self.log = log
|
||||
|
||||
def OnBeginDocument(self, start, end):
|
||||
self.log.WriteText("wx.Printout.OnBeginDocument\n")
|
||||
return self.base_OnBeginDocument(start, end)
|
||||
self.log.WriteText("MyPrintout.OnBeginDocument\n")
|
||||
return super(MyPrintout, self).OnBeginDocument(start, end)
|
||||
|
||||
def OnEndDocument(self):
|
||||
self.log.WriteText("wx.Printout.OnEndDocument\n")
|
||||
self.base_OnEndDocument()
|
||||
self.log.WriteText("MyPrintout.OnEndDocument\n")
|
||||
super(MyPrintout, self).OnEndDocument()
|
||||
|
||||
def OnBeginPrinting(self):
|
||||
self.log.WriteText("wx.Printout.OnBeginPrinting\n")
|
||||
self.base_OnBeginPrinting()
|
||||
self.log.WriteText("MyPrintout.OnBeginPrinting\n")
|
||||
super(MyPrintout, self).OnBeginPrinting()
|
||||
|
||||
def OnEndPrinting(self):
|
||||
self.log.WriteText("wx.Printout.OnEndPrinting\n")
|
||||
self.base_OnEndPrinting()
|
||||
self.log.WriteText("MyPrintout.OnEndPrinting\n")
|
||||
super(MyPrintout, self).OnEndPrinting()
|
||||
|
||||
def OnPreparePrinting(self):
|
||||
self.log.WriteText("wx.Printout.OnPreparePrinting\n")
|
||||
self.base_OnPreparePrinting()
|
||||
self.log.WriteText("MyPrintout.OnPreparePrinting\n")
|
||||
super(MyPrintout, self).OnPreparePrinting()
|
||||
|
||||
def HasPage(self, page):
|
||||
self.log.WriteText("wx.Printout.HasPage: %d\n" % page)
|
||||
self.log.WriteText("MyPrintout.HasPage: %d\n" % page)
|
||||
if page <= 2:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def GetPageInfo(self):
|
||||
self.log.WriteText("wx.Printout.GetPageInfo\n")
|
||||
self.log.WriteText("MyPrintout.GetPageInfo\n")
|
||||
return (1, 2, 1, 2)
|
||||
|
||||
def OnPrintPage(self, page):
|
||||
self.log.WriteText("wx.Printout.OnPrintPage: %d\n" % page)
|
||||
self.log.WriteText("MyPrintout.OnPrintPage: %d\n" % page)
|
||||
dc = self.GetDC()
|
||||
|
||||
#-------------------------------------------
|
||||
@@ -128,7 +128,7 @@ class TestPrintPanel(wx.Panel):
|
||||
def OnPrintSetup(self, event):
|
||||
data = wx.PrintDialogData(self.printData)
|
||||
printerDialog = wx.PrintDialog(self, data)
|
||||
printerDialog.GetPrintDialogData().SetSetupDialog(True)
|
||||
#printerDialog.GetPrintDialogData().SetSetupDialog(True)
|
||||
printerDialog.ShowModal();
|
||||
|
||||
# this makes a copy of the wx.PrintData instead of just saving
|
||||
|
Reference in New Issue
Block a user