Exemple #1
0
 def __init__(self, plotCanvas):
     # create the default toolbar
     NavigationToolbar2Wx.__init__(self, plotCanvas)
     # remove the unwanted buttons
     self.DeleteToolByPos(1)
     self.DeleteToolByPos(1)
     self.DeleteToolByPos(5)
    def __init__(self, canvas, legend):
        NavigationToolbar2Wx.__init__(self, canvas)
        self._canvas = canvas
        self._legend = legend
        self._autoScale = True

        if matplotlib.__version__ >= '1.2':
            panId = self.wx_ids['Pan']
        else:
            panId = self.FindById(self._NTB2_PAN).GetId()
        self.ToggleTool(panId, True)
        self.pan()

        checkLegend = wx.CheckBox(self, label='Legend')
        checkLegend.SetValue(legend.get_visible())
        self.AddControl(checkLegend)
        self.Bind(wx.EVT_CHECKBOX, self.__on_legend, checkLegend, id)

        if wx.__version__ >= '2.9.1':
            self.AddStretchableSpace()
        else:
            self.AddSeparator()

        self._textCursor = wx.StaticText(self, style=wx.ALL | wx.ALIGN_RIGHT)
        font = self._textCursor.GetFont()
        if wx.__version__ >= '2.9.1':
            font.MakeSmaller()
        font.SetFamily(wx.FONTFAMILY_TELETYPE)
        self._textCursor.SetFont(font)
        w, _h = get_text_size(' ' * 18, font)
        self._textCursor.SetSize((w, -1))

        self.AddControl(self._textCursor)

        self.Realize()
Exemple #3
0
    def __init__(self, plotCanvas):
        # create the default toolbar
        NavigationToolbar2Wx.__init__(self, plotCanvas)
        # add new toolbar buttons
        temp = os.getcwd()

        logx_icon_path = os.path.join(temp, 'gui', 'icons', 'Logx.png')
        logy_icon_path = os.path.join(temp, 'gui', 'icons', 'Logy.png')

        self.AddSimpleTool(self.X_SCALE_SWITCH,
                           wx.Image(logx_icon_path,
                                    wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                           'x Log Lin Toggle',
                           'Switch the x-axis between log and linear scale',
                           isToggle=0)

        wx.EVT_TOOL(self, self.X_SCALE_SWITCH, self._x_scale_Log_Lin)

        self.AddSimpleTool(self.Y_SCALE_SWITCH,
                           wx.Image(logy_icon_path,
                                    wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                           'y Log Lin Toggle',
                           'Switch the y-axis between log and linear scale',
                           isToggle=0)

        os.chdir(temp)

        wx.EVT_TOOL(self, self.Y_SCALE_SWITCH, self._y_scale_Log_Lin)
Exemple #4
0
    def __init__(self, plotCanvas):
        # create the default toolbar
        NavigationToolbar2Wx.__init__(self, plotCanvas)
        # remove the unwanted button
        POSITION_OF_CONFIGURE_SUBPLOTS_BTN = 7

        self.DeleteToolByPos(POSITION_OF_CONFIGURE_SUBPLOTS_BTN)
Exemple #5
0
 def __init__(self, plot_canvas):
     # create the default toolbar
     NavigationToolbar2Wx.__init__(self, plot_canvas)
     # remove the unwanted button
     delete_array = (8, 7, 2, 1)
     for i in delete_array:
         self.DeleteToolByPos(i)
Exemple #6
0
    def __init__(self, canvas, keep_tools):
        # Taken from matplotlib/backend_wx.py but added style:
        self.VERSION = matplotlib.__version__
        #print('MPL VERSION:',self.VERSION)
        if self.VERSION[0]=='2' or self.VERSION[0]=='1': 
            wx.ToolBar.__init__(self, canvas.GetParent(), -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_NODIVIDER)
            NavigationToolbar2.__init__(self, canvas)

            self.canvas = canvas
            self._idle = True
            try: # Old matplotlib
                self.statbar = None 
            except:
                pass
            self.prevZoomRect = None
            self.retinaFix = 'wxMac' in wx.PlatformInfo
            #NavigationToolbar2Wx.__init__(self, plotCanvas)
        else:
            NavigationToolbar2Wx.__init__(self, canvas)

        # Make sure we start in zoom mode
        if 'Pan' in keep_tools:
            self.zoom() # NOTE: #22 BREAK cursors #12!

        # Remove unnecessary tools
        tools = [self.GetToolByPos(i) for i in range(self.GetToolsCount())]
        for i, t in reversed(list(enumerate(tools))):
            if t.GetLabel() not in keep_tools:
                self.DeleteToolByPos(i)
Exemple #7
0
 def __init__(self, plot_canvas):
     # create the default toolbar
     NavigationToolbar2Wx.__init__(self, plot_canvas)
     # remove the unwanted button
     delete_array = (8, 7, 2, 1)
     for i in delete_array:
         self.DeleteToolByPos(i)
Exemple #8
0
    def __init__(self, canvas, cankill):
        NavigationToolbar2Wx.__init__(self, canvas)

        # for simplicity I'm going to reuse a bitmap from wx, you'll
        # probably want to add your own.
        self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('stock_left.xpm'),
                           'Click me', 'Activate custom contol')
        EVT_TOOL(self, self.ON_CUSTOM, self._on_custom)
Exemple #9
0
    def __init__(self, canvas, cankill):
        NavigationToolbar2Wx.__init__(self, canvas)

        # for simplicity I'm going to reuse a bitmap from wx, you'll
        # probably want to add your own.
        self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('stock_left.xpm'),
                           'Click me', 'Activate custom contol')
        EVT_TOOL(self, self.ON_CUSTOM, self._on_custom)
    def __init__(self, canvas):
        NavigationToolbar2Wx.__init__(self,canvas)
        self.pan_tool  = self.FindById(self.wx_ids['Pan'])
        self.zoom_tool = self.FindById(self.wx_ids['Zoom'])
        #self.home_tool = self.FindById(self._NTB2_HOME)
        
        self.Bind(wx.EVT_TOOL, self.on_toggle_pan_zoom, self.zoom_tool)
        self.Bind(wx.EVT_TOOL, self.on_toggle_pan_zoom, self.pan_tool)

        self.user_tools = {}   # user_tools['tool_mode'] : wx.ToolBarToolBase

        self.InsertSeparator(5)
