Exemplo n.º 1
0
class CanvasFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1,
                          'CanvasFrame', size=(550, 350))

        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        t = np.arange(0.0, 3.0, 0.01)
        s = np.sin(2 * np.pi * t)

        self.axes.plot(t, s)
        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_toolbar()  # comment this out for no toolbar

    def add_toolbar(self):
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        # By adding toolbar in sizer, we are able to put it at the bottom
        # of the frame - so appearance is closer to GTK version.
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()
Exemplo n.º 2
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)
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
class CanvasFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'CanvasFrame', size=(550, 350))

        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        t = np.arange(0.0, 3.0, 0.01)
        s = np.sin(2 * np.pi * t)

        self.axes.plot(t, s)
        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_toolbar()  # comment this out for no toolbar

    def add_toolbar(self):
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        # By adding toolbar in sizer, we are able to put it at the bottom
        # of the frame - so appearance is closer to GTK version.
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()
Exemplo n.º 5
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)
Exemplo n.º 6
0
 def drag_pan(self, event):
     """
     Callback for mouse motion in pan mode
     """
     NavigationToolbar.drag_pan(self, event)
     if event.button == 3:
         self.plot.set_right_click_zoomed()
Exemplo n.º 7
0
class FigurePanel(wx.Panel):
    def __init__(self, parent, figure_window):
        super().__init__(parent)

        self.figure = Figure()
        self.canvas = FigureCanvas(self, -1, self.figure)
        # self.subplot = self.figure.subplots(1)

        figure_window.figure = self.figure
        figure_window.setUpFigLayout()
        figure_window.plot_data()
        figure_window.activate_sliders()

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, wx.SizerFlags(1).Left().Top().Shaped())
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_toolbar()  # comment this out for no toolbar

    def add_toolbar(self):
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        # By adding toolbar in sizer, we are able to put it at the bottom
        # of the frame - so appearance is closer to GTK version.
        self.sizer.Add(self.toolbar, wx.SizerFlags(0).Left())
        # update the axes menu on the toolbar
        self.toolbar.update()
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
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)
Exemplo n.º 11
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)
Exemplo n.º 12
0
 def release_pan(self, event):
     """
     Callback for mouse button release in pan mode
     """
     # disable any buttons except 1 and 3
     if event.button != 1 and event.button != 3:
         return
     NavigationToolbar.release_pan(self, event)
Exemplo n.º 13
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)
Exemplo n.º 14
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)
Exemplo n.º 15
0
 def press_zoom(self, event):
     """
     Callback for mouse button press in zoom mode
     """
     # disable the weird right-click zoom rectangle
     if event.button != 1:
         return
     self._zoom_pressed = True
     NavigationToolbar.press_zoom(self, event)
Exemplo n.º 16
0
 def release_zoom(self, event):
     """
     Callback for mouse button release in zoom mode
     """
     # disable the weird right-click zoom rectangle
     if event.button != 1:
         return
     self._zoom_pressed = False
     NavigationToolbar.release_zoom(self, event)
     self.plot.do_dynamic_update()
Exemplo n.º 17
0
    def mouse_move(self, event):
        """
        Mouse motion callback
        """
        # update the text box with coordinates of cursor
        # FIXME: Make this a method
        if not self._zoom_pressed and event.inaxes:
            self.plot.on_mouse_move(event)

        # call the parent handler also
        NavigationToolbar.mouse_move(self, event)
Exemplo n.º 18
0
	def OnConnect(self,event):
		self.ToggleTool(self._NTB2_PAN,False)
		self.ToggleTool(self._NTB2_ZOOM,False)
		if self._active=='PAN': NavigationToolbar2Wx.pan(self,event)
		if self._active=='ZOOM': NavigationToolbar2Wx.zoom(self,event)
		
		if self.GetToolState(self.IdConnect):
			if callable(self._connect): self._connect()
		else:
			if callable(self._disconnect): self._disconnect()
		if callable(self._getlim): self._getlim()
Exemplo n.º 19
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)
Exemplo n.º 20
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)
    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)
