From cb545458a820c29cf589f2c021671f3d83823c8f Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 20 Jun 2012 17:10:29 +0000 Subject: [PATCH] * Add missing BookCtrl and Notebook constants and Notebook event binders. * Add a wx.BookCtrl and binder aliases (set to wx.Notebook) since it is mentioned in the notebook overview. * update unittests git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71812 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/bookctrl.py | 9 ++++++--- etg/notebook.py | 15 +++++++++++++++ unittests/test_bookctrl.py | 35 +++++++++++++++++++++++++++++++++++ unittests/test_notebook.py | 5 +++++ 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 unittests/test_bookctrl.py diff --git a/etg/bookctrl.py b/etg/bookctrl.py index 03ac22a7..8f779839 100644 --- a/etg/bookctrl.py +++ b/etg/bookctrl.py @@ -17,7 +17,8 @@ DOCSTRING = "" # The classes and/or the basename of the Doxygen XML files to be processed by # this script. -ITEMS = [ 'wxBookCtrlBase', +ITEMS = [ 'interface_2wx_2bookctrl_8h.xml', + 'wxBookCtrlBase', 'wxBookCtrlEvent', ] @@ -25,13 +26,15 @@ ITEMS = [ 'wxBookCtrlBase', def run(): # Parse the XML file(s) building a collection of Extractor objects - module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING, - check4unittest=False) + 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. + + # Ignore the macro. We'll add a Python alias in notebook.py instead. + module.find('wxBookCtrl').ignore() c = module.find('wxBookCtrlBase') assert isinstance(c, etgtools.ClassDef) diff --git a/etg/notebook.py b/etg/notebook.py index 9b73467a..07835e7d 100644 --- a/etg/notebook.py +++ b/etg/notebook.py @@ -38,6 +38,21 @@ def run(): tools.fixWindowClass(c) module.addGlobalStr('wxNotebookNameStr', c) + + module.addPyCode("""\ + EVT_NOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 1 ) + EVT_NOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 1 ) + """) + + module.addPyCode("""\ + # Aliases for the "best book" control as described in the overview + BookCtrl = Notebook + wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED = wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED + wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING = wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING + EVT_BOOKCTRL_PAGE_CHANGED = EVT_NOTEBOOK_PAGE_CHANGED + EVT_BOOKCTRL_PAGE_CHANGING = EVT_NOTEBOOK_PAGE_CHANGING + """) + #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/unittests/test_bookctrl.py b/unittests/test_bookctrl.py new file mode 100644 index 00000000..08fd3c07 --- /dev/null +++ b/unittests/test_bookctrl.py @@ -0,0 +1,35 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class panel_Tests(wtc.WidgetTestCase): + + def test_bookctrl1(self): + wx.BK_DEFAULT + wx.BK_TOP + wx.BK_BOTTOM + wx.BK_LEFT + wx.BK_RIGHT + wx.BK_HITTEST_NOWHERE + wx.BK_HITTEST_ONICON + wx.BK_HITTEST_ONLABEL + wx.BK_HITTEST_ONITEM + wx.BK_HITTEST_ONPAGE + + + def test_bookctrl2(self): + # These are actually aliases for wx.Notebook + wx.BookCtrl + wx.wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED + wx.wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING + wx.EVT_BOOKCTRL_PAGE_CHANGED + wx.EVT_BOOKCTRL_PAGE_CHANGING + + +#--------------------------------------------------------------------------- + + +if __name__ == '__main__': + unittest.main() diff --git a/unittests/test_notebook.py b/unittests/test_notebook.py index fc2e1f97..3c8b43e6 100644 --- a/unittests/test_notebook.py +++ b/unittests/test_notebook.py @@ -31,6 +31,11 @@ class notebook_Tests(wtc.WidgetTestCase): wx.NB_HITTEST_ONITEM wx.NB_HITTEST_ONPAGE + def test_notebookEventTypes(self): + wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED + wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING + wx.EVT_NOTEBOOK_PAGE_CHANGED + wx.EVT_NOTEBOOK_PAGE_CHANGING def test_notebookPages(self): nb = wx.Notebook(self.frame, style=wx.NB_BOTTOM)