From a41fd0304a43223c90d39d733880a7b3f0288246 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 7 Jun 2013 03:02:32 +0000 Subject: [PATCH] Add wx.ModalDialogHook git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@74117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/_core.py | 1 + etg/modalhook.py | 50 +++++++++++++++++++++++++++++++++++++ unittests/test_modalhook.py | 34 +++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 etg/modalhook.py create mode 100644 unittests/test_modalhook.py diff --git a/etg/_core.py b/etg/_core.py index 6955c2a5..ae102994 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -220,6 +220,7 @@ INCLUDES = [ # base and core stuff 'cmdproc', 'fswatcher', 'preferences', + 'modalhook', ] diff --git a/etg/modalhook.py b/etg/modalhook.py new file mode 100644 index 00000000..8411900e --- /dev/null +++ b/etg/modalhook.py @@ -0,0 +1,50 @@ +#--------------------------------------------------------------------------- +# Name: etg/modalhook.py +# Author: Robin Dunn +# +# Created: 06-Jun-2013 +# Copyright: (c) 2013 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "modalhook" # 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 = [ "wxModalDialogHook", + ] + +#--------------------------------------------------------------------------- + +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('wxModalDialogHook') + assert isinstance(c, etgtools.ClassDef) + c.addPrivateCopyCtor() + + c.find('Enter').ignore(False) + c.find('Exit').ignore(False) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/test_modalhook.py b/unittests/test_modalhook.py new file mode 100644 index 00000000..24c4d84b --- /dev/null +++ b/unittests/test_modalhook.py @@ -0,0 +1,34 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class modalhook_Tests(wtc.WidgetTestCase): + + def test_modalhook1(self): + class MyModalDialogHook(wx.ModalDialogHook): + def __init__(self): + wx.ModalDialogHook.__init__(self) + self.counter = 0 + + def Enter(self, dialog): + self.counter += 1 + return wx.ID_OK + + def Exit(self, dialog): + self.counter += 1 # not called because Enter didn't return wx.ID_NONE + + myHook = MyModalDialogHook() + myHook.Register() + + wx.MessageBox("This should be auto-dismissed...", style=wx.OK|wx.CANCEL) + self.assertEqual(myHook.counter, 1) + + myHook.Unregister() + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()