Exemplo n.º 22
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 )
Exemplo n.º 24
0
    def __init__(self, parent, title, size):
        wx.Frame.__init__(self, parent, title=title, size=size)

        self.menubar = wx.MenuBar()
        self.file = wx.Menu()
        menusavefig = self.file.Append(wx.ID_ANY, '&Save figure',\
                                       "Save the current figure")
        menuexit = self.file.Append(wx.ID_EXIT, \
                                    '&Exit', u"Close Fourier Frame")
        self.menubar.Append(self.file, '&File')
        self.SetMenuBar(self.menubar)

        self.figure = Figure()
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.EXPAND)
        self.SetSizer(self.sizer)

        self.Bind(wx.EVT_MENU, self._OnSave, menusavefig)
        self.Bind(wx.EVT_MENU, self._OnClose, menuexit)
        self.Bind(wx.EVT_CLOSE, self._OnClose)

        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.toolbar.update()
Exemplo n.º 25
0
    def __init__(self, parent, ID, title, data=None, axes_label=None):

        wx.MDIChildFrame.__init__(self, parent, ID, title)
        self.data = data
        if axes_label is None:
            self.axes_title = self.GetTitle()
            self.axes_xlabel = "Frequency(GHz)"
            self.axes_ylabel = "Mag(dB)"
        else:
            self.axes_title = axes_label[0]
            self.axes_xlabel = axes_label[1]
            self.axes_ylabel = axes_label[2]

        #GUI layout
        self.Maximize()
        panel = wx.Panel(self, -1, style=wx.CLIP_CHILDREN)
        self.canvas = FigureCanvas(panel, -1, Figure())
        toolbar = NavigationToolbar2Wx(self.canvas)
        sizer = wx.BoxSizer(wx.VERTICAL)
        panel.SetSizer(sizer)

        sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        sizer.Add(toolbar, 0, wx.EXPAND | wx.RIGHT)

        self.canvas.mpl_connect('motion_notify_event', self.UpdateStatusBar)
Exemplo n.º 26
0
    def __init__(self, parent, title):
        #wx.Frame.__init__(self, parent,id,'Procesador de Imagen Raster Version 1.1.1.1', size=(1000,600))
        #p = wx.Panel(self)
        wx.Frame.__init__(self, parent, title=title)
        self.MakeMenuBar()        
        self.initpos = 100
        self.sp = wx.SplitterWindow(self)            
        self.p1 = wx.Panel(self.sp)
        self.p2 = wx.Panel(self.sp,style=wx.SUNKEN_BORDER)            
        #self.p2.Hide()
        #self.p1.wx.SetBackgroundColour("pink")
        #self.p2.wx.SetBackgroundColour("sky blue")
        self.sp.Initialize(self.p1)
        self.sp.SetMinimumPaneSize(10)
        
        self.sp.SplitVertically(self.p1, self.p2,self.initpos)
        #ListBox
        dirlist = ['o','u','y']
        listBox = wx.ListBox(self.p1,-1,(20,20),(80,120),dirlist, wx.LB_SINGLE)
        listBox.SetSelection(3)
        
        #self.figure = Figure()
        #self.axes = self.figure.add_subplot(111)    
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self.p2, wx.ID_ANY, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
        self.toolbar = NavigationToolbar2Wx(self.canvas)
##        self.toolbar.Realize()
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.toolbar.Show()
Exemplo n.º 27
0
    def __init__(self, argv):
        wx.Frame.__init__(self,None,-1,
                         'Segment Size',size=(550,350))
        parser = argparse.ArgumentParser(description="utility to plot a persistence diagram")
        parser.add_argument('file')
        self.args = vars(parser.parse_args(argv[1:]))
        self.file = self.args['file']
        pf_json = load_data(self.file, 'persistence', None, None, None)
        if pf_json == None :
            print "Could not load persistence file : %s" % (self.args['file'],)
            exit()
        self.persistences = Persistences.fromJSONDict(pf_json)
        
        self.SetBackgroundColour(wx.NamedColour("WHITE"))
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        
        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(NavigationToolbar2Wx(self.canvas), 1, wx.LEFT | wx.TOP | wx.GROW)
        self.sizer.Add(self.canvas, 8, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()
        self.background = self.axes.figure.canvas.copy_from_bbox(self.axes.bbox)
        self.colors = ['black', 'red', 'yellow', 'orange', 'blue', 'green', 'violet']
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_KEY_UP, self.KeyEvent)
        self.index = 0
        self.point_Refresh()
