From efec3bcca5a2e6491c27490951ded20323869bd6 Mon Sep 17 00:00:00 2001 From: Metallicow Date: Mon, 19 Oct 2020 03:32:58 -0500 Subject: [PATCH 01/13] Reduce flicker in svg demos --- demo/SVGImage_Bitmap.py | 2 ++ demo/SVGImage_Render.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/demo/SVGImage_Bitmap.py b/demo/SVGImage_Bitmap.py index ef119b7a..5284291d 100644 --- a/demo/SVGImage_Bitmap.py +++ b/demo/SVGImage_Bitmap.py @@ -21,6 +21,8 @@ class SVGBitmapDisplay(wx.Panel): sbox = wx.StaticBoxSizer(wx.VERTICAL, self, label) sbox.Add(self.statbmp) self.SetSizer(sbox) + if not self.IsDoubleBuffered(): + self.SetDoubleBuffered(True) # Reduce flicker on size event. def UpdateSVG(self, svg_filename): diff --git a/demo/SVGImage_Render.py b/demo/SVGImage_Render.py index 7cafa55f..579eb5f2 100644 --- a/demo/SVGImage_Render.py +++ b/demo/SVGImage_Render.py @@ -33,7 +33,7 @@ class SVGRenderPanel(wx.Panel): def OnPaint(self, event): - dc = wx.PaintDC(self) + dc = wx.BufferedPaintDC(self) dc.Clear() iw, ih = (self._img.width, self._img.height) if self._img else (100,100) From 18ceaeadd7b53fe3306f27064310a79a9016bcff Mon Sep 17 00:00:00 2001 From: Metallicow Date: Mon, 19 Oct 2020 04:09:04 -0500 Subject: [PATCH 02/13] Reduce flicker of overlay, since throbber can be composed of svg bitmaps --- wx/lib/throbber.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wx/lib/throbber.py b/wx/lib/throbber.py index f74873f7..9954d6b2 100644 --- a/wx/lib/throbber.py +++ b/wx/lib/throbber.py @@ -214,7 +214,7 @@ class Throbber(wx.Panel): :param `event`: a :class:`PaintEvent` event to be processed. """ - self.Draw(wx.PaintDC(self)) + self.Draw(wx.BufferedPaintDC(self)) event.Skip() From 7a637d862d082adaa579e888a259fd6dcc50d8c3 Mon Sep 17 00:00:00 2001 From: Metallicow Date: Tue, 27 Oct 2020 18:58:20 -0500 Subject: [PATCH 03/13] Revert "Reduce flicker of overlay, since throbber can be composed of svg bitmaps" This reverts commit 18ceaeadd7b53fe3306f27064310a79a9016bcff. --- wx/lib/throbber.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wx/lib/throbber.py b/wx/lib/throbber.py index 9954d6b2..f74873f7 100644 --- a/wx/lib/throbber.py +++ b/wx/lib/throbber.py @@ -214,7 +214,7 @@ class Throbber(wx.Panel): :param `event`: a :class:`PaintEvent` event to be processed. """ - self.Draw(wx.BufferedPaintDC(self)) + self.Draw(wx.PaintDC(self)) event.Skip() From 8d4f8e733c2a36fae65b9a582fe6029ed16c702a Mon Sep 17 00:00:00 2001 From: Metallicow Date: Tue, 27 Oct 2020 19:03:10 -0500 Subject: [PATCH 04/13] Reduce flicker in throbber. Use BufferedPaintDC --- wx/lib/throbber.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wx/lib/throbber.py b/wx/lib/throbber.py index f74873f7..9954d6b2 100644 --- a/wx/lib/throbber.py +++ b/wx/lib/throbber.py @@ -214,7 +214,7 @@ class Throbber(wx.Panel): :param `event`: a :class:`PaintEvent` event to be processed. """ - self.Draw(wx.PaintDC(self)) + self.Draw(wx.BufferedPaintDC(self)) event.Skip() From c4f1e9f3bd99d20b1d1f032dac7760933e20adcc Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 10 Nov 2020 14:43:18 -0800 Subject: [PATCH 05/13] Add missing context manager methods for wx.LogNull --- etg/log.py | 6 ++++-- unittests/test_log.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/etg/log.py b/etg/log.py index d0a15627..2558bd5f 100644 --- a/etg/log.py +++ b/etg/log.py @@ -116,11 +116,13 @@ def run(): c.addPrivateCopyCtor() c.addPrivateAssignOp() - - c = module.find('wxLogFormatter') c.find('FormatTime').ignore(False) + c = module.find('wxLogNull') + c.addPyMethod('__enter__', '(self)', 'return self') + c.addPyMethod('__exit__', '(self, exc_type, exc_val, exc_tb)', 'return False') + #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/unittests/test_log.py b/unittests/test_log.py index 60591dcb..fc43254c 100644 --- a/unittests/test_log.py +++ b/unittests/test_log.py @@ -23,6 +23,12 @@ class log_Tests(wtc.WidgetTestCase): wx.LogMessage("This is a test") self.assertTrue(log.messageLogged) + + def test_lognull_is_context_mgr(self): + with wx.LogNull(): + pass + + #--------------------------------------------------------------------------- From a6e855c34e0d0dfab9914b6f65432263e7a2dadf Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 10 Nov 2020 14:46:15 -0800 Subject: [PATCH 06/13] Add changelog item --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e66dca07..a522b33e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -79,6 +79,8 @@ New and improved in this release: was done to workaround a bug in wxMac, but it seems worthwhile enough to keep it around even after the bug was fixed. +* Added the missing context manager methods for wx.LogNull. (#1842) + From e3dbe68b49e29317a24164a602732b0e9db9612d Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 11 Nov 2020 14:41:44 -0800 Subject: [PATCH 07/13] Allow passing iterator flags into GetPropertyValues --- etg/propgridiface.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/etg/propgridiface.py b/etg/propgridiface.py index 402b6ba6..4f020b21 100644 --- a/etg/propgridiface.py +++ b/etg/propgridiface.py @@ -215,18 +215,20 @@ def run(): c.find('GetPropertyValues').ignore() c.addPyMethod('GetPropertyValues', - '(self, dict_=None, as_strings=False, inc_attributes=False)', + '(self, dict_=None, as_strings=False, inc_attributes=False, flags=PG_ITERATE_PROPERTIES)', doc="""\ - Returns all property values in the grid.\n - :param `dict_`: A to fill with the property values. If not given, - then a new one is created. The dict_ can be an object as well, - in which case it's __dict__ is used. + Returns all property values in the grid. + + :param `dict_`: A diftionary to fill with the property values. + If not given, then a new one is created. The dict_ can be an + object as well, in which case it's __dict__ is used. :param `as_strings`: if True, then string representations of values are fetched instead of native types. Useful for config and such. :param `inc_attributes`: if True, then property attributes are added - in the form of "@@". + in the form of ``"@@"``. + :param `flags`: Flags to pass to the iterator, see :ref:`wx.propgrid.PG_ITERATOR_FLAGS` :returns: A dictionary with values. It is always a dictionary, - so if dict_ was and object with __dict__ attribute, then that + so if dict_ was an object with __dict__ attribute, then that attribute is returned. """, body="""\ @@ -237,7 +239,7 @@ def run(): getter = self.GetPropertyValue if not as_strings else self.GetPropertyValueAsString - it = self.GetVIterator(PG_ITERATE_PROPERTIES) + it = self.GetVIterator(flags) while not it.AtEnd(): p = it.GetProperty() name = p.GetName() @@ -314,7 +316,7 @@ def run(): self.Refresh() """) - # TODO: should these be marked as deprecated? + # TODO: should these be marked as deprecated? Probably... module.addPyCode("""\ PropertyGridInterface.GetValues = PropertyGridInterface.GetPropertyValues PropertyGridInterface.SetValues = PropertyGridInterface.SetPropertyValues From 7a839de24872c7feb95471aceafabcb49416e7a9 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 11 Nov 2020 15:40:05 -0800 Subject: [PATCH 08/13] Make it possible to call a function that post-processes the generated ReST doc for a class. --- etg/propgridiface.py | 10 +++++++++- etgtools/extractors.py | 6 ++++++ etgtools/sphinx_generator.py | 9 +++++++++ sphinxtools/utilities.py | 16 +++++++++++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/etg/propgridiface.py b/etg/propgridiface.py index 4f020b21..9425f84e 100644 --- a/etg/propgridiface.py +++ b/etg/propgridiface.py @@ -226,7 +226,7 @@ def run(): are fetched instead of native types. Useful for config and such. :param `inc_attributes`: if True, then property attributes are added in the form of ``"@@"``. - :param `flags`: Flags to pass to the iterator, see :ref:`wx.propgrid.PG_ITERATOR_FLAGS` + :param `flags`: Flags to pass to the iterator. See :ref:`wx.propgrid.PG_ITERATOR_FLAGS`. :returns: A dictionary with values. It is always a dictionary, so if dict_ was an object with __dict__ attribute, then that attribute is returned. @@ -505,6 +505,14 @@ def run(): c.addPyProperty('Items', '_Items') + def postProcessReST(text): + # fix some autodoc glitches + text = text.replace(':ref:`PropertyGridIterator Flags `', + ':ref:`wx.propgrid.PG_ITERATOR_FLAGS`') + return text + + c.setReSTPostProcessor(postProcessReST) + #---------------------------------------------------------- module.addItem( diff --git a/etgtools/extractors.py b/etgtools/extractors.py index 757ec61b..8c992cb1 100644 --- a/etgtools/extractors.py +++ b/etgtools/extractors.py @@ -684,6 +684,7 @@ class ClassDef(BaseDef): self.isInner = False # Is this a nested class? self.klass = None # if so, then this is the outer class self.preMethodCode = None + self.postProcessReST = None # Stuff that needs to be generated after the class instead of within # it. Some back-end generators need to put stuff inside the class, and @@ -1157,6 +1158,11 @@ private: self.addItem(item) return item + def setReSTPostProcessor(self, func): + """ + Set a function to be called after the class's docs have been generated. + """ + self.postProcessReST = func #--------------------------------------------------------------------------- diff --git a/etgtools/sphinx_generator.py b/etgtools/sphinx_generator.py index 1897ab25..8ecd2165 100644 --- a/etgtools/sphinx_generator.py +++ b/etgtools/sphinx_generator.py @@ -48,6 +48,7 @@ from sphinxtools.utilities import pickleClassInfo, pickleFunctionInfo, isNumeric from sphinxtools.utilities import underscore2Capitals, countSpaces from sphinxtools.utilities import formatContributedSnippets from sphinxtools.utilities import PickleFile +from sphinxtools.utilities import textfile_open from sphinxtools.constants import VERSION, REMOVED_LINKS, SECTIONS from sphinxtools.constants import MAGIC_METHODS, MODULENAME_REPLACE @@ -3230,6 +3231,14 @@ class SphinxGenerator(generators.DocsGeneratorBase): f = dispatch[item.__class__][0] f(item) + if klass.postProcessReST is not None: + full_name = os.path.join(SPHINXROOT, filename) + with textfile_open(full_name) as f: + text = f.read() + text = klass.postProcessReST(text) + with textfile_open(full_name, 'wt') as f: + f.write(text) + if klass.enum_list: stream = StringIO() stream.write("\n.. toctree::\n :maxdepth: 1\n :hidden:\n\n") diff --git a/sphinxtools/utilities.py b/sphinxtools/utilities.py index 6177a10a..662d5275 100644 --- a/sphinxtools/utilities.py +++ b/sphinxtools/utilities.py @@ -561,7 +561,7 @@ header = """\ This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. - Copyright: (c) 2011-2018 by Total Control Software + Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License """ @@ -861,3 +861,17 @@ def isPython3(): return sys.version_info >= (3, ) + +def textfile_open(filename, mode='rt'): + """ + Simple wrapper around open() that will use codecs.open on Python2 and + on Python3 will add the encoding parameter to the normal open(). The + mode parameter must include the 't' to put the stream into text mode. + """ + assert 't' in mode + if sys.version_info < (3,): + import codecs + mode = mode.replace('t', '') + return codecs.open(filename, mode, encoding='utf-8') + else: + return open(filename, mode, encoding='utf-8') From 35931985abb24824064f5bf6f342354fd8d56b24 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 11 Nov 2020 15:55:30 -0800 Subject: [PATCH 09/13] Update some copyright years --- samples/combo/combo1.py | 2 +- sphinxtools/constants.py | 2 +- sphinxtools/inheritance.py | 2 +- sphinxtools/postprocess.py | 2 +- sphinxtools/templates.py | 2 +- sphinxtools/utilities.py | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/combo/combo1.py b/samples/combo/combo1.py index 63493bbe..b47e84fd 100644 --- a/samples/combo/combo1.py +++ b/samples/combo/combo1.py @@ -3,7 +3,7 @@ # Author: Robin Dunn # # Created: 1-June-2012 -# Copyright: (c) 2012-2018 by Total Control Software +# Copyright: (c) 2012-2020 by Total Control Software # License: wxWindows License #--------------------------------------------------------------------------- diff --git a/sphinxtools/constants.py b/sphinxtools/constants.py index 364f79a6..68bc8477 100644 --- a/sphinxtools/constants.py +++ b/sphinxtools/constants.py @@ -5,7 +5,7 @@ # Author: Andrea Gavana # # Created: 30-Nov-2010 -# Copyright: (c) 2010-2018 by Total Control Software +# Copyright: (c) 2010-2020 by Total Control Software # License: wxWindows License #--------------------------------------------------------------------------- diff --git a/sphinxtools/inheritance.py b/sphinxtools/inheritance.py index 7a1793bf..acd7a803 100644 --- a/sphinxtools/inheritance.py +++ b/sphinxtools/inheritance.py @@ -5,7 +5,7 @@ # Author: Andrea Gavana # # Created: 30-Nov-2010 -# Copyright: (c) 2010-2018 by Total Control Software +# Copyright: (c) 2010-2020 by Total Control Software # License: wxWindows License #--------------------------------------------------------------------------- diff --git a/sphinxtools/postprocess.py b/sphinxtools/postprocess.py index 0c72ab97..9211b642 100644 --- a/sphinxtools/postprocess.py +++ b/sphinxtools/postprocess.py @@ -4,7 +4,7 @@ # Author: Andrea Gavana # # Created: 30-Nov-2010 -# Copyright: (c) 2010-2018 by Total Control Software +# Copyright: (c) 2010-2020 by Total Control Software # License: wxWindows License #--------------------------------------------------------------------------- diff --git a/sphinxtools/templates.py b/sphinxtools/templates.py index 90a2b199..03fbeee8 100644 --- a/sphinxtools/templates.py +++ b/sphinxtools/templates.py @@ -5,7 +5,7 @@ # Author: Andrea Gavana # # Created: 30-Nov-2010 -# Copyright: (c) 2010-2018 by Total Control Software +# Copyright: (c) 2010-2020 by Total Control Software # License: wxWindows License #--------------------------------------------------------------------------- diff --git a/sphinxtools/utilities.py b/sphinxtools/utilities.py index 6177a10a..a8757305 100644 --- a/sphinxtools/utilities.py +++ b/sphinxtools/utilities.py @@ -5,7 +5,7 @@ # Author: Andrea Gavana # # Created: 30-Nov-2010 -# Copyright: (c) 2010-2018 by Total Control Software +# Copyright: (c) 2010-2020 by Total Control Software # License: wxWindows License #--------------------------------------------------------------------------- @@ -561,7 +561,7 @@ header = """\ This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. - Copyright: (c) 2011-2018 by Total Control Software + Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License """ From b8facb230d15bcd72a16feb4da9150a803697c8a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 11 Nov 2020 16:41:52 -0800 Subject: [PATCH 10/13] Update wxWidgets revision to current master --- ext/wxWidgets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/wxWidgets b/ext/wxWidgets index 15f1f7a9..cf4c6fca 160000 --- a/ext/wxWidgets +++ b/ext/wxWidgets @@ -1 +1 @@ -Subproject commit 15f1f7a9e5c4ac783f789e45446b75b2ef496ae2 +Subproject commit cf4c6fca847874356c712d7bc3c6b67bd1bbfbd4 From f2b7035a5a8442c389769d545a76e31994f6ae54 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 13 Nov 2020 09:38:39 -0800 Subject: [PATCH 11/13] Swap which is the real name and which is the alias for DatePickerCtrlGeneric --- docs/sphinx/itemToModuleMap.json | 1 + etg/datectrl.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/itemToModuleMap.json b/docs/sphinx/itemToModuleMap.json index 33c8fba3..5cdb410e 100644 --- a/docs/sphinx/itemToModuleMap.json +++ b/docs/sphinx/itemToModuleMap.json @@ -891,6 +891,7 @@ "DataViewVirtualListModel":"wx.dataview.", "DateEvent":"wx.adv.", "DatePickerCtrl":"wx.adv.", +"DatePickerCtrlGeneric":"wx.adv.", "DateProperty":"wx.propgrid.", "DateSpan":"wx.", "DateTime":"wx.", diff --git a/etg/datectrl.py b/etg/datectrl.py index 7fb97f96..8630f142 100644 --- a/etg/datectrl.py +++ b/etg/datectrl.py @@ -42,8 +42,8 @@ def run(): gdpc = tools.copyClassDef(dpc, 'wxDatePickerCtrlGeneric') assert isinstance(gdpc, etgtools.ClassDef) module.insertItemAfter(dpc, gdpc) - # and give it a new Python name to match Classic - gdpc.pyName = 'GenericDatePickerCtrl' + # and give it an alias matching the class name in Classic + module.addPyCode("GenericDatePickerCtrl = DatePickerCtrlGeneric") # now back to our regular tweaking for c in [dpc, gdpc]: From b27e4928984b62d13028eedb6a96eaaba7d811e6 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 13 Nov 2020 09:39:37 -0800 Subject: [PATCH 12/13] Also show wx.adv.DatePickerCtrlGeneric in the demo --- demo/DatePickerCtrl.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/demo/DatePickerCtrl.py b/demo/DatePickerCtrl.py index 48615b6a..54313a1b 100644 --- a/demo/DatePickerCtrl.py +++ b/demo/DatePickerCtrl.py @@ -20,15 +20,17 @@ class TestPanel(wx.Panel): self.Bind(wx.adv.EVT_DATE_CHANGED, self.OnDateChanged, dpc) sizer.Add(dpc, 0, wx.ALL, 50) - # In some cases the widget used above will be a native date - # picker, so show the generic one too. - # dpc = wx.adv.DatePickerCtrlGeneric(self, size=(120,-1), - # style = wx.TAB_TRAVERSAL - # | wx.adv.DP_DROPDOWN - # | wx.adv.DP_SHOWCENTURY - # | wx.adv.DP_ALLOWNONE ) - # self.Bind(wx.adv.EVT_DATE_CHANGED, self.OnDateChanged, dpc) - # sizer.Add(dpc, 0, wx.LEFT, 50) + st = wx.StaticText(self, + label="In some cases the widget used above will be a native date picker, so show the generic one too.") + sizer.Add(st, 0, wx.LEFT, 50) + + dpc = wx.adv.DatePickerCtrlGeneric(self, size=(120,-1), + style = wx.adv.DP_DROPDOWN + | wx.adv.DP_SHOWCENTURY + | wx.adv.DP_ALLOWNONE ) + self.Bind(wx.adv.EVT_DATE_CHANGED, self.OnDateChanged, dpc) + sizer.Add((1,15)) + sizer.Add(dpc, 0, wx.LEFT, 50) def OnDateChanged(self, evt): From d45f07b6560fdf48237b5c42e4f5098ee3a7b43e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 13 Nov 2020 09:40:48 -0800 Subject: [PATCH 13/13] Update wxWidgets revision to current master --- ext/wxWidgets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/wxWidgets b/ext/wxWidgets index cf4c6fca..f65caa31 160000 --- a/ext/wxWidgets +++ b/ext/wxWidgets @@ -1 +1 @@ -Subproject commit cf4c6fca847874356c712d7bc3c6b67bd1bbfbd4 +Subproject commit f65caa31831ceb397022fefb308db09defa3fb66