From d398ada0427bf36ed0cdfaab7e07464a54be26e9 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 17 Apr 2012 17:01:23 +0000 Subject: [PATCH] Add TipProvider and helpers to wx.adv git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/_adv.py | 2 +- etg/tipdlg.py | 45 ++++++++++++++++++++++++++++++++++++++++ unittests/test_tipdlg.py | 38 +++++++++++++++++++++++++++++++++ unittests/tips.txt | 1 + 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 etg/tipdlg.py create mode 100644 unittests/test_tipdlg.py create mode 100644 unittests/tips.txt diff --git a/etg/_adv.py b/etg/_adv.py index 5cacd861..328e25a8 100644 --- a/etg/_adv.py +++ b/etg/_adv.py @@ -32,6 +32,7 @@ INCLUDES = [ 'datectrl', 'calctrl', 'hyperlink', + 'tipdlg', # TODOs - @@ -51,7 +52,6 @@ INCLUDES = [ #'splash', #'taskbar', #'timectrl', - #'tipdlg', #'treelist', #'wizard', diff --git a/etg/tipdlg.py b/etg/tipdlg.py new file mode 100644 index 00000000..1272ca3e --- /dev/null +++ b/etg/tipdlg.py @@ -0,0 +1,45 @@ +#--------------------------------------------------------------------------- +# Name: etg/tipdlg.py +# Author: Robin Dunn +# +# Created: 12-Apr-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_adv" +NAME = "tipdlg" # 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 = [ "wxTipProvider", + ] + +#--------------------------------------------------------------------------- + +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 ') + module.find('wxCreateFileTipProvider').factory = True + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/test_tipdlg.py b/unittests/test_tipdlg.py new file mode 100644 index 00000000..c86b6bac --- /dev/null +++ b/unittests/test_tipdlg.py @@ -0,0 +1,38 @@ +import imp_unittest, unittest +import wtc +import wx +import wx.adv +import os + +tipFile = os.path.join(os.path.dirname(__file__), 'tips.txt') + +#--------------------------------------------------------------------------- + +class tipdlg_Tests(wtc.WidgetTestCase): + + def test_tipdlg1(self): + tp = wx.adv.CreateFileTipProvider(tipFile, 0); + wx.CallLater(25, self._closeTipDialog) + wx.adv.ShowTip(self.frame, tp) + + + def test_tipdlg2(self): + class MyTipProvider(wx.adv.TipProvider): + def GetTip(self): + return "This is my tip" + + wx.CallLater(25, self._closeTipDialog) + wx.adv.ShowTip(self.frame, MyTipProvider(0)) + + + def _closeTipDialog(self): + #self.myYield() + for w in wx.GetTopLevelWindows(): + if isinstance(w, wx.Dialog): + w.EndModal(wx.ID_CANCEL) + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main() diff --git a/unittests/tips.txt b/unittests/tips.txt new file mode 100644 index 00000000..d49df8f5 --- /dev/null +++ b/unittests/tips.txt @@ -0,0 +1 @@ +Here is a tip from a text file. See test_tipdlg.py