Exemplo n.º 28
0
    def __init__(self, parent, columns, df_list_ctrl):
        wx.Panel.__init__(self, parent)

        columns_with_neutral_selection = [''] + list(columns)
        self.columns = columns
        self.df_list_ctrl = df_list_ctrl

        self.figure = Figure(facecolor="white", figsize=(1, 1))
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)

        chart_toolbar = NavigationToolbar2Wx(self.canvas)

        self.combo_box1 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)
        self.combo_box2 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)

        self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select)

        row_sizer = wx.BoxSizer(wx.HORIZONTAL)
        row_sizer.Add(self.combo_box1, 0, wx.ALL | wx.ALIGN_CENTER, 5)
        row_sizer.Add(self.combo_box2, 0, wx.ALL | wx.ALIGN_CENTER, 5)
        row_sizer.Add(chart_toolbar, 0, wx.ALL, 5)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, flag=wx.EXPAND, border=5)
        sizer.Add(row_sizer)
        self.SetSizer(sizer)
Exemplo n.º 29
0
    def OnInit(self, *args, **kw):
        wxInitAllImageHandlers()
        self.frame = wxFrame(None, -1, "PyScope")

        self.frame.fig = Figure((5, 4), 75)
        self.frame.canvas = FigureCanvasWx(self.frame, -1, self.frame.fig)
        self.frame.toolbar = NavigationToolbar2Wx(self.frame.canvas)
        self.frame.toolbar.Realize()

        # On Windows, default frame size behaviour is incorrect
        # you don't need this under Linux
        tw, th = self.frame.toolbar.GetSizeTuple()
        fw, fh = self.frame.canvas.GetSizeTuple()
        self.frame.toolbar.SetSize(wxSize(fw, th))

        # Create a figure manager to manage things
        self.frame.figmgr = FigureManager(self.frame.canvas, 1, self)
        # Now put all into a sizer
        sizer = wxBoxSizer(wxVERTICAL)
        # This way of adding to sizer allows resizing
        sizer.Add(self.frame.canvas, 1, wxLEFT | wxTOP | wxGROW)
        # Best to allow the toolbar to resize!
        sizer.Add(self.frame.toolbar, 0, wxGROW)
        self.frame.SetSizer(sizer)
        self.frame.Fit()
        EVT_TRIG(self, self.OnTrig)

        # finalize wx stuff
        self.frame.SetAutoLayout(true)
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True
Exemplo n.º 30
0
    def _create_canvas(self, parent):
        """ Create the MPL canvas. """
        # The panel lets us add additional controls.
        a = self.adapter
        fig = self.figure

        panel = wx.Panel(parent, -1, style=wx.CLIP_CHILDREN)
        sizer = wx.BoxSizer(wx.VERTICAL)
        panel.SetSizer(sizer)

        # matplotlib commands to create a canvas
        mpl_control = FigureCanvas(panel, -1, fig)
        toolbar = NavigationToolbar2Wx(mpl_control)

        sizer.Add(toolbar, 0, wx.EXPAND)
        sizer.Add(mpl_control, 1, wx.LEFT | wx.TOP | wx.GROW)

        if a.max_size:
            self.figure.canvas.SetMaxSize(a.max_size)
        if a.min_size:
            self.figure.canvas.SetMinSize((a.min_size))

        if a.padding:
            for side, pad in a.padding.items():
                setattr(self.figure.subplotpars, side, pad)

        return panel
Exemplo n.º 31
0
    def __init__(self):
        Frame.__init__(self, None, -1, "Test embedded wxFigure")

        self.fig = Figure((5, 4), 75)
        self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()

        # On Windows, default frame size behaviour is incorrect
        # you don't need this under Linux
        tw, th = self.toolbar.GetSizeTuple()
        fw, fh = self.canvas.GetSizeTuple()
        self.toolbar.SetSize(Size(fw, th))

        # Create a figure manager to manage things

        # Now put all into a sizer
        sizer = BoxSizer(VERTICAL)
        # This way of adding to sizer allows resizing
        sizer.Add(self.canvas, 1, LEFT | TOP | GROW)
        # Best to allow the toolbar to resize!
        sizer.Add(self.toolbar, 0, GROW)
        self.SetSizer(sizer)
        self.Fit()
        EVT_TIMER(self, TIMER_ID, self.onTimer)
