diff --git a/TODO.txt b/TODO.txt index 3883c9b8..6129da8e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -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. + + * diff --git a/buildtools/version.py b/buildtools/version.py index f99a371b..2fdea93e 100644 --- a/buildtools/version.py +++ b/buildtools/version.py @@ -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. diff --git a/etg/_core.py b/etg/_core.py index 9df83f87..affefad7 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -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', ] diff --git a/etg/app.py b/etg/app.py index ca869f08..dd1bbd19 100644 --- a/etg/app.py +++ b/etg/app.py @@ -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.", diff --git a/etg/bmpbuttn.py b/etg/bmpbuttn.py index 5dfab422..1badaeb6 100644 --- a/etg/bmpbuttn.py +++ b/etg/bmpbuttn.py @@ -35,8 +35,6 @@ def run(): c.find('Create.bitmap').default = 'wxNullBitmap' tools.fixWindowClass(c) - tools.removeVirtuals(c) - tools.addWindowVirtuals(c) #----------------------------------------------------------------- diff --git a/etg/bookctrl.py b/etg/bookctrl.py index d4c3e360..531abed5 100644 --- a/etg/bookctrl.py +++ b/etg/bookctrl.py @@ -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 diff --git a/etg/button.py b/etg/button.py index ae14cc79..2c10c482 100644 --- a/etg/button.py +++ b/etg/button.py @@ -32,8 +32,6 @@ def run(): c = module.find('wxButton') tools.fixWindowClass(c) - tools.removeVirtuals(c) - tools.addWindowVirtuals(c) #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/etg/choice.py b/etg/choice.py index e94cf929..6f78972b 100644 --- a/etg/choice.py +++ b/etg/choice.py @@ -40,9 +40,6 @@ def run(): tools.fixWindowClass(c) - tools.removeVirtuals(c) - tools.addWindowVirtuals(c) - #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.addGetterSetterProps(module) diff --git a/etg/collpane.py b/etg/collpane.py index f789ee5a..62bc732a 100644 --- a/etg/collpane.py +++ b/etg/collpane.py @@ -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) diff --git a/etg/control.py b/etg/control.py index 23f9db8c..81545964 100644 --- a/etg/control.py +++ b/etg/control.py @@ -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) diff --git a/etg/defs.py b/etg/defs.py index 5ebcec35..e2fac384 100644 --- a/etg/defs.py +++ b/etg/defs.py @@ -50,7 +50,8 @@ 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 # yet. diff --git a/etg/dialog.py b/etg/dialog.py index 8da074f0..ad398ab9 100644 --- a/etg/dialog.py +++ b/etg/dialog.py @@ -19,8 +19,7 @@ DOCSTRING = "" # this script. ITEMS = [ 'wxDialog', - 'wxDialogLayoutAdapter', - 'wxProgressDialog', + 'wxDialogLayoutAdapter', ] #--------------------------------------------------------------------------- @@ -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 ") - c = module.find('wxDialog') assert isinstance(c, etgtools.ClassDef) - tools.fixWindowClass(c) c.find('wxDialog.title').default = 'wxEmptyString' c.find('Create.title').default = 'wxEmptyString' @@ -55,13 +51,8 @@ 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) diff --git a/etg/frame.py b/etg/frame.py index f1152405..5d82f4c1 100644 --- a/etg/frame.py +++ b/etg/frame.py @@ -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) diff --git a/etg/gdicmn.py b/etg/gdicmn.py index 80d200c8..6a426987 100644 --- a/etg/gdicmn.py +++ b/etg/gdicmn.py @@ -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") diff --git a/etg/image.py b/etg/image.py index e0df38ce..41475a2b 100644 --- a/etg/image.py +++ b/etg/image.py @@ -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) diff --git a/etg/log.py b/etg/log.py index 4bf39a6c..e1907a5e 100644 --- a/etg/log.py +++ b/etg/log.py @@ -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 diff --git a/etg/menu.py b/etg/menu.py index 2026c3d8..e56f2511 100644 --- a/etg/menu.py +++ b/etg/menu.py @@ -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,32 +31,18 @@ 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')) - + #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.runGenerators(module) diff --git a/etg/menuitem.py b/etg/menuitem.py new file mode 100644 index 00000000..b6f51a9d --- /dev/null +++ b/etg/menuitem.py @@ -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() + diff --git a/etg/notebook.py b/etg/notebook.py index 76839c46..30d8aee7 100644 --- a/etg/notebook.py +++ b/etg/notebook.py @@ -36,8 +36,6 @@ def run(): #c.addGetterSetterProps() tools.fixWindowClass(c) - tools.removeVirtuals(c) - tools.addWindowVirtuals(c) #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/etg/panel.py b/etg/panel.py index 6611a7d5..5e6b864c 100644 --- a/etg/panel.py +++ b/etg/panel.py @@ -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") + tools.fixWindowClass(c) + + module.addPyCode("PyPanel = wx.deprecated(Panel)") #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/etg/progdlg.py b/etg/progdlg.py new file mode 100644 index 00000000..34fc94ee --- /dev/null +++ b/etg/progdlg.py @@ -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 ") + + 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() + diff --git a/etg/sizer.py b/etg/sizer.py index 6c39f798..6fbcf736 100644 --- a/etg/sizer.py +++ b/etg/sizer.py @@ -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')) #----------------------------------------------------------------- diff --git a/etg/splitter.py b/etg/splitter.py index 71faacbd..5230e169 100644 --- a/etg/splitter.py +++ b/etg/splitter.py @@ -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) diff --git a/etg/statbmp.py b/etg/statbmp.py index 64e36ad4..48e9f557 100644 --- a/etg/statbmp.py +++ b/etg/statbmp.py @@ -36,9 +36,6 @@ def run(): tools.fixWindowClass(c) - tools.removeVirtuals(c) - tools.addWindowVirtuals(c) - #----------------------------------------------------------------- tools.doCommonTweaks(module) tools.addGetterSetterProps(module) diff --git a/etg/statline.py b/etg/statline.py index 7df268bf..ee3d06ff 100644 --- a/etg/statline.py +++ b/etg/statline.py @@ -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) diff --git a/etg/stattext.py b/etg/stattext.py index 6056fe51..b2c73c3b 100644 --- a/etg/stattext.py +++ b/etg/stattext.py @@ -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) diff --git a/etg/toplevel.py b/etg/toplevel.py index 2002c178..1b448e0f 100644 --- a/etg/toplevel.py +++ b/etg/toplevel.py @@ -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) diff --git a/etg/window.py b/etg/window.py index e26391a1..6f76b8f7 100644 --- a/etg/window.py +++ b/etg/window.py @@ -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 @@ -254,12 +247,12 @@ def run(): # Add a wrapper for wxWindowList and a new iterator class for it that # 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) diff --git a/etg/withimage.py b/etg/withimage.py new file mode 100644 index 00000000..daf3f88a --- /dev/null +++ b/etg/withimage.py @@ -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() + diff --git a/etgtools/extractors.py b/etgtools/extractors.py index 506cf50e..a03daa0a 100644 --- a/etgtools/extractors.py +++ b/etgtools/extractors.py @@ -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. diff --git a/etgtools/tweaker_tools.py b/etgtools/tweaker_tools.py index 64155cf2..eaa4929b 100644 --- a/etgtools/tweaker_tools.py +++ b/etgtools/tweaker_tools.py @@ -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' @@ -118,20 +117,39 @@ def fixWindowClass(klass): p = func.findItem('size') 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() diff --git a/samples/simple/deprecated.py b/samples/simple/deprecated.py index 67063318..933d3c5d 100644 --- a/samples/simple/deprecated.py +++ b/samples/simple/deprecated.py @@ -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() diff --git a/src/app_ex.cpp b/src/app_ex.cpp index ef0d2311..1fac4901 100644 --- a/src/app_ex.cpp +++ b/src/app_ex.cpp @@ -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() {} diff --git a/src/app_ex.py b/src/app_ex.py index 9c721dbb..2ec8f283 100644 --- a/src/app_ex.py +++ b/src/app_ex.py @@ -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. diff --git a/src/core_ex.py b/src/core_ex.py index d91352c4..2a6f5327 100644 --- a/src/core_ex.py +++ b/src/core_ex.py @@ -35,18 +35,72 @@ 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): - 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 - +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 + 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) + ## #----------------------------------------------------------------------------