Changeset eea3ffa in sasview for src/sans/plottools
- Timestamp:
- Apr 3, 2014 8:21:43 AM (11 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 51f14603
- Parents:
- caf273b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/plottools/toolbar.py
ra9d5684 reea3ffa 4 4 import wx 5 5 from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg 6 from matplotlib.backends.backend_wx import _load_bitmap 7 import logging 8 9 # Event binding code changed after version 2.5 10 if wx.VERSION_STRING >= '2.5': 11 def bind(actor,event,action,**kw): 12 actor.Bind(event,action,**kw) 13 else: 14 def bind(actor,event,action,id=None): 15 if id is not None: 16 event(actor, id, action) 17 else: 18 event(actor,action) 6 19 7 20 class NavigationToolBar(NavigationToolbar2WxAgg): … … 11 24 def __init__(self, canvas, parent=None): 12 25 NavigationToolbar2WxAgg.__init__(self, canvas) 13 #the panel using this toolbar14 self.parent = parent15 #save canvas16 self.canvas = canvas17 #remove some icones18 self.delete_option()19 #add more icone20 self.add_option()21 22 def delete_option(self):23 """24 remove default toolbar item25 """26 #delte reset button27 self.DeleteToolByPos(0)28 #delete unwanted button that configures subplot parameters29 self.DeleteToolByPos(5)30 26 31 def add_option(self): 32 """ 33 add item to the toolbar 34 """ 35 #add print button 36 id_context = wx.NewId() 27 def _init_toolbar(self): 28 self._parent = self.canvas.GetParent() 29 _NTB2_HOME = wx.NewId() 30 self._NTB2_BACK = wx.NewId() 31 self._NTB2_FORWARD = wx.NewId() 32 self._NTB2_PAN = wx.NewId() 33 self._NTB2_ZOOM = wx.NewId() 34 _NTB2_SAVE = wx.NewId() 35 _NTB2_PRINT = wx.NewId() 36 _NTB2_RESET = wx.NewId() 37 38 self.SetToolBitmapSize(wx.Size(24,24)) 39 37 40 context_tip = 'Graph Menu: \n' 38 41 context_tip += ' For more menu options, \n' 39 42 context_tip += ' right-click the data symbols.' 40 43 context = wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_TOOLBAR) 41 self.InsertSimpleTool(0, id_context, context, 42 context_tip, context_tip) 43 wx.EVT_TOOL(self, id_context, self.on_menu) 44 self.AddSimpleTool(_NTB2_HOME, context, context_tip, context_tip) 45 44 46 self.InsertSeparator(1) 45 47 46 id_print = wx.NewId() 48 self.AddSimpleTool(self._NTB2_BACK, _load_bitmap('back.png'), 49 'Back', 'Back navigation view') 50 self.AddSimpleTool(self._NTB2_FORWARD, _load_bitmap('forward.png'), 51 'Forward', 'Forward navigation view') 52 # todo: get new bitmap 53 self.AddCheckTool(self._NTB2_PAN, _load_bitmap('move.png'), 54 shortHelp='Pan', 55 longHelp='Pan with left, zoom with right') 56 self.AddCheckTool(self._NTB2_ZOOM, _load_bitmap('zoom_to_rect.png'), 57 shortHelp='Zoom', longHelp='Zoom to rectangle') 58 59 self.AddSeparator() 60 self.AddSimpleTool(_NTB2_SAVE, _load_bitmap('filesave.png'), 61 'Save', 'Save plot contents to file') 62 47 63 print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR) 48 self.AddSimpleTool(id_print, print_bmp, 49 'Print', 'Activate printing') 50 wx.EVT_TOOL(self, id_print, self.on_print) 51 #add reset button 52 id_reset = wx.NewId() 64 self.AddSimpleTool(_NTB2_PRINT, print_bmp, 'Print', 'Print plot') 65 53 66 reset_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR) 54 self.AddSimpleTool(id_reset, reset_bmp, 55 'Reset Graph Range', 'Reset graph range') 56 wx.EVT_TOOL(self, id_reset, self.on_reset) 67 self.AddSimpleTool(_NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range') 68 69 bind(self, wx.EVT_TOOL, self.on_menu, id=_NTB2_HOME) 70 bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) 71 bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK) 72 bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) 73 bind(self, wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) 74 bind(self, wx.EVT_TOOL, self.save, id=_NTB2_SAVE) 75 bind(self, wx.EVT_TOOL, self.on_print, id=_NTB2_PRINT) 76 bind(self, wx.EVT_TOOL, self.on_reset, id=_NTB2_RESET) 77 78 self.Realize() 57 79 58 80 def on_menu(self, event): 59 81 """ 60 activate reset82 Plot menu 61 83 """ 62 84 try: 63 self. parent.onToolContextMenu(event=event)85 self._parent.onToolContextMenu(event=event) 64 86 except: 65 pass87 logging.error("Plot toolbar could not show menu") 66 88 67 89 def on_reset(self, event): 68 90 """ 69 activate reset91 Reset plot 70 92 """ 71 93 try: 72 self. parent.onResetGraph(event=event)94 self._parent.onResetGraph(event=event) 73 95 except: 74 pass96 logging.error("Plot toolbar could not reset plot") 75 97 76 98 def on_print(self, event): 77 99 """ 78 activate print100 Print 79 101 """ 80 102 try: 81 self.canvas.Printer_Pr int(event=event)103 self.canvas.Printer_Preview(event=event) 82 104 except: 83 pass105 logging.error("Plot toolbar could not print") 84 106
Note: See TracChangeset
for help on using the changeset viewer.