Exemplo n.º 32
0
    def __init__(self, ):
        wx.Frame.__init__(self, None, -1, 'CanvasFrame', size=(550, 350))

        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        t = np.arange(0.0, 3.0, 0.01)
        s = np.sin(2 * np.pi * t)

        self.axes.plot(t, s)
        self.axes.set_xlabel('t')
        self.axes.set_ylabel('sin(t)')
        self.figure_canvas = FigureCanvas(self, -1, self.figure)

        # Note that event is a MplEvent
        self.figure_canvas.mpl_connect('motion_notify_event',
                                       self.UpdateStatusBar)
        self.figure_canvas.Bind(wx.EVT_ENTER_WINDOW, self.ChangeCursor)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.figure_canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

        self.statusBar = wx.StatusBar(self, -1)
        self.SetStatusBar(self.statusBar)

        self.toolbar = NavigationToolbar2Wx(self.figure_canvas)
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.toolbar.Show()
Exemplo n.º 33
0
    def __init__(self, viewPanel, overlayList, displayCtx, extraModes=None):
        """Create a ``PlotProfile``.

        :arg viewPanel:    A :class:`.PlotPanel` instance.

        :arg overlayList:  The :class:`.OverlayList` instance.

        :arg displayCtx:   The :class:`.DisplayContext` instance.

        :arg extraModes:   Extra modes to pass through to the
                           :class:`.Profile` constructor.
        """

        if extraModes is None:
            extraModes = []

        modes = ['panzoom'] + extraModes

        profiles.Profile.__init__(self, viewPanel, overlayList, displayCtx,
                                  modes)

        self.__canvas = viewPanel.getCanvas()
        self.__axis = viewPanel.getAxis()

        # Pan/zoom functionality is actually
        # implemented by the NavigationToolbar2Wx
        # class, but the toolbar is not actually
        # shown.
        self.__toolbar = NavigationToolbar2Wx(self.__canvas)
        self.__toolbar.Show(False)

        # This flag keeps track of
        # the toolbar pan state
        self.__panning = False
Exemplo n.º 34
0
    def __init__(self, title='', verb=1):
        wx.Frame.__init__(self, None, -1, title, size=(400, 300))
        self.verb = verb
        self.figure = Figure()
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

        # toolbar?
        # self.toolbar = NavigationToolbar2Wx(self.canvas)
        # self.toolbar.Realize()
        # self.sizer.Add(self.toolbar, 0, wx.BOTTOM | wx.EXPAND)
        # self.toolbar.update()

        # axis plotting info
        self.ax = None
        self.xmin = 1.0
        self.xmax = 0.0
        self.ymin = 1.0
        self.ymax = 0.0
        self.xlabel = ''
        self.ylabel = ''
        self.style = 'graph'

        self.images = []

        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.toolbar.update()
