* Update version number

* Since they are almost always needed for window classes, move the calls to
  removeVirtuals and addWindowVirtuals into the fixWindowClass and
  fixTopLevelWindowClass functions.

* Add wxWithImages to the interface headers and create wrappers for it and use
  it as a base of wxBoockCtrlBase.

* Add a new wx.deprecated() function that can handle properties and classes in
  addition to callables. It issues a custom warning, wxPyDeprecationWarning
  since the stock DeprecationWarning is filtered out by default in Python 2.7.

* Deprecate PyWindow and similar aliases

* Deprecate wx.Window.SetDimensions


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69050 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2011-09-11 00:33:10 +00:00
parent 60d9ea15f6
commit d949d1dad1
35 changed files with 376 additions and 143 deletions

View File

@@ -18,7 +18,7 @@ For all new etg files
will help to find the interface header source to compare what is
being declared there with what is being generated and to better
understand what may need tweaked in the etg script file.
* Check for extras added to the class in Classic wxPython and
* Check for any extras added to the class in Classic wxPython and
evaluate whether the same extras should be added to the Phoenix
verison.
* Check for backwards compatibility issues with Classic wxPython
@@ -77,24 +77,6 @@ build.py
commands.
etg/gdicmn.py
-------------
* I've never liked the x,y properties on a wxSize...
wx interface files
-------------------
* commit my layout.h on the trunk
* also Kevin's interface files patch
etg/window.py
-------------
* Do we really want to keep the SetDimensions alias when we have a
working overload of SetSize?
* Keep the PyWindow alias? Just deprecate it? Discuss on
wxPython-dev. Do the same for PyPanel, PySizer, PyControl, etc.
etg/pen.py
----------
@@ -111,4 +93,83 @@ etg/menu.py
* Figure out what to do about the MSW-only methods in wxMenuItem
wxProgressDialog
----------------
* Add wxGenericProgressDialog.
* and wxProgressDialog inherits from the generic version
Deprecated C++ items
---------------------
* Does Doxygen have a standard way to mark items as deprecated
that will also be tagged as such in the XML?
custom wrapper code
-------------------
Currently function.setCppCode requires some sip-isms (using sipRes and
sipCpp for example) to be able to replace the wrapper code used to
wrap the C++ function. Try making it work more like addCppMethod
where it will generate a new function that is passed "self" and that
you can simply return a value from.
Namespace Diff Tool
-------------------
I think that this will be more than just a diff tool, but for now that
is the only name that comes to mind. The general idea is that the
tool can be used to help us discover differences between different
versions of wxPython, such as Classic vs. Phoenix, or even between
different iterations of Phoenix. The tool would be used to help us
identify what is missing and still needs to be implemented, or what is
new, etc. The granularity would be items at the module level, and
items within each class, such as methods and properties. I don't
think it would be worth the effort to compare things like function
signatures or docstrings because the effor to do that may be large.
But maybe it could record whether a docstring is present to help us
track down items that need them added.
Here is a basic workflow and any other ideas that come up along the
way:
* Since the tool will be dealing with multiple versions of wxPython
(although nothing should prevent this from being used for other
packages as well), including historical versions, then the tool
will not be able to do a live introspection and compare. Instead
it should be able to do an introspection and source analysys of a
specified package and record the results in a database or perhaps
an XML file. The things it should be able to record are the
package/module names, the names and perhaps the types of all top
level items in a module, the names of all items in each class,
whether modules, classes, methods, functions have docstrings, etc.
* The scan and analisys should recursively descend to include all
modules within the specified package. Any imports of packages or
modules located outside of the target package can be ignored.
* When the scan is finished all the data can be saved usign a
specified name. (The name can be used to name the XML file, or be
used to collate all data related to this scan in a sqlite database
if that is what is used to save the data.)
* The tool should be able to be used to answer questions about the
data for a single scan like:
* number of classes
* list of all class names
* list of methods in class Foo
* count or list of items starting with "EVT_*"
* list of items without docstrings that should have one
* etc.
* Once there are more than one scan saved then the diff tool can be
used to highlight differences between them, such as the classes in
scan A that are not in scan B. The methods that are in the Foo
class in scan A that are not in the Foo class in scan B. Etc.
* Since it is expected that some things will be missing on purpose
there should be an easy way to tell the tool that when comparing
scan A and scan B, or perhaps when comparing scan A with any
subsequent scan, that it should ignore the fact that item X is
missing and not report it.
*