Exemple #11
0
 def __init__(self, plotCanvas):
     CONFIGURE_SUBPLOTS_TOOLBAR_BTN_POSITION = 6
     NavigationToolbar2Wx.__init__(self, plotCanvas)        
     # delete the toolbar button we don't want
     self.DeleteToolByPos(CONFIGURE_SUBPLOTS_TOOLBAR_BTN_POSITION) 
     # add the new toolbar buttons that we do want
     self.AddSimpleTool(self.ON_CUSTOM_LEFT, _load_bitmap('stock_left.xpm'),
                        'Pan to the left', 'Pan graph to the left')
     wx.EVT_TOOL(self, self.ON_CUSTOM_LEFT, self._on_custom_pan_left)
     self.AddSimpleTool(self.ON_CUSTOM_RIGHT, _load_bitmap('stock_right.xpm'),
                        'Pan to the right', 'Pan graph to the right')
     wx.EVT_TOOL(self, self.ON_CUSTOM_RIGHT, self._on_custom_pan_right)
Exemple #12
0
    def __init__(self, canvas):
        NavigationToolbar2Wx.__init__(self, canvas)
        self.pan_tool = self.FindById(self.wx_ids['Pan'])
        self.zoom_tool = self.FindById(self.wx_ids['Zoom'])
        #self.home_tool = self.FindById(self._NTB2_HOME)

        self.Bind(wx.EVT_TOOL, self.on_toggle_pan_zoom, self.zoom_tool)
        self.Bind(wx.EVT_TOOL, self.on_toggle_pan_zoom, self.pan_tool)

        self.user_tools = {}  # user_tools['tool_mode'] : wx.ToolBarToolBase

        self.InsertSeparator(5)
