(self, num, fig, *, canvas_class)
| 912 | |
| 913 | class FigureFrameWx(wx.Frame): |
| 914 | def __init__(self, num, fig, *, canvas_class): |
| 915 | # On non-Windows platform, explicitly set the position - fix |
| 916 | # positioning bug on some Linux platforms |
| 917 | if wx.Platform == '__WXMSW__': |
| 918 | pos = wx.DefaultPosition |
| 919 | else: |
| 920 | pos = wx.Point(20, 20) |
| 921 | super().__init__(parent=None, id=-1, pos=pos) |
| 922 | # Frame will be sized later by the Fit method |
| 923 | _log.debug("%s - __init__()", type(self)) |
| 924 | _set_frame_icon(self) |
| 925 | |
| 926 | self.canvas = canvas_class(self, -1, fig) |
| 927 | # Auto-attaches itself to self.canvas.manager |
| 928 | manager = FigureManagerWx(self.canvas, num, self) |
| 929 | |
| 930 | toolbar = self.canvas.manager.toolbar |
| 931 | if toolbar is not None: |
| 932 | self.SetToolBar(toolbar) |
| 933 | |
| 934 | # On Windows, canvas sizing must occur after toolbar addition; |
| 935 | # otherwise the toolbar further resizes the canvas. |
| 936 | w, h = map(math.ceil, fig.bbox.size) |
| 937 | self.canvas.SetInitialSize(self.FromDIP(wx.Size(w, h))) |
| 938 | self.canvas.SetMinSize(self.FromDIP(wx.Size(2, 2))) |
| 939 | self.canvas.SetFocus() |
| 940 | |
| 941 | self.Fit() |
| 942 | |
| 943 | self.Bind(wx.EVT_CLOSE, self._on_close) |
| 944 | |
| 945 | def _on_close(self, event): |
| 946 | _log.debug("%s - on_close()", type(self)) |
nothing calls this directly
no test coverage detected