source: sasview/plottools/src/danse/common/plottools/toolbar.py @ 9bab141

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 9bab141 was 10bfeb3, checked in by Mathieu Doucet <doucetm@…>, 12 years ago

Pep-8-ification

  • Property mode set to 100644
File size: 2.5 KB
Line 
1"""
2    This module overwrites matplotlib toolbar
3"""
4import wx
5from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg
6
7class NavigationToolBar(NavigationToolbar2WxAgg):
8    """
9    Overwrite matplotlib toolbar
10    """
11    def __init__(self, canvas, parent=None):
12        NavigationToolbar2WxAgg.__init__(self, canvas)
13        #the panel using this toolbar
14        self.parent = parent
15        #save canvas
16        self.canvas = canvas
17        #remove some icones
18        self.delete_option()
19        #add more icone
20        self.add_option()
21       
22    def delete_option(self):
23        """
24        remove default toolbar item
25        """
26        #delte reset button
27        self.DeleteToolByPos(0)
28        #delete unwanted button that configures subplot parameters
29        self.DeleteToolByPos(5)
30       
31    def add_option(self):
32        """
33        add item to the toolbar
34        """
35        #add print button
36        id_context = wx.NewId()
37        context_tip = 'Graph Menu: \n'
38        context_tip += '    For more menu options, \n'
39        context_tip += '    right-click the data symbols.'
40        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.InsertSeparator(1)
45       
46        id_print = wx.NewId()
47        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()
53        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)
57       
58    def on_menu(self, event):
59        """
60        activate reset
61        """
62        try:
63            self.parent.onToolContextMenu(event=event)
64        except:
65            pass
66       
67    def on_reset(self, event):
68        """
69        activate reset
70        """
71        try:
72            self.parent.onResetGraph(event=event)
73        except:
74            pass
75       
76    def on_print(self, event):
77        """
78        activate print
79        """
80        try:
81            self.canvas.Printer_Print(event=event)
82        except:
83            pass
84       
Note: See TracBrowser for help on using the repository browser.