Exemplo n.º 35
0
    def __init__(self, title, mins, maxs, values, *args, **kw):
        super().__init__(*args, **kw)
        panel = wx.Panel(self)
        panel.SetBackgroundColour(wx.Colour("White"))

        self.fig = Figure((5, 4), 75)
        # Adjust the subplots region to leave some space for the sliders and
        # buttons
        self.fig.subplots_adjust(left=0.25, bottom=0.25)
        self.ax = self.fig.add_axes([0.1, 0.2, 0.85, 0.75])
        self.canvas = FigureCanvasWxAgg(panel, -1, self.fig)
        self.toolbar = NavigationToolbar2Wx(self.canvas)  # matplotlib toolbar
        self.toolbar.Realize()

        self.sliders = []
        mins = np.atleast_1d(mins).flatten()
        maxs = np.atleast_1d(maxs).flatten()
        values = np.array(values).flatten()
        for idx, (min_, max_, val, tit) in enumerate(
                zip(mins, maxs, values, title)):
            slider = CustomSlider(
                panel,
                val,
                min_,
                max_,
                title=tit,
                height=wx.ScreenDC().GetPPI()[0] * 0.6,
                pads=wx.ScreenDC().GetPPI()[0] * 0.1,
            )
            slider.idx = idx
            self.sliders.append(slider)
        # self.highlighter2 = CustomSlider(panel, 1, 1, 8)
        self.clb = wx.CheckListBox(
            panel, -1, (wx.ScreenDC().GetPPI()[0] * 2, -1), wx.DefaultSize, []
        )
        self.retrain = wx.Button(panel, -1, "Retrain")

        hsizer = wx.BoxSizer(wx.HORIZONTAL)
        rsizer = wx.BoxSizer(wx.VERTICAL)
        # This way of adding to sizer allows resizing
        rsizer.Add(self.canvas, 1, wx.EXPAND)
        for slider in self.sliders:
            # | wx.LEFT | wx.RIGHT, 20)
            rsizer.Add(slider, 0, wx.EXPAND | wx.RIGHT)
        rsizer.Add(self.toolbar, 0, wx.GROW | wx.RIGHT)

        lsizer = wx.BoxSizer(wx.VERTICAL)
        lsizer.Add(self.clb, 1, wx.EXPAND)
        lsizer.Add(self.retrain, 0)

        hsizer.Add(lsizer, 0, wx.EXPAND)
        hsizer.Add(rsizer, 1, wx.EXPAND)

        self.Bind(wx.EVT_LISTBOX, self.OnListBox)
        self.Bind(wx.EVT_CHECKLISTBOX, self.OnCheckListBox)
        self.Bind(wx.EVT_BUTTON, self.OnRetrain)
        panel.SetSizer(hsizer)
        self.Layout()
        self.Centre()
Exemplo n.º 36
0
 def add_toolbar(self):
     self.toolbar = NavigationToolbar(self.canvas)
     self.toolbar.Realize()
     # By adding toolbar in sizer, we are able to put it at the bottom
     # of the frame - so appearance is closer to GTK version.
     self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
     # update the axes menu on the toolbar
     self.toolbar.update()
Exemplo n.º 37
0
 def _init_canvas(self):
     self._c = 0
     #self._fig.tight_layout()#rect=[-0.03, 0.02, 1.03, 1])
     self._canvas = FigureCanvasWxAgg(self._panel, -1, self._fig)
     self._toolbar = NavigationToolbar2Wx(self._canvas)
     #self._cursor = Cursor(self._ax, useblit=True, color='red',
     #                      linewidth=0.5)
     self._toolbar.Realize()
 def add_toolbar(self):
     self.toolbar = NavigationToolbar2Wx(self.canvas)
     self.toolbar.Realize()
     # By adding toolbar in sizer, we are able to put it at the bottom
     # of the frame - so appearance is closer to GTK version.
     self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
     # update the axes menu on the toolbar
     self.toolbar.update()
Exemplo n.º 39
0
 def pan(self, *args):
     try:
         #if self.VERSION[0]=='2' or self.VERSION[0]=='1':
         isPan = self._active == 'PAN'
     except:
         try:
             from matplotlib.backend_bases import _Mode
             isPan = self.mode == _Mode.PAN
         except:
             raise Exception(
                 'Pan not found, report a pyDatView bug, with matplotlib version.'
             )
     if isPan:
         NavigationToolbar2Wx.pan(self, *args)
         self.zoom()
     else:
         NavigationToolbar2Wx.pan(self, *args)
Exemplo n.º 40
0
	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()
Exemplo n.º 41
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)
Exemplo n.º 42
0
    def __init__(self, parent, id = -1, dpi = None, data = None, **kwargs):
        # TODO: inherit directly from Canvas --- it is after all a panel.
        self.data = data

        # Set up the panel parameters
        #style = wx.NO_FULL_REPAINT_ON_RESIZE
        wx.Panel.__init__(self, parent, id = id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi,figsize=(1,1))
        self.canvas = Canvas(self, -1, self.figure)
        self.toolbar = Toolbar(self.canvas)
        self.toolbar.set_status_bar(parent.GetStatusBar())
        self.toolbar.Realize()
        self.canvas.mpl_connect('resize_event',self.onResize)
        self.canvas.mpl_connect('scroll_event',self.onWheel)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas,1,wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)
