| 1053 | |
| 1054 | class NavigationToolbar2Wx(NavigationToolbar2, wx.ToolBar): |
| 1055 | def __init__(self, canvas, coordinates=True, *, style=wx.TB_BOTTOM): |
| 1056 | wx.ToolBar.__init__(self, canvas.GetParent(), -1, style=style) |
| 1057 | if wx.Platform == '__WXMAC__': |
| 1058 | self.SetToolBitmapSize(self.GetToolBitmapSize()*self.GetDPIScaleFactor()) |
| 1059 | |
| 1060 | self.wx_ids = {} |
| 1061 | for text, tooltip_text, image_file, callback in self.toolitems: |
| 1062 | if text is None: |
| 1063 | self.AddSeparator() |
| 1064 | continue |
| 1065 | self.wx_ids[text] = ( |
| 1066 | self.AddTool( |
| 1067 | -1, |
| 1068 | bitmap=self._icon(f"{image_file}.svg"), |
| 1069 | bmpDisabled=wx.NullBitmap, |
| 1070 | label=text, shortHelp=tooltip_text, |
| 1071 | kind=(wx.ITEM_CHECK if text in ["Pan", "Zoom"] |
| 1072 | else wx.ITEM_NORMAL)) |
| 1073 | .Id) |
| 1074 | self.Bind(wx.EVT_TOOL, getattr(self, callback), |
| 1075 | id=self.wx_ids[text]) |
| 1076 | |
| 1077 | self._coordinates = coordinates |
| 1078 | if self._coordinates: |
| 1079 | self.AddStretchableSpace() |
| 1080 | self._label_text = wx.StaticText(self, style=wx.ALIGN_RIGHT) |
| 1081 | self.AddControl(self._label_text) |
| 1082 | |
| 1083 | self.Realize() |
| 1084 | |
| 1085 | NavigationToolbar2.__init__(self, canvas) |
| 1086 | |
| 1087 | @staticmethod |
| 1088 | def _icon(name): |