From 2f5c143fa701e75a5b24a0cfbf040820ea35083e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 30 May 2018 17:01:04 -0700 Subject: [PATCH 1/8] Changelog for TextEditMixin fix --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 3d330310..030d1f3b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -135,6 +135,9 @@ Changes in this release include the following: * Detach wxControl in AuiToolbar from current sizer before attach to a new one. (#843) +* Fixed a problem in wx.lib.mixins.listctrl.TextEditMixin where the height of + the editor widget could be set to zero. (See discussion in #849) + From 6453684bc3f27840650ea2ca2786a4a9828657f7 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 30 May 2018 16:46:25 -0700 Subject: [PATCH 2/8] Keep existing height of edit widget, and move the activation to a call-after --- wx/lib/mixins/listctrl.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/wx/lib/mixins/listctrl.py b/wx/lib/mixins/listctrl.py index 021eca8d..c0c72532 100644 --- a/wx/lib/mixins/listctrl.py +++ b/wx/lib/mixins/listctrl.py @@ -611,14 +611,15 @@ class TextEditMixin: y0 = self.GetItemRect(row)[1] - editor = self.editor - editor.SetSize(x0-scrolloffset,y0, x1,-1) + def _activate_editor(editor): + editor.SetSize(x0-scrolloffset,y0, x1,-1, wx.SIZE_USE_EXISTING) + editor.SetValue(self.GetItem(row, col).GetText()) + editor.Show() + editor.Raise() + editor.SetSelection(-1,-1) + editor.SetFocus() - editor.SetValue(self.GetItem(row, col).GetText()) - editor.Show() - editor.Raise() - editor.SetSelection(-1,-1) - editor.SetFocus() + wx.CallAfter(_activate_editor, self.editor) self.curRow = row self.curCol = col From c53f5b01cae0fffa7fbe900cb25a20bf1e168b6e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 30 May 2018 16:51:22 -0700 Subject: [PATCH 3/8] Minor tweaks for some comments --- wscript | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/wscript b/wscript index ad580861..f0ae50a4 100644 --- a/wscript +++ b/wscript @@ -68,20 +68,18 @@ def configure(conf): msvc_version = str( distutils.msvc9compiler.get_build_version() ) # When building for Python 3.7 the msvc_version returned will be - # "14.1" as that is the version of the BasePlatformToolkit that - # stock Python 3.7 was built with, a.k.a v141, which is the - # default in Visual Studio 2017. However, waf is using "msvc - # 15.0" to designate that version rather than "14.1" so we'll - # need to catch that case and fix up the msvc_version - # accordingly. + # "14.1" as that is the version of the BasePlatformToolkit that stock + # Python 3.7 was built with, a.k.a v141, which is the default in + # Visual Studio 2017. However, waf is using "msvc 15.0" to designate + # that version rather than "14.1" so we'll need to catch that case and + # fix up the msvc_version accordingly. if msvc_version == "14.1" and sys.version_info >= (3,7): ##msvc_version = '15.0' - # On the other hand, microsoft says that v141 and v140 - # (Visual Studio 2015) are binary compatible, so for now - # let's just drop it back to "14.0" until I get all the - # details worked out for using VS 2017 everywhere for Python - # 3.7. + # On the other hand, microsoft says that v141 and v140 (Visual + # Studio 2015) are binary compatible, so for now let's just drop + # it back to "14.0" until I get all the details worked out for + # using VS 2017 everywhere for Python 3.7. msvc_version = '14.0' conf.env['MSVC_VERSIONS'] = ['msvc ' + msvc_version] From 57fb12c877749de601cdfd8d0295417001a443f7 Mon Sep 17 00:00:00 2001 From: Tianzhu Qiao Date: Sun, 27 May 2018 16:08:28 -0700 Subject: [PATCH 4/8] Fix a bug in calculating whether a tool fits into the AuiToolBar. (cherry picked from commit ae4a5dc665a8d50a0dca3714bf9c417e3cc27996) --- CHANGES.rst | 1 + wx/lib/agw/aui/auibar.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 030d1f3b..94b00b00 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -138,6 +138,7 @@ Changes in this release include the following: * Fixed a problem in wx.lib.mixins.listctrl.TextEditMixin where the height of the editor widget could be set to zero. (See discussion in #849) +* Fix a bug in calculating whether a tool fits into the AuiToolBar. (#863) diff --git a/wx/lib/agw/aui/auibar.py b/wx/lib/agw/aui/auibar.py index af61dc72..5c6a9d58 100644 --- a/wx/lib/agw/aui/auibar.py +++ b/wx/lib/agw/aui/auibar.py @@ -2935,11 +2935,12 @@ class AuiToolBar(wx.Control): cli_w, cli_h = self.GetClientSize() rect = self._items[tool_id].sizer_item.GetRect() + dropdown_size = self._art.GetElementSize(AUI_TBART_OVERFLOW_SIZE) if self._agwStyle & AUI_TB_VERTICAL: # take the dropdown size into account if self._overflow_visible: - cli_h -= self._overflow_sizer_item.GetSize().y + cli_h -= dropdown_size if rect.y+rect.height < cli_h: return True @@ -2948,7 +2949,7 @@ class AuiToolBar(wx.Control): # take the dropdown size into account if self._overflow_visible: - cli_w -= self._overflow_sizer_item.GetSize().x + cli_w -= dropdown_size if rect.x+rect.width < cli_w: return True From 0c75ee6277eb93f98f2ab34836bcedc9854da449 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 30 May 2018 21:02:57 -0700 Subject: [PATCH 5/8] Merge pull request #867 from RobinD42/fix-issue855 im_func --> __func__ (cherry picked from commit 6b858b5966c6ca1084b60b0059bb14b9f413760d) --- wx/py/introspect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wx/py/introspect.py b/wx/py/introspect.py index 507400d4..d5548cd9 100644 --- a/wx/py/introspect.py +++ b/wx/py/introspect.py @@ -371,7 +371,7 @@ def getBaseObject(obj): elif callable(obj): # Get the __call__ method instead. try: - obj = obj.__call__.im_func + obj = obj.__call__.__func__ dropSelf = 1 except AttributeError: dropSelf = 0 @@ -382,7 +382,7 @@ def getBaseObject(obj): def getConstructor(obj): """Return constructor for class object, or None if there isn't one.""" try: - return obj.__init__.im_func + return obj.__init__.__func__ except AttributeError: for base in obj.__bases__: constructor = getConstructor(base) From 0a0c170450fedc19ceb35c721a39aebf4b0b7171 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 30 May 2018 21:05:21 -0700 Subject: [PATCH 6/8] Merge pull request #869 from RobinD42/fix-issue808 Override SetForegroundColour and SetBackgroundColour in MaskedEditMixin (cherry picked from commit 4b1ecf2c2589b1a33a9f1c95829380894612dd99) --- CHANGES.rst | 3 +++ wx/lib/masked/maskededit.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 94b00b00..13e0c7bd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -140,6 +140,9 @@ Changes in this release include the following: * Fix a bug in calculating whether a tool fits into the AuiToolBar. (#863) +* Override SetForegroundColour and SetBackgroundColour in MaskedEditMixin (#808) + + 4.0.1 "Lemonade" diff --git a/wx/lib/masked/maskededit.py b/wx/lib/masked/maskededit.py index d87769d3..a0e05122 100644 --- a/wx/lib/masked/maskededit.py +++ b/wx/lib/masked/maskededit.py @@ -3229,6 +3229,13 @@ class MaskedEditMixin: #### dbg(indent=0) return self._fields[self._lookupField[pos]] + def SetForegroundColour(self, colour): + super(MaskedEditMixin, self).SetForegroundColour(colour) + self._foregroundColour = colour + + def SetBackgroundColour(self, colour): + super(MaskedEditMixin, self).SetBackgroundColour(colour) + self._validBackgroundColour = colour def ClearValue(self): """ Blanks the current control value by replacing it with the default value.""" From 4b4e642c4fedb5235d5db89e6ad9fd6fef792bc5 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 31 May 2018 21:16:27 -0700 Subject: [PATCH 7/8] Merge pull request #874 from RobinD42/fix-issue783 Add a wx.GraphicsContext.Create overload for wx.AutoBufferedPaintDC (cherry picked from commit c798be08a30dd51400f66dee4d495044f492b4f1) --- CHANGES.rst | 2 ++ etg/graphics.py | 34 ++++++++++++++++++++++------------ unittests/test_graphics.py | 21 +++++++++++++++++++++ 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 13e0c7bd..e4f08d22 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -142,6 +142,8 @@ Changes in this release include the following: * Override SetForegroundColour and SetBackgroundColour in MaskedEditMixin (#808) +* Add an explicit wx.GraphicsContext.Create overload for wx.AutoBufferedPaintDC. (#783) + diff --git a/etg/graphics.py b/etg/graphics.py index a86eae18..a35a7605 100644 --- a/etg/graphics.py +++ b/etg/graphics.py @@ -47,7 +47,8 @@ def run(): module.addHeaderCode('#include ') - def markFactories(klass): + def markCreateFactories(klass): + """Mark all Create methods as factories""" for func in klass.allItems(): if isinstance(func, etgtools.FunctionDef) \ and func.name.startswith('Create') \ @@ -65,20 +66,16 @@ def run(): #--------------------------------------------- c = module.find('wxGraphicsContext') assert isinstance(c, etgtools.ClassDef) - markFactories(c) tools.removeVirtuals(c) c.abstract = True c.mustHaveApp() - - # Ensure that the target DC or image lives as long as the GC does. NOTE: - # Since the Creates are static methods there is no self to associate the - # extra reference with, but since they are factories then that extra - # reference will be held by the return value of the factory instead. - for m in c.find('Create').all(): - for p in m.items: - if 'DC' in p.name or p.name == 'image': - p.keepReference = True + c.addCppMethod('wxGraphicsContext*', 'Create', '(wxAutoBufferedPaintDC* autoPaintDC /KeepReference/)', + pyArgsString='(autoPaintDC) -> GraphicsContext', + isStatic=True, + body="""\ + return wxGraphicsContext::Create(autoPaintDC); + """) m = c.find('Create').findOverload('wxEnhMetaFileDC') m.find('metaFileDC').type = 'const wxMetafileDC&' @@ -93,6 +90,19 @@ def run(): return NULL; """) + markCreateFactories(c) + + # Ensure that the target DC or image passed to Create lives as long as the + # GC does. NOTE: Since the Creates are static methods there is no self to + # associate the extra reference with, but since they are factories then + # that extra reference will be held by the return value of the factory + # instead. + for m in c.find('Create').all(): + for p in m.items: + if 'DC' in p.name or p.name == 'image': + p.keepReference = True + + c.find('GetSize.width').out = True c.find('GetSize.height').out = True c.find('GetDPI.dpiX').out = True @@ -194,7 +204,7 @@ def run(): #--------------------------------------------- c = module.find('wxGraphicsRenderer') tools.removeVirtuals(c) - markFactories(c) + markCreateFactories(c) c.abstract = True for m in c.find('CreateContext').all(): diff --git a/unittests/test_graphics.py b/unittests/test_graphics.py index 26cb520d..fefe8ff4 100644 --- a/unittests/test_graphics.py +++ b/unittests/test_graphics.py @@ -23,6 +23,27 @@ class graphics_Tests(wtc.WidgetTestCase): gc = wx.GraphicsContext.Create(img) self.assertTrue(gc.IsOk()) + def test_gcCreate4(self): + class MyPanel(wx.Panel): + def __init__(self, parent): + super(MyPanel, self).__init__(parent) + self.SetBackgroundStyle(wx.BG_STYLE_PAINT) + self.Bind(wx.EVT_PAINT, self.OnPaint) + self.painted = False + self.gcIsOk = False + + def OnPaint(self, evt): + dc = wx.AutoBufferedPaintDC(self) + gc = wx.GraphicsContext.Create(dc) + self.gcIsOk = gc.IsOk() + self.painted = True + + panel = MyPanel(self.frame) + self.myUpdate(panel) + self.assertTrue(panel.painted) + self.assertTrue(panel.gcIsOk) + + def test_gcCreateBitmap(self): self.waitFor(50) gc = wx.GraphicsContext.Create(self.frame) From d04878e5eaf7f2e5fba6cd240cf97900b255f8be Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 31 May 2018 21:20:45 -0700 Subject: [PATCH 8/8] Merge pull request #871 from tianzhuqiao/agw_aui_4.0.x Return original AGW window style in AuiToolBar.GetAGWWindowStyleFlag. (cherry picked from commit 183bda593011cddb973cc989fbe5911e361bacfb) --- CHANGES.rst | 1 + wx/lib/agw/aui/auibar.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index e4f08d22..d18008de 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -144,6 +144,7 @@ Changes in this release include the following: * Add an explicit wx.GraphicsContext.Create overload for wx.AutoBufferedPaintDC. (#783) +* Return original AGW window style in AuiToolBar.GetAGWWindowStyleFlag. (#870) diff --git a/wx/lib/agw/aui/auibar.py b/wx/lib/agw/aui/auibar.py index 5c6a9d58..5f6eec67 100644 --- a/wx/lib/agw/aui/auibar.py +++ b/wx/lib/agw/aui/auibar.py @@ -1706,7 +1706,7 @@ class AuiToolBar(wx.Control): :see: :meth:`SetAGWWindowStyleFlag` for an explanation of various AGW-specific style. """ - return self._agwStyle + return self._originalStyle def SetArtProvider(self, art):