From 10b92e1ff95c1e655ec4f8e140edb3a14ee2973c Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 6 Mar 2013 19:56:16 +0000 Subject: [PATCH] add Preference classes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/_core.py | 1 + etg/preferences.py | 52 +++++++++++++++++++++++++++++++++++ unittests/test_preferences.py | 41 +++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 etg/preferences.py create mode 100644 unittests/test_preferences.py diff --git a/etg/_core.py b/etg/_core.py index 0b2c8093..6955c2a5 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -219,6 +219,7 @@ INCLUDES = [ # base and core stuff 'filehistory', 'cmdproc', 'fswatcher', + 'preferences', ] diff --git a/etg/preferences.py b/etg/preferences.py new file mode 100644 index 00000000..0b4bf5a5 --- /dev/null +++ b/etg/preferences.py @@ -0,0 +1,52 @@ +#--------------------------------------------------------------------------- +# Name: etg/preferences.py +# Author: Robin Dunn +# +# Created: 28-Feb-2013 +# Copyright: (c) 2013 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_core" +NAME = "preferences" # 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 = [ "wxPreferencesEditor", + "wxPreferencesPage", + "wxStockPreferencesPage", + ] + +#--------------------------------------------------------------------------- + +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('wxPreferencesEditor') + assert isinstance(c, etgtools.ClassDef) + c.addPrivateCopyCtor() + c.find('AddPage.page').transfer = True + + c = module.find('wxPreferencesPage') + c.addPrivateCopyCtor() + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/test_preferences.py b/unittests/test_preferences.py new file mode 100644 index 00000000..d2a90cf8 --- /dev/null +++ b/unittests/test_preferences.py @@ -0,0 +1,41 @@ +import imp_unittest, unittest +import wtc +import wx + +#--------------------------------------------------------------------------- + +class preferences_Tests(wtc.WidgetTestCase): + + def test_preferences1(self): + + class MyPrefsPanel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + cb1 = wx.CheckBox(self, -1, "Option 1") + cb2 = wx.CheckBox(self, -1, "Option 2") + box = wx.BoxSizer(wx.VERTICAL) + box.Add(cb1, 0, wx.ALL, 5) + box.Add(cb2, 0, wx.ALL, 5) + self.Sizer = wx.BoxSizer() + self.Sizer.Add(box, 0, wx.ALL, 10) + + class MyPrefsPage(wx.PreferencesPage): + def GetName(self): + return 'MyPrefsPage' + def GetLargeIcon(self): + return wx.ArtProvider.GetBitmap(wx.ART_HELP, wx.ART_TOOLBAR, (32,32)) + def CreateWindow(self, parent): + return MyPrefsPanel(parent) + + prefEd = wx.PreferencesEditor() + page1 = MyPrefsPage() + page2 = MyPrefsPage() + prefEd.AddPage(page1) + prefEd.AddPage(page2) + prefEd.Show(self.frame) + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()