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)
| 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(): |
nothing calls this directly
no test coverage detected