View File

@@ -13,6 +13,6 @@
VER_MAJOR = 2 # The first three must match wxWidgets
VER_MINOR = 9
VER_RELEASE = 2
VER_RELEASE = 3
VER_SUBREL = 80 # wxPython release num for x.y.z release of wxWidgets
VER_FLAGS = "" # release flags, such as prerelease or RC num, etc.

View File

@@ -33,6 +33,7 @@ INCLUDES = [ 'defs',
'string',
'arrays',
'clntdata',
'userdata',
'windowid',
'platinfo',
'display',
@@ -55,7 +56,7 @@ INCLUDES = [ 'defs',
'dcmemory',
'dcbuffer',
'dcscreen',
#'dcgraph', # TODO: needs wxGaphicsContext
#'dcgraph', # TODO: needs wxGraphicsContext
'dcmirror',
#'dcprint', # TODO: needs wxPrintData
#'dcps', # TODO: needs wxPrintData
@@ -77,10 +78,11 @@ INCLUDES = [ 'defs',
'apptrait',
'app',
'window',
'validate',
'panel',
'menu',
'window',
'menuitem',
'toplevel',
'dialog',
'frame',
@@ -91,6 +93,7 @@ INCLUDES = [ 'defs',
'choice',
'button',
'bmpbuttn',
'withimage',
'bookctrl',
'notebook',
'imagelist',
@@ -101,8 +104,8 @@ INCLUDES = [ 'defs',
'snglinst',
'accel',
'cursor',
'userdata',
'log',
'progdlg',
]

View File

@@ -92,9 +92,6 @@ def run():
item.name = '~wxPyApp'
c.find('ProcessMessage').ignore()
# The deprecation macros unfortunately get used as the method name.
# Until we fix this in the extraction code, just ignore any method marked this way.
c.find('wxDEPRECATED_BUT_USED_INTERNALLY').ignore()
c.addCppMethod('void', 'MacHideApp', '()',
doc="Hide all application windows just as the user can do with the\nsystem Hide command. Mac only.",

View File

@@ -35,8 +35,6 @@ def run():
c.find('Create.bitmap').default = 'wxNullBitmap'
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#-----------------------------------------------------------------

View File

@@ -33,7 +33,6 @@ def run():
# customizing the generated code and docstrings.
c = module.find('wxBookCtrlBase')
c.bases.append('wxWithImages')
assert isinstance(c, etgtools.ClassDef)
c.abstract = True

View File

@@ -32,8 +32,6 @@ def run():
c = module.find('wxButton')
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -40,9 +40,6 @@ def run():
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.addGetterSetterProps(module)

View File

@@ -40,10 +40,8 @@ def run():
c = module.find('wxCollapsiblePane')
c.find('wxCollapsiblePane.label').default = 'wxEmptyString'
c.find('Create.label').default = 'wxEmptyString'
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
tools.fixWindowClass(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -34,10 +34,8 @@ def run():
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
module.addPyCode("PyControl = Control")
module.addPyCode("PyControl = wx.deprecated(Control)")
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -50,6 +50,7 @@ def run():
module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxUChar'))
module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxChar'))
module.insertItemAfter(td, etgtools.TypedefDef(type='unsigned int', name='size_t'))
module.insertItemAfter(td, etgtools.TypedefDef(type='long', name='time_t'))
# Forward declarations for classes that are referenced but not defined

View File

@@ -20,7 +20,6 @@ DOCSTRING = ""
ITEMS = [
'wxDialog',
'wxDialogLayoutAdapter',
'wxProgressDialog',
]
#---------------------------------------------------------------------------
@@ -34,11 +33,8 @@ def run():
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
module.addHeaderCode("#include <wx/progdlg.h>")
c = module.find('wxDialog')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)
c.find('wxDialog.title').default = 'wxEmptyString'
c.find('Create.title').default = 'wxEmptyString'
@@ -56,12 +52,7 @@ def run():
# TODO: Restore when wxArrayInt is working
c.find('GetMainButtonIds').ignore()
c = module.find('wxProgressDialog')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
tools.fixTopLevelWindowClass(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -32,7 +32,6 @@ def run():
c = module.find('wxFrame')
assert isinstance(c, etgtools.ClassDef)
tools.fixTopLevelWindowClass(c)
c.find('wxFrame.title').default = 'wxEmptyString'
c.find('Create.title').default = 'wxEmptyString'
@@ -46,13 +45,11 @@ def run():
c.addProperty('ToolBar GetToolBar SetToolBar')
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
# TODO: should these go into a tools.addFrameVirtuals function?
c.find('OnCreateStatusBar').isVirtual = True
c.find('OnCreateToolBar').isVirtual = True
tools.fixTopLevelWindowClass(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -134,6 +134,8 @@ def run():
c.addProperty("width GetWidth SetWidth")
c.addProperty("height GetHeight SetHeight")
# TODO: How prevalent is the use of x,y properties on a size object? Can we deprecate them?
c.addProperty("x GetWidth SetWidth")
c.addProperty("y GetHeight SetHeight")

View File

@@ -17,7 +17,7 @@ DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxImage', 'wxImageHistogram', 'wxWithImages' ]
ITEMS = [ 'wxImage', 'wxImageHistogram' ]
#---------------------------------------------------------------------------
@@ -43,9 +43,6 @@ def run():
f.find('g').out = True
f.find('b').out = True
c = module.find('wxWithImages')
c.addPrivateCopyCtor()
c.addPrivateAssignOp()
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -30,7 +30,6 @@ ITEMS = [
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
module.items.append(etgtools.TypedefDef(type='long', name='time_t'))
etgtools.parseDoxyXML(module, ITEMS)
# do not use the va_list forms of the functions

View File

@@ -17,7 +17,7 @@ DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxMenu', 'wxMenuBar', 'wxMenuItem' ]
ITEMS = [ 'wxMenu', 'wxMenuBar' ]
#---------------------------------------------------------------------------
@@ -31,30 +31,16 @@ def run():
# customizing the generated code and docstrings.
c = module.find('wxMenu')
c.find('GetMenuItems').ignore()
assert isinstance(c, etgtools.ClassDef)
c.find('GetMenuItems').overloads[0].ignore()
tools.removeVirtuals(c)
c = module.find('wxMenuBar')
assert isinstance(c, etgtools.ClassDef)
c.find('wxMenuBar').findOverload('(size_t n, wxMenu *menus[], const wxString titles[], long style=0)').ignore()
c.find('FindItem').ignore()
assert isinstance(c, etgtools.ClassDef)
c.find('FindItem.menu').out = True
tools.removeVirtuals(c)
c = module.find('wxMenuItem')
c.addPrivateCopyCtor()
c.find('GetBackgroundColour').ignore()
c.find('SetBackgroundColour').ignore()
c.find('GetBitmap').ignore()
c.find('SetBitmap').ignore()
c.find('SetBitmaps').ignore()
c.find('GetFont').ignore()
c.find('SetFont').ignore()
c.find('GetMarginWidth').ignore()
c.find('SetMarginWidth').ignore()
c.find('GetTextColour').ignore()
c.find('SetTextColour').ignore()
assert isinstance(c, etgtools.ClassDef)
module.addItem(tools.wxListWrapperTemplate('wxMenuItemList', 'wxMenuItem'))
module.addItem(tools.wxListWrapperTemplate('wxMenuList', 'wxMenu'))
#-----------------------------------------------------------------

61
etg/menuitem.py Normal file
View File

@@ -0,0 +1,61 @@
#---------------------------------------------------------------------------
# Name: etg/menuitem.py
# Author: Robin Dunn
#
# Created: 10-Sept-2011
# Copyright: (c) 2011 by Total Control Software
# License: wxWindows License
#---------------------------------------------------------------------------
import etgtools
import etgtools.tweaker_tools as tools
PACKAGE = "wx"
MODULE = "_core"
NAME = "menuitem" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxMenuItem' ]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
c = module.find('wxMenuItem')
assert isinstance(c, etgtools.ClassDef)
c.addPrivateCopyCtor()
c.find('GetBackgroundColour').ignore()
c.find('SetBackgroundColour').ignore()
c.find('GetBitmap').ignore()
c.find('SetBitmap').ignore()
c.find('SetBitmaps').ignore()
c.find('GetFont').ignore()
c.find('SetFont').ignore()
c.find('GetMarginWidth').ignore()
c.find('SetMarginWidth').ignore()
c.find('GetTextColour').ignore()
c.find('SetTextColour').ignore()
module.addItem(tools.wxListWrapperTemplate('wxMenuItemList', 'wxMenuItem'))
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

View File

@@ -36,8 +36,6 @@ def run():
#c.addGetterSetterProps()
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -32,14 +32,10 @@ def run():
c = module.find('wxPanel')
assert isinstance(c, etgtools.ClassDef)
c.find('OnSysColourChanged').ignore()
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
module.addPyCode("PyPanel = Panel")
module.addPyCode("PyPanel = wx.deprecated(Panel)")
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

49
etg/progdlg.py Normal file
View File

@@ -0,0 +1,49 @@
#---------------------------------------------------------------------------
# Name: etg/progdlg
# Author: Robin Dunn
#
# Created: 9-Sept-2011
# Copyright: (c) 2011 by Total Control Software
# License: wxWindows License
#---------------------------------------------------------------------------
import etgtools
import etgtools.tweaker_tools as tools
PACKAGE = "wx"
MODULE = "_core"
NAME = "progdlg" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxProgressDialog' ]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
module.addHeaderCode("#include <wx/progdlg.h>")
c = module.find('wxProgressDialog')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c, False)
tools.removeVirtuals(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

View File

@@ -62,7 +62,7 @@ def run():
c.addPrivateCopyCtor()
c.addPrivateAssignOp()
module.addPyCode("PySizer = Sizer")
module.addPyCode("PySizer = wx.deprecated(Sizer)")
module.addItem(tools.wxListWrapperTemplate('wxSizerItemList', 'wxSizerItem'))
#-----------------------------------------------------------------

View File

@@ -37,9 +37,6 @@ def run():
c = module.find('wxSplitterWindow')
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.addGetterSetterProps(module)

View File

@@ -36,9 +36,6 @@ def run():
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.addGetterSetterProps(module)

View File

@@ -33,9 +33,6 @@ def run():
c = module.find('wxStaticLine')
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.addGetterSetterProps(module)

View File

@@ -35,9 +35,6 @@ def run():
c.find('Create.label').default = 'wxEmptyString'
tools.fixWindowClass(c)
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.addGetterSetterProps(module)

View File

@@ -32,7 +32,6 @@ def run():
c = module.find('wxTopLevelWindow')
assert isinstance(c, etgtools.ClassDef)
tools.fixTopLevelWindowClass(c)
c.find('wxTopLevelWindow.title').default = 'wxEmptyString'
c.find('Create.title').default = 'wxEmptyString'
@@ -74,9 +73,7 @@ def run():
c.addProperty('TmpDefaultItem GetTmpDefaultItem SetTmpDefaultItem')
c.addProperty('OSXModified OSXIsModified OSXSetModified')
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
tools.fixTopLevelWindowClass(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -58,8 +58,6 @@ def run():
# We now return you to our regularly scheduled programming...
tools.fixWindowClass(c)
c.includeCppCode('src/window_ex.cpp')
# ignore some overloads that will be ambiguous afer wrapping
@@ -111,6 +109,7 @@ def run():
c.addCppMethod('void', 'SetDimensions', '(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO)', """\
self->SetSize(x, y, width, height, sizeFlags);
""")
c.addPyCode("Window.SetDimensions = wx.deprecated(Window.SetDimensions)")
# Make the Register/UnregisterHotKey functions be available on Windows,
# and empty stubs otherwise
@@ -223,13 +222,7 @@ def run():
c.addProperty('MaxClientSize GetMaxClientSize SetMaxClientSize')
##c.addProperty('GtkWidget GetGtkWidget')
# We probably won't ever need most of the wxWindow virtuals to be
# overridable in Python, so we'll clear all the virtual flags here and add
# back those that we want to keep in the next step.
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
tools.fixWindowClass(c)
#-----------------------------------------------------------------------
# Other stuff
@@ -255,11 +248,11 @@ def run():
# makes wxWindowList quack like a read-only Python sequence.
module.addItem(tools.wxListWrapperTemplate('wxWindowList', 'wxWindow'))
module.addCppFunction('wxWindowList*', 'GetTopLevelWindows', '()',
briefDoc="Returns a list-like object of the the application's top-level windows, (frames,dialogs, etc.)",
body="return &wxTopLevelWindows;")
module.addPyCode("PyWindow = Window")
module.addPyCode("PyWindow = wx.deprecated(Window)")
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

48
etg/withimage.py Normal file
View File

@@ -0,0 +1,48 @@
#---------------------------------------------------------------------------
# Name: etg/withimage.py
# Author: Robin Dunn
#
# Created: 9-Sept-2011
# Copyright: (c) 2011 by Wide Open Technologies
# License: wxWindows License
#---------------------------------------------------------------------------
import etgtools
import etgtools.tweaker_tools as tools
PACKAGE = "wx"
MODULE = "_core"
NAME = "withimage" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxWithImages' ]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
c = module.find('wxWithImages')
c.addPrivateCopyCtor()
c.addPrivateAssignOp()
c.find('AssignImageList.imageList').transfer = True
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.addGetterSetterProps(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

View File

@@ -17,8 +17,6 @@ import os
import pprint
import xml.etree.ElementTree as et
#---------------------------------------------------------------------------
# These classes simply hold various bits of information about the classes,
# methods, functions and other items in the C/C++ API being wrapped.

View File

@@ -97,7 +97,7 @@ def fixEventClass(klass):
klass.addPrivateAssignOp()
def fixWindowClass(klass):
def fixWindowClass(klass, hideVirtuals=True):
"""
Do common tweaks for a window class.
"""
@@ -106,7 +106,6 @@ def fixWindowClass(klass):
if isinstance(func, extractors.MethodDef):
func.find('parent').transferThis = True
# give the id param a default value if it has one
# some classes like wxProgressDialog don't
id = func.findItem('id')
if id:
id.default = 'wxID_ANY'
@@ -119,18 +118,37 @@ def fixWindowClass(klass):
if p and not p.default:
p.default = 'wxDefaultSize'
if hideVirtuals:
# There is no need to make all the C++ virtuals overridable in Python, and
# hiding the fact that they are virtual from the back end generator will
# greatly reduce the amount of code that needs to be generated. Remove all
# the virtual flags, and then and then add it back to a select few.
removeVirtuals(klass)
addWindowVirtuals(klass)
def fixTopLevelWindowClass(klass):
def fixTopLevelWindowClass(klass, hideVirtuals=True):
"""
Tweaks for TLWs
"""
# TLW tweaks are a little different. We use the function annotation for
# TransferThis instead of the argument anotation.
klass.find(klass.name).findOverload('parent').transfer = True
klass.find('Create').transferThis = True
item = klass.findItem('Create')
if item:
item.transferThis = True
# give the id param a default value
klass.find('%s.id' % klass.name).default = 'wxID_ANY'
klass.find('Create.id').default = 'wxID_ANY'
item = klass.findItem('%s.id' % klass.name)
if item:
item.default = 'wxID_ANY'
item = klass.findItem('Create.id')
if item:
item.default = 'wxID_ANY'
if hideVirtuals:
removeVirtuals(klass)
addWindowVirtuals(klass)
def removeVirtuals(klass):
@@ -217,6 +235,7 @@ def addWindowVirtuals(klass):
klass.addItem(extractors.WigCode(txt))
txt = _processItems(klass, 'protected:\n', protectedWindowVirtuals)
klass.addItem(extractors.WigCode(txt))
klass.addPublic()

View File

@@ -1,7 +1,16 @@
import wx
print wx.version()
app = wx.PySimpleApp() # Should see a deprecation warning here
class TestPanel(wx.PyPanel):
def __init__(self, *args, **kw):
wx.PyPanel.__init__(self, *args, **kw) # You should see a deprecation warning here
self.BackgroundColour = "#66CDAA"
app = wx.PySimpleApp() # You should see a deprecation warning here
frm = wx.Frame(None)
pnl = TestPanel(frm)
frm.Show()
app.MainLoop()

View File

@@ -29,6 +29,7 @@ public:
#ifndef __WXMAC__
virtual void MacNewFile() {}
virtual void MacOpenFile(const wxString &) {}
virtual void MacOpenFiles(const wxArrayString& fileNames) {}
virtual void MacOpenURL(const wxString &) {}
virtual void MacPrintFile(const wxString &) {}
virtual void MacReopenApp() {}

View File

@@ -239,7 +239,7 @@ logged in on the main display of your Mac."""
#----------------------------------------------------------------------------
@deprecated
@wx.deprecated
class PySimpleApp(App):
"""
This class is deprecated. Please use wx.App instead.

View File

@@ -35,17 +35,71 @@ def version():
port = '???'
return "%s %s (phoenix)" % (wx.VERSION_STRING, port)
import warnings
class wxPyDeprecationWarning(DeprecationWarning):
pass
warnings.simplefilter('default', wxPyDeprecationWarning)
del warnings
def deprecated(func):
def new_func(*args, **kwargs):
def deprecated(item, msg=''):
"""
Create a delegating wrapper that raises a deprecation warning. Can be
used with callable objects (functions, methods, classes) or with
properties.
"""
import warnings
warnings.warn("Call to deprecated item %s." % func.__name__,
DeprecationWarning, stacklevel=2)
return func(*args, **kwargs)
new_func.__name__ = func.__name__
new_func.__doc__ = func.__doc__
new_func.__dict__.update(func.__dict__)
return new_func
if isinstance(item, type):
# It's a class. Make a subclass that raises a warning.
class DeprecatedClassProxy(item):
def __init__(*args, **kw):
warnings.warn("Using deprecated class. %s" % msg,
wxPyDeprecationWarning, stacklevel=2)
item.__init__(*args, **kw)
DeprecatedClassProxy.__name__ = item.__name__
DeprecatedClassProxy.__doc__ = item.__doc__
return DeprecatedClassProxy
elif callable(item):
# wrap a new function around the callable
def deprecated_func(*args, **kw):
warnings.warn("Call to deprecated item '%s'. %s" % (item.__name__, msg),
wxPyDeprecationWarning, stacklevel=2)
return item(*args, **kw)
deprecated_func.__name__ = item.__name__
deprecated_func.__doc__ = item.__doc__
if hasattr(item, '__dict__'):
deprecated_func.__dict__.update(item.__dict__)
return deprecated_func
elif hasattr(item, '__get__'):
# it should be a property if there is a getter
class DepGetProp(object):
def __init__(self,item, msg):
self.item = item
self.msg = msg
def __get__(self, inst, klass):
warnings.warn("Accessing deprecated property. %s" % msg,
wxPyDeprecationWarning, stacklevel=2)
return self.item.__get__(inst, klass)
class DepGetSetProp(DepGetProp):
def __set__(self, inst, val):
warnings.warn("Accessing deprecated property. %s" % msg,
wxPyDeprecationWarning, stacklevel=2)
return self.item.__set__(inst, val)
class DepGetSetDelProp(DepGetSetProp):
def __delete__(self, inst):
warnings.warn("Accessing deprecated property. %s" % msg,
wxPyDeprecationWarning, stacklevel=2)
return self.item.__delete__(inst)
if hasattr(item, '__set__') and hasattr(item, '__delete__'):
return DepGetSetDelProp(item, msg)
elif hasattr(item, '__set__'):
return DepGetSetProp(item, msg)
else:
return DepGetProp(item, msg)
else:
raise TypeError, "unsupported type %s" % type(item)