Exemplo n.º 43
0
 def home(self, *args):
     NavigationToolbar2Wx.home(self, *args)
     self._autoScale = True
Exemplo n.º 44
0
 def press_zoom(self, *args):
     NavigationToolbar2Wx.press_zoom(self, *args)
     self._autoScale = False
Exemplo n.º 45
0
 def back(self, *args):
     NavigationToolbar2Wx.back(self, *args)
     self._autoScale = False
Exemplo n.º 46
0
 def forward(self, *args):
     NavigationToolbar2Wx.forward(self, *args)
     self._autoScale = False
Exemplo n.º 47
0
class Plotter(wx.Panel):
    def __init__(self, parent, id = -1, dpi = None, data = None, **kwargs):
        # TODO: inherit directly from Canvas --- it is after all a panel.
        self.data = data

        # Set up the panel parameters
        #style = wx.NO_FULL_REPAINT_ON_RESIZE
        wx.Panel.__init__(self, parent, id = id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi,figsize=(1,1))
        self.canvas = Canvas(self, -1, self.figure)
        self.toolbar = Toolbar(self.canvas)
        self.toolbar.set_status_bar(parent.GetStatusBar())
        self.toolbar.Realize()
        self.canvas.mpl_connect('resize_event',self.onResize)
        self.canvas.mpl_connect('scroll_event',self.onWheel)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas,1,wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)

    def onResize(self,event):
        self.data.plot(self.figure)

    def onWheel(self, event):
        """
        Process mouse wheel as zoom events
        """
        ax = event.inaxes
        step = event.step

        # Icky hardcoding of colorbar zoom.
        if False and ax == self.coloraxes:
            # rescale colormap: the axes are already scaled to 0..1,
            # so use bal instead of pt for centering
            lo,hi = self.colormapper.get_clim()
            lo,hi = _rescale(lo,hi,step,bal=event.ydata,scale=self.vscale)
            self.colormapper.set_clim(lo,hi)
        elif ax != None:
            # Event occurred inside a plotting area
            lo,hi = ax.get_xlim()
            lo,hi = _rescale(lo,hi,step,pt=event.xdata)
            ax.set_xlim((lo,hi))

            lo,hi = ax.get_ylim()
            lo,hi = _rescale(lo,hi,step,pt=event.ydata)
            ax.set_ylim((lo,hi))
        else:
            # Check if zoom happens in the axes
            xdata,ydata = None,None
            x,y = event.x,event.y
            for ax in self.figure.axes:
                insidex,_ = ax.xaxis.contains(event)
                if insidex:
                    xdata,_ = _invert(ax,x,y)
                    #print "xaxis",x,"->",xdata
                insidey,_ = ax.yaxis.contains(event)
                if insidey:
                    _,ydata = _invert(ax,x,y)
                    #print "yaxis",y,"->",ydata
            if xdata is not None:
                lo,hi = ax.get_xlim()
                lo,hi = _rescale(lo,hi,step,bal=xdata)
                ax.set_xlim((lo,hi))
            if ydata is not None:
                lo,hi = ax.get_ylim()
                lo,hi = _rescale(lo,hi,step,bal=ydata)
                ax.set_ylim((lo,hi))

        self.canvas.draw()
Exemplo n.º 48
0
	def zoom(self,*args):
		# overriding zoom method
		self.ToggleTool(self.IdConnect,False)
		if callable(self._disconnect): self._disconnect()
		NavigationToolbar2Wx.zoom(self,*args)
Exemplo n.º 49
0
	def forward(self,*args):
		# overriding forward method
		NavigationToolbar2Wx.forward(self,*args)
		if callable(self._getlim): self._getlim()
Exemplo n.º 50
0
	def back(self,*args):
		# overriding back method
		NavigationToolbar2Wx.back(self,*args)
		if callable(self._getlim): self._getlim()
Exemplo n.º 51
0
	def home(self,*args):
		# overriding home method
		NavigationToolbar2Wx.home(self,*args)
		if callable(self._getlim): self._getlim()