Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a502c39

Browse files
FigureCanvasWx: use GetMinSize if canvas is managed by a sizer, but with fixed size
1 parent 2ed292d commit a502c39

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

lib/matplotlib/backends/backend_wx.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,19 @@ def _onSize(self, evt):
947947
"""
948948

949949
DEBUG_MSG("_onSize()", 2, self)
950+
sz = self.GetParent().GetSizer()
951+
if sz: si = sz.GetItem(self)
952+
if sz and si and not si.Proportion and not si.Flag & wx.EXPAND:
953+
# managed by a sizer, but with a fixed size
954+
size = self.GetMinSize()
955+
else:
956+
# variable size
957+
size = self.GetClientSize()
958+
if getattr(self, "_width", None) and size==(self._width,self._height):
959+
# no change in size
960+
return
961+
self._width, self._height = size
950962
# Create a new, correctly sized bitmap
951-
self._width, self._height = self.GetClientSize()
952963
self.bitmap = wxc.EmptyBitmap(self._width, self._height)
953964

954965
self._isDrawn = False

0 commit comments

Comments
 (0)