From a502c39d91076fd1db09a9623ae780eef5d6e4a1 Mon Sep 17 00:00:00 2001 From: DietmarSchwertberger Date: Sun, 4 Feb 2018 16:37:58 +0100 Subject: [PATCH 1/2] FigureCanvasWx: use GetMinSize if canvas is managed by a sizer, but with fixed size --- lib/matplotlib/backends/backend_wx.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index d2fd3c5218ab..5d60b2e0e5dd 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -947,8 +947,19 @@ def _onSize(self, evt): """ DEBUG_MSG("_onSize()", 2, self) + sz = self.GetParent().GetSizer() + if sz: si = sz.GetItem(self) + if sz and si and not si.Proportion and not si.Flag & wx.EXPAND: + # managed by a sizer, but with a fixed size + size = self.GetMinSize() + else: + # variable size + size = self.GetClientSize() + if getattr(self, "_width", None) and size==(self._width,self._height): + # no change in size + return + self._width, self._height = size # Create a new, correctly sized bitmap - self._width, self._height = self.GetClientSize() self.bitmap = wxc.EmptyBitmap(self._width, self._height) self._isDrawn = False From d48114ecaf848219d55eb67d1c6bde559129f4e1 Mon Sep 17 00:00:00 2001 From: DietmarSchwertberger Date: Mon, 5 Feb 2018 00:21:31 +0100 Subject: [PATCH 2/2] reformat to avoid Travis CI errors --- lib/matplotlib/backends/backend_wx.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 5d60b2e0e5dd..05e20a0d93f1 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -948,16 +948,18 @@ def _onSize(self, evt): DEBUG_MSG("_onSize()", 2, self) sz = self.GetParent().GetSizer() - if sz: si = sz.GetItem(self) + if sz: + si = sz.GetItem(self) if sz and si and not si.Proportion and not si.Flag & wx.EXPAND: # managed by a sizer, but with a fixed size size = self.GetMinSize() else: # variable size size = self.GetClientSize() - if getattr(self, "_width", None) and size==(self._width,self._height): - # no change in size - return + if getattr(self, "_width", None): + if size == (self._width, self._height): + # no change in size + return self._width, self._height = size # Create a new, correctly sized bitmap self.bitmap = wxc.EmptyBitmap(self._width, self._height)