MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _on_size

Method _on_size

lib/matplotlib/backends/backend_wx.py:642–686  ·  view source on GitHub ↗

Called when wxEventSize is generated. In this application we attempt to resize to fit the window, so it is better to take the performance hit and redraw the whole window.

(self, event)

Source from the content-addressed store, hash-verified

640 drawDC.Destroy()
641
642 def _on_size(self, event):
643 """
644 Called when wxEventSize is generated.
645
646 In this application we attempt to resize to fit the window, so it
647 is better to take the performance hit and redraw the whole window.
648 """
649 self._update_device_pixel_ratio()
650 _log.debug("%s - _on_size()", type(self))
651 sz = self.GetParent().GetSizer()
652 if sz:
653 si = sz.GetItem(self)
654 if sz and si and not si.Proportion and not si.Flag & wx.EXPAND:
655 # managed by a sizer, but with a fixed size
656 size = self.GetMinSize()
657 else:
658 # variable size
659 size = self.GetClientSize()
660 # Do not allow size to become smaller than MinSize
661 size.IncTo(self.GetMinSize())
662 if getattr(self, "_width", None):
663 if size == (self._width, self._height):
664 # no change in size
665 return
666 self._width, self._height = size
667 self._isDrawn = False
668
669 if self._width <= 1 or self._height <= 1:
670 return # Empty figure
671
672 # Create a new, correctly sized bitmap
673 dpival = self.figure.dpi
674 if not wx.Platform == '__WXMSW__':
675 scale = self.GetDPIScaleFactor()
676 dpival /= scale
677 winch = self._width / dpival
678 hinch = self._height / dpival
679 self.figure.set_size_inches(winch, hinch, forward=False)
680
681 # Rendering will happen on the associated paint event
682 # so no need to do anything here except to make sure
683 # the whole background is repainted.
684 self.Refresh(eraseBackground=False)
685 ResizeEvent("resize_event", self)._process()
686 self.draw_idle()
687
688 @staticmethod
689 def _mpl_buttons():

Callers

nothing calls this directly

Calls 5

draw_idleMethod · 0.95
ResizeEventClass · 0.90
set_size_inchesMethod · 0.80
_processMethod · 0.80

Tested by

no test coverage detected