Exemple #13
0
    def __init__(self, plotCanvas):
        # create the default toolbar
        NavigationToolbar2Wx.__init__(self, plotCanvas)
        # add new toolbar buttons
        temp =os.getcwd()

       
        self.AddSimpleTool(self.X_SCALE_SWITCH, wx.Image('Logy.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(),'x Log Lin Toggle', 'Switch the x-axis between log and linear scale',isToggle=0)
        wx.EVT_TOOL(self, self.X_SCALE_SWITCH, self._x_scale_Log_Lin)
        self.AddSimpleTool(self.Y_SCALE_SWITCH, wx.Image('Logx.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(),'y Log Lin Toggle', 'Switch the y-axis between log and linear scale',isToggle=0)
        os.chdir(temp)

        wx.EVT_TOOL(self, self.Y_SCALE_SWITCH, self._y_scale_Log_Lin)
 def __init__(self, gui, canvas):
     '''Create the toolbar'''
     NavigationToolbar2Wx.__init__(self, canvas)
     self.gui         = gui
     self.pan_id      = self.wx_ids['Pan']
     self.zoom_id     = self.wx_ids['Zoom']
     self.pan_tool    = self.FindById(self.pan_id)
     self.zoom_tool   = self.FindById(self.zoom_id)
     self.Bind(wx.EVT_TOOL, self._on_toggle_pan_zoom, self.pan_tool)
     self.Bind(wx.EVT_TOOL, self._on_toggle_pan_zoom, self.zoom_tool)
     self.button      = wx.Button( self, label = 'Region Selector' )
     self.button.Bind( wx.EVT_BUTTON, self._on_region_select )
     self.AddControl( self.button )
Exemple #15
0
    def __init__(self, plotCanvas, plot):

        # create the default toolbar
        NavigationToolbar.__init__(self, plotCanvas)
        self.plot = plot

        # remove the sub-plots button
        POSITION_OF_CONFIGURE_SUBPLOTS_BTN = 7
        self.DeleteToolByPos(POSITION_OF_CONFIGURE_SUBPLOTS_BTN)

        # add check-boxes for grid overlay, coordinate labels
        # and cursor coordinates
        self._checkboxes = {}
        self._checkboxes['cursor'] = wx.CheckBox(self, label='&Cursor Coords')
        self._checkboxes['grid'] = wx.CheckBox(self, label='Coord &Grid')
        self._checkboxes['gridlabel'] = wx.CheckBox(self, label='Grid &Labels')
        self.AddSeparator()
        self.AddControl(self._checkboxes['cursor'])
        self.AddControl(self._checkboxes['grid'])
        self.AddControl(self._checkboxes['gridlabel'])

        # bind the checkboxes
        self.Bind(
                wx.EVT_CHECKBOX, self.on_checkbox,
                id=self._checkboxes['cursor'].GetId()
                )
        self.Bind(
                wx.EVT_CHECKBOX, self.on_checkbox,
                id=self._checkboxes['grid'].GetId()
                )
        self.Bind(
                wx.EVT_CHECKBOX, self.on_checkbox,
                id=self._checkboxes['gridlabel'].GetId()
                )

        # default values for checkboxes
        self._checkboxes['cursor'].SetValue(wx.CHK_CHECKED)
        self._checkboxes['grid'].SetValue(wx.CHK_CHECKED)
        self._checkboxes['gridlabel'].SetValue(wx.CHK_CHECKED)

        self._zoom_pressed = False

        self.Realize()
Exemple #16
0
    def __init__(self, canvas, figure):
        if matplotlib.__version__ < '3.3.0':
            self._init_toolbar = self.init_toolbar
        else:
            self._init_toolbar = self.init_toolbar_empty
        NavigationToolbar.__init__(self, canvas)

        if matplotlib.__version__ >= '3.3.0':
            self.init_toolbar()
        self.SetWindowStyle(wx.TB_HORIZONTAL | wx.TB_FLAT)
        self.figure = figure
        self.datacursor = DataCursor()
        self.canvas.mpl_connect('pick_event', self.datacursor)
        self.canvas.mpl_connect('motion_notify_event', self.OnMove)
        self.canvas.mpl_connect('button_press_event', self.OnPressed)
        self.canvas.mpl_connect('button_release_event', self.OnReleased)
        self.canvas.mpl_connect('scroll_event', self.OnZoomFun)
        # clear the view history
        wx.CallAfter(self._nav_stack.clear)
	def __init__(self,canvas):
		NavigationToolbar2Wx.__init__(self,canvas)
		self.canvas=canvas
		
		self.AddSeparator()
		self.IdConnect=wx.NewId()
		self.AddSimpleTool(self.IdConnect, _load_bitmap('stock_refresh.xpm'),'Connect',isToggle=True)
		self._connect=False
		
		self.IdClear=wx.NewId()
		self.AddSimpleTool(self.IdClear, _load_bitmap('stock_close.xpm'),'Clear')
		
		self.Bind(wx.EVT_TOOL, self.OnConnect, id=self.IdConnect)
		self._connect=None
		self._disconnect=None
		self.Bind(wx.EVT_TOOL, self.OnClear, id=self.IdClear)
		self._clear=None
		self._getlim=None
		
		self.Realize()
Exemple #18
0
    def __init__(self, plotCanvas):
        # create the default toolbar
        NavigationToolbar2Wx.__init__(self, plotCanvas)
        # add new toolbar buttons

        folder = os.path.dirname(__file__)

        self.AddSimpleTool(self.X_SCALE_SWITCH,
                           wx.Image(os.path.join(folder, 'Logy.png'),
                                    wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                           'x Log Lin Toggle',
                           'Switch the x-axis between log and linear scale',
                           isToggle=0)
        wx.EVT_TOOL(self, self.X_SCALE_SWITCH, self._x_scale_Log_Lin)
        self.AddSimpleTool(self.Y_SCALE_SWITCH,
                           wx.Image(os.path.join(folder, 'Logx.png'),
                                    wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                           'y Log Lin Toggle',
                           'Switch the y-axis between log and linear scale',
                           isToggle=0)

        wx.EVT_TOOL(self, self.Y_SCALE_SWITCH, self._y_scale_Log_Lin)
    def __init__(self, plotCanvas):
        # create the default toolbar
        NavigationToolbar2Wx.__init__(self, plotCanvas)
        # add new toolbar buttons

        folder = os.path.dirname(__file__)

        self.AddSimpleTool(self.X_SCALE_SWITCH,
                           wx.Image(os.path.join(folder, 'Logy.png'),
                                    wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                           'x Log Lin Toggle',
                           'Switch the x-axis between log and linear scale',
                           isToggle=0)
        wx.EVT_TOOL(self, self.X_SCALE_SWITCH, self._x_scale_Log_Lin)
        self.AddSimpleTool(self.Y_SCALE_SWITCH,
                           wx.Image(os.path.join(folder, 'Logx.png'),
                                    wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                           'y Log Lin Toggle',
                           'Switch the y-axis between log and linear scale',
                           isToggle=0)

        wx.EVT_TOOL(self, self.Y_SCALE_SWITCH, self._y_scale_Log_Lin)
 def __init__(self, *args, **kwargs):
     NavigationToolbar2Wx.__init__(self, *args, **kwargs)