def __init__(self, graph_canvas): super(BioPepaToolbar, self).__init__(graph_canvas) cwd = os.getcwd() #WorldState.Instance() = WorldState.Instance() if (platform.system() == "Linux"): #save self.DeleteToolByPos(8) #subplots self.DeleteToolByPos(7) self.AddSimpleTool(self.ON_CUSTOM_ENLARGE, _load_bitmap(cwd + '/icons/full_screen.xpm'), 'Enlarge Graph', 'Enlarge Graph') wx.EVT_TOOL(self, self.ON_CUSTOM_ENLARGE, self._on_custom_enlarge) self.AddSimpleTool(self.ANNOTATE_ARROW, _load_bitmap(cwd + '/icons/arrow.xpm'), 'Annotate with an Arrow', 'Annotate with an Arrow') wx.EVT_TOOL(self, self.ANNOTATE_ARROW, self._on_custom_annotate_arrow) self.AddSimpleTool(self.ANNOTATE_TEXT, _load_bitmap(cwd + '/icons/text.xpm'), 'Annotate with Text', 'Annotate with Text') wx.EVT_TOOL(self, self.ANNOTATE_TEXT, self._on_custom_annotate_text) self.AddSimpleTool(self.ANNOTATE_TEXT_ARROW, _load_bitmap(cwd + '/icons/text_arrow.xpm'), 'Annotate with an Arrow and Text', 'Annotate with an Arrow and Text') wx.EVT_TOOL(self, self.ANNOTATE_TEXT_ARROW, self._on_custom_annotate_text_arrow) self.AddSimpleTool(self.ANNOTATE_CIRCLE, _load_bitmap(cwd + '/icons/circle.xpm'), 'Annotate with a circle', 'Annotate with a circle') wx.EVT_TOOL(self, self.ANNOTATE_CIRCLE, self._on_custom_annotate_circle)
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__init__(self, canvas) # for simplicity I'm going to reuse a bitmap from wx, you'll # probably want to add your own. self.ON_PREVIOUS = wx.NewId() self.ON_NEXT = wx.NewId() self.ON_LISTE = wx.NewId() self.AddSimpleTool(self.ON_PREVIOUS, _load_bitmap('stock_left.xpm'), 'Courbe precedente', 'Courbe precedente') self.AddSimpleTool(self.ON_NEXT, _load_bitmap('stock_right.xpm'), 'Courbe suivante', 'Courbe suivante') self.AddSimpleTool(self.ON_LISTE, _load_bitmap('stock_up.xpm'), 'Liste par date', 'Liste par date') wx.EVT_TOOL(self, self.ON_PREVIOUS, self._on_previous) wx.EVT_TOOL(self, self.ON_NEXT, self._on_next) wx.EVT_TOOL(self, self.ON_LISTE, self._on_liste) self.diryears = datayears print self.diryears #keys_sort = self.diryears.keys() #keys_sort.sort() #self.premyear = self.diryears[keys_sort[0]] #self.premyear = datayears[0] self.premyear = 2005 #self.deryear = self.diryears[keys_sort[len(keys_sort)-1]] #self.deryear = datayears[len(datayears)-1] self.deryear = 2012 self.njour = self.premyear self.compteuryear = 0 self.prepdata() self.draw()
def __init__(self, frame_object): """ Constructor for toolbar object @type self: Toolbar @type frame_object: MainFrame the frame object that the toolbar will be in/part of @rtype: None """ NavigationToolbar2WxAgg.__init__(self, frame_object.canvas) self.frame_object = frame_object # Deleting unwanted icons in standard toolbar self.DeleteToolByPos(8) self.DeleteToolByPos(1) self.DeleteToolByPos(1) self.InsertSeparator(6) self.InsertSeparator(6) self.AddSimpleTool(self.ON_PREVIOUS, _load_bitmap('back.png'), 'Previous Run', 'Activate custom control') wx.EVT_TOOL(self, self.ON_PREVIOUS, self._on_previous) self.AddSimpleTool(self.ON_NEXT, _load_bitmap('forward.png'), 'Next Run', 'Activate custom control') wx.EVT_TOOL(self, self.ON_NEXT, self._on_next) self.AddSimpleTool(self.ON_EXTRACT, _load_bitmap('filesave.png'), 'Save to Excel', 'Activate custom control') wx.EVT_TOOL(self, self.ON_EXTRACT, self._on_extract)
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__init__(self, canvas) self.canvas = canvas #setattr(self,'datajours', getattr(canvas.GetParent(),'datajours')) for name in dir(canvas.GetParent()): #print "name= :", name if name in ["datayear","vg0","vg0_2","year","nyear","month","day","nday","pm10","aot1020"]: setattr(self,name,getattr(canvas.GetParent(),name)) # for simplicity I'm going to reuse a bitmap from wx, you'll # probably want to add your own. self.ON_PREVIOUS = wx.NewId() self.ON_NEXT = wx.NewId() self.ON_LISTE = wx.NewId() self.AddSimpleTool(self.ON_PREVIOUS, _load_bitmap('stock_left.xpm'), 'Courbe precedente', 'Courbe precedente') self.AddSimpleTool(self.ON_NEXT, _load_bitmap('stock_right.xpm'), 'Courbe suivante', 'Courbe suivante') self.AddSimpleTool(self.ON_LISTE, _load_bitmap('stock_up.xpm'), 'Liste par date', 'Liste par date') wx.EVT_TOOL(self, self.ON_PREVIOUS, self._on_previous) wx.EVT_TOOL(self, self.ON_NEXT, self._on_next) wx.EVT_TOOL(self, self.ON_LISTE, self._on_liste) self.inityear() self.draw()
def _init_toolbar(self): self._parent = self.canvas.GetParent() self._NTB2_HOME = wx.NewId() self._NTB2_BACK = wx.NewId() self._NTB2_FORWARD = wx.NewId() self._NTB2_PAN = wx.NewId() self._NTB2_ZOOM = wx.NewId() self._NTB2_SAVE = wx.NewId() self._NTB2_PRINT = wx.NewId() self._NTB2_RESET = wx.NewId() # for mpl 1.2+ compatibility self.wx_ids = {} self.wx_ids['Back'] = self._NTB2_BACK self.wx_ids['Forward'] = self._NTB2_FORWARD self.wx_ids['Pan'] = self._NTB2_PAN self.wx_ids['Zoom'] = self._NTB2_ZOOM self.SetToolBitmapSize(wx.Size(24, 24)) context_tip = 'Graph Menu: \n' context_tip += ' For more menu options, \n' context_tip += ' right-click the data symbols.' context = wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_TOOLBAR) self.AddSimpleTool(self._NTB2_HOME, context, context_tip, context_tip) self.InsertSeparator(1) self.AddSimpleTool(self._NTB2_BACK, _load_bitmap('back.png'), 'Back', 'Back navigation view') self.AddSimpleTool(self._NTB2_FORWARD, _load_bitmap('forward.png'), 'Forward', 'Forward navigation view') # todo: get new bitmap self.AddCheckTool(self._NTB2_PAN, _load_bitmap('move.png'), shortHelp='Pan', longHelp='Pan with left, zoom with right') self.AddCheckTool(self._NTB2_ZOOM, _load_bitmap('zoom_to_rect.png'), shortHelp='Zoom', longHelp='Zoom to rectangle') self.AddSeparator() self.AddSimpleTool(self._NTB2_SAVE, _load_bitmap('filesave.png'), 'Save', 'Save plot contents to file') print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR) self.AddSimpleTool(self._NTB2_PRINT, print_bmp, 'Print', 'Print plot') reset_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR) self.AddSimpleTool(self._NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range') bind(self, wx.EVT_TOOL, self.context_menu, id=self._NTB2_HOME) bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK) bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) bind(self, wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) bind(self, wx.EVT_TOOL, self.save_figure, id=self._NTB2_SAVE) bind(self, wx.EVT_TOOL, self.print_figure, id=self._NTB2_PRINT) bind(self, wx.EVT_TOOL, self.home, id=self._NTB2_RESET) self.Realize()
def _init_toolbar(self): self._parent = self.canvas.GetParent() # for mpl 1.2+ compatibility self.wx_ids = {} self.wx_ids['Back'] = self._NTB2_BACK self.wx_ids['Forward'] = self._NTB2_FORWARD self.wx_ids['Pan'] = self._NTB2_PAN self.wx_ids['Zoom'] = self._NTB2_ZOOM self.SetToolBitmapSize(wx.Size(24, 24)) context_tip = 'Graph Menu: \n' context_tip += ' For more menu options, \n' context_tip += ' right-click the data symbols.' context = wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_TOOLBAR) self.AddSimpleTool(self._NTB2_HOME, context, context_tip, context_tip) self.InsertSeparator(1) self.AddSimpleTool(self._NTB2_BACK, _load_bitmap('back.png'), 'Back', 'Back navigation view') self.AddSimpleTool(self._NTB2_FORWARD, _load_bitmap('forward.png'), 'Forward', 'Forward navigation view') # todo: get new bitmap self.AddCheckTool(self._NTB2_PAN, _load_bitmap('move.png'), shortHelp='Pan', longHelp='Pan with left, zoom with right') self.AddCheckTool(self._NTB2_ZOOM, _load_bitmap('zoom_to_rect.png'), shortHelp='Zoom', longHelp='Zoom to rectangle') self.AddSeparator() self.AddSimpleTool(self._NTB2_SAVE, _load_bitmap('filesave.png'), 'Save', 'Save plot contents to file') print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR) self.AddSimpleTool(self._NTB2_PRINT, print_bmp, 'Print', 'Print plot') reset_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR) self.AddSimpleTool(self._NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range') bind(self, wx.EVT_TOOL, self.context_menu, id=self._NTB2_HOME) bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK) bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) bind(self, wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) bind(self, wx.EVT_TOOL, self.save_figure, id=self._NTB2_SAVE) bind(self, wx.EVT_TOOL, self.print_figure, id=self._NTB2_PRINT) bind(self, wx.EVT_TOOL, self.home, id=self._NTB2_RESET) self.Realize()
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)
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__init__(self, canvas) # for simplicity I'm going to reuse a bitmap from wx, you'll # probably want to add your own. if 'phoenix' in wx.PlatformInfo: self.AddTool(self.ON_CUSTOM, 'Click me', _load_bitmap('back.png'), 'Activate custom contol') self.Bind(wx.EVT_TOOL, self._on_custom, id=self.ON_CUSTOM) else: self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('back.png'), 'Click me', 'Activate custom contol') self.Bind(wx.EVT_TOOL, self._on_custom, id=self.ON_CUSTOM)
def __init__(self, canvas, cankill): NavigationToolbar.__init__(self, canvas) # for simplicity I'm going to reuse a bitmap from wx, you'll # probably want to add your own. if 'phoenix' in wx.PlatformInfo: self.AddTool(self.ON_CUSTOM, 'Click me', _load_bitmap('back.png'), 'Activate custom contol') self.Bind(wx.EVT_TOOL, self._on_custom, id=self.ON_CUSTOM) else: self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('back.png'), 'Click me', 'Activate custom contol') self.Bind(wx.EVT_TOOL, self._on_custom, id=self.ON_CUSTOM)
def __init__(self, parent, canvas, cankill, OnUndo): self.cid = 0 self.circles = [] self.point3 = array([]) self.point2 = array([]) self.lines = [] self.hist = ["start"] NavigationToolbar2WxAgg.__init__(self, canvas) self.statbar = None self.OnUndo = OnUndo self.parent = parent if self.parent.mpl_old: self.wx_ids = {"Pan": self._NTB2_PAN, "Zoom": self._NTB2_ZOOM} self.AddSeparator() self.AddCheckTool( self.ON_MARKRINGS, _load_bitmap(os.path.join(self.parent.iconspath, "3_point.png")), shortHelp="Mark Rings", longHelp="mark 3-points on a ring to find center", ) wx.EVT_TOOL(self, self.ON_MARKRINGS, self._on_markrings) self.AddCheckTool( self.ON_MARKSPOTS, _load_bitmap(os.path.join(self.parent.iconspath, "2_point.png")), shortHelp="Mark Spots", longHelp="mark 2 spots to measure distance", ) wx.EVT_TOOL(self, self.ON_MARKSPOTS, self._on_markspots) self.AddSeparator() self.AddSimpleTool( self.ON_INTEGRATE, _load_bitmap(os.path.join(self.parent.iconspath, "profile.png")), "Profile", "Extract profiles from the diffraction pattern", ) wx.EVT_TOOL(self, self.ON_INTEGRATE, self._on_integrate) undo_ico = wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR, (16, 16)) self.AddSimpleTool(self.ON_UNDO, undo_ico, "Undo", "Undo last point or ring") wx.EVT_TOOL(self, self.ON_UNDO, self._on_undo)
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__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, main): self.main = main navId = wx.NewId() NavigationToolbar2WxAgg.__init__(self, canvas) self.AddSimpleTool(navId, _load_bitmap("subplots.png"), "Range", "Set plot range") wx.EVT_TOOL(self, navId, self.on_range)
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__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') wx.EVT_TOOL(self, self.ON_CUSTOM, self._on_custom)
def __init__(self, canvas, main): self.main = main navId = wx.NewId() NavigationToolbar2WxAgg.__init__(self, canvas) self.AddSimpleTool(navId, _load_bitmap('subplots.png'), 'Range', 'Set plot range') wx.EVT_TOOL(self, navId, self.on_range)
def __init__(self, canvas, cankill): NavigationToolbar.__init__(self, canvas) # for simplicity I'm going to reuse a bitmap from wx, you'll # probably want to add your own. tool = self.AddTool(wx.ID_ANY, 'Click me', _load_bitmap('back.png'), 'Activate custom contol') self.Bind(wx.EVT_TOOL, self._on_custom, id=tool.GetId())
def SetToolBar(self, toolbar): from matplotlib.backends.backend_wx import _load_bitmap toolbar.Hide() tb = self.CreateToolBar((wx.TB_HORIZONTAL|wx.TB_TEXT)) _NTB2_HOME = wx.NewId() _NTB2_BACK = wx.NewId() _NTB2_FORWARD = wx.NewId() _NTB2_PAN = wx.NewId() _NTB2_ZOOM = wx.NewId() _NTB2_SAVE = wx.NewId() _NTB2_SUBPLOT = wx.NewId() tb.AddSimpleTool(_NTB2_HOME, _load_bitmap('home.png'), 'Home', 'Reset original view') tb.AddSimpleTool(_NTB2_BACK, _load_bitmap('back.png'), 'Back', 'Back navigation view') tb.AddSimpleTool(_NTB2_FORWARD, _load_bitmap('forward.png'), 'Forward', 'Forward navigation view') tb.AddCheckTool(_NTB2_PAN, _load_bitmap('move.png'), shortHelp='Pan', longHelp='Pan with left, zoom with right') tb.AddCheckTool(_NTB2_ZOOM, _load_bitmap('zoom_to_rect.png'), shortHelp='Zoom', longHelp='Zoom to rectangle') tb.AddSeparator() tb.AddSimpleTool(_NTB2_SUBPLOT, _load_bitmap('subplots.png'), 'Configure subplots', 'Configure subplot parameters') tb.AddSimpleTool(_NTB2_SAVE, _load_bitmap('filesave.png'), 'Save', 'Save plot contents to file') self.Bind(wx.EVT_TOOL, toolbar.home, id=_NTB2_HOME) self.Bind(wx.EVT_TOOL, toolbar.forward, id=_NTB2_FORWARD) self.Bind(wx.EVT_TOOL, toolbar.back, id=_NTB2_BACK) self.Bind(wx.EVT_TOOL, toolbar.zoom, id=_NTB2_ZOOM) self.Bind(wx.EVT_TOOL, toolbar.pan, id=_NTB2_PAN) self.Bind(wx.EVT_TOOL, toolbar.configure_subplots, id=_NTB2_SUBPLOT) self.Bind(wx.EVT_TOOL, toolbar.save_figure, id=_NTB2_SAVE) tb.Realize()
def __init__(self, canvas, chart, pan_tool=True, pan_percentage=0.5): """ Constructor :param canvas: :param chart: :param pan_tool: :param pan_percentage: :return: """ NavigationToolbar.__init__(self, canvas) self.chart = chart self.pan_percentage = pan_percentage # add new toolbar buttons self.AddSimpleTool(self.ON_CUSTOM_DPLOT, _load_bitmap('qt4_editor_options.png'), 'Save XY', 'Save XY to csv.') self.AddSimpleTool(self.ON_CUSTOM_FIGURE_SETTING, load_bitmap('hand.xpm'), 'Open figure setting', 'Open figure setting.') # wx.EVT_TOOL(self, self.ON_CUSTOM_FIGURE_SETTING, self._on_custom_figure_setting) # self.AddSimpleTool(self.ON_CUSTOM_DPLOT, # wx.Bitmap(ICONS['dplot']), # 'DPLOT', # 'DPLOT') self.AddSeparator() self.AddStretchableSpace() if pan_tool: self.AddSimpleTool(self.ON_CUSTOM_LEFT, load_bitmap('stock_left.xpm'), 'Pan to the left', 'Pan graph to the left') self.Bind(wx.EVT_TOOL, self._on_custom_pan_left, None, self.ON_CUSTOM_LEFT) self.AddSimpleTool(self.ON_CUSTOM_RIGHT, load_bitmap('stock_right.xpm'), 'Pan to the right', 'Pan graph to the right') self.Bind(wx.EVT_TOOL, self._on_custom_pan_right, None, self.ON_CUSTOM_RIGHT) self.AddSimpleTool(self.ON_CUSTOM_UP, load_bitmap('stock_up.xpm'), 'Pan to the top', 'Pan graph to the top') self.Bind(wx.EVT_TOOL, self._on_custom_pan_up, None, self.ON_CUSTOM_UP) self.AddSimpleTool(self.ON_CUSTOM_DOWN, load_bitmap('stock_down.xpm'), 'Pan to the bottom', 'Pan graph to the bottom') self.Bind(wx.EVT_TOOL, self._on_custom_pan_down, None, self.ON_CUSTOM_DOWN)
def __init__(self, plot_canvas): NavigationToolbar2WxAgg.__init__(self, plot_canvas) #Delete home tool #TODO add after history clear is added at each plot_refresh self.DeleteToolByPos(0) #add refresh plot button self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('stock_refresh.xpm'), 'Click me', 'Activate custom control') wx.EVT_TOOL(self, self.ON_CUSTOM, self._on_custom)
def _init_toolbar(self, *args): NavigationToolbar2Wx._init_toolbar(self, *args) self.AddSimpleTool(_NTB_PLAY, _load_bitmap('forward.xpm'), 'Play', 'Start playing') self.AddSimpleTool(_NTB_LEFT, _load_bitmap('stock_left.xpm'), 'Left', 'Jump one screen to the left') self.AddSimpleTool(_NTB_RIGHT, _load_bitmap('stock_right.xpm'), 'Right', 'Jump one screen to the right') self.AddSimpleTool(_NTB_DOWN, _load_bitmap('stock_down.xpm'), 'Down', 'Go down one channel') self.AddSimpleTool(_NTB_UP, _load_bitmap('stock_up.xpm'), 'Up', 'Go up one channel') self.Bind(EVT_REDRAW, self._on_redraw) bind(self, wx.EVT_TOOL, self._on_play, id=_NTB_PLAY) bind(self, wx.EVT_TOOL, self._on_left, id=_NTB_LEFT) bind(self, wx.EVT_TOOL, self._on_right, id=_NTB_RIGHT) bind(self, wx.EVT_TOOL, self._on_down, id=_NTB_DOWN) bind(self, wx.EVT_TOOL, self._on_up, id=_NTB_UP)
def __init__(self, plotCanvas): # create the default toolbar NavigationToolbar.__init__(self, plotCanvas) # find where icons are located path = os.path.dirname(__file__) icon_file = os.path.join(path, 'data-export-icon.png') self.AddSimpleTool(self.EXPORT_DATA, _load_bitmap(icon_file), 'Export data', 'Export current data to file') wx.EVT_TOOL(self, self.EXPORT_DATA, self._on_export_data)
def __init__(self, canvas, main): self.main = main navId = wx.NewId() NavigationToolbar2WxAgg.__init__(self, canvas) # self.DeleteTool(self.wx_ids['Back']) # self.DeleteTool(self.wx_ids['Forward']) # self.DeleteTool(self.wx_ids['Subplots']) self.AddSimpleTool(navId, _load_bitmap("hand.png"), "Range", "Set plot range") wx.EVT_TOOL(self, navId, self.on_range)
def __init__(self, canvas): NavToolbar.__init__(self, canvas) # Get rid of the configure subplots button if hasattr(self, 'wx_ids'): self.DeleteTool(self.wx_ids['Subplots']) else: self.DeleteToolByPos(6) # Add new buttons self.AddSimpleTool(wx.ID_PRINT, wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR), 'Print', 'print graph') self.AddSimpleTool(DATA_SAVE_ID, _load_bitmap('stock_save_as.xpm'), 'Export plot data', 'Export plot data to file') self.AddSeparator() self.AddSimpleTool(wx.ID_CLOSE, _load_bitmap('stock_close.xpm'), 'Close window', 'Close window') return
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()
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__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') #self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('stock_left.xpm'), #'Click me', 'Save to PDF format') wx.EVT_TOOL(self, self.ON_CUSTOM, self._on_custom) #wx.EVT_TOOL(self, self.ON_SAVETOPDF, self._on_savetopdf) self.canvas = canvas
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__init__(self, canvas) self.canvas = canvas #setattr(self,'datajours', getattr(canvas.GetParent(),'datajours')) for name in dir(canvas.GetParent()): #print "name= :", name if name in ["nyear","Config","datajours","vg0","year","month","day","nday","heure","pm10","aot1020"]: setattr(self,name,getattr(canvas.GetParent(),name)) # for simplicity I'm going to reuse a bitmap from wx, you'll # probably want to add your own. self.ON_PREVIOUS = wx.NewId() self.ON_NEXT = wx.NewId() self.ON_LISTE = wx.NewId() self.AddSimpleTool(self.ON_PREVIOUS, _load_bitmap('stock_left.xpm'), 'Courbe precedente', 'Courbe precedente') self.AddSimpleTool(self.ON_NEXT, _load_bitmap('stock_right.xpm'), 'Courbe suivante', 'Courbe suivante') self.AddSimpleTool(self.ON_LISTE, _load_bitmap('stock_up.xpm'), 'Liste par date', 'Liste par date') wx.EVT_TOOL(self, self.ON_PREVIOUS, self._on_previous) wx.EVT_TOOL(self, self.ON_NEXT, self._on_next) wx.EVT_TOOL(self, self.ON_LISTE, self._on_liste) cid = self.canvas.mpl_connect('button_press_event', self.onclick) cid = self.canvas.mpl_connect('key_press_event', self.onkey) import MySQLdb #self.db = MySQLdb.connect("calamar.univ-ag.fr","dbmeteodb","dbmeteodb","dbmeteodb") # localhost, alias for 127.0.0.1(default in mysql), marked in c:\windows\system32\drivers\etc # "127.0.0.1" works too, localhost self.db = MySQLdb.connect(host="localhost",user="******",passwd="dbmeteodb",db="dbmeteodb") self.cursor = self.db.cursor() self.initjour() self.draw()
def _init_toolbar(self): self._parent = self.canvas.GetParent() _NTB2_HOME = wx.NewId() self._NTB2_BACK = wx.NewId() self._NTB2_FORWARD = wx.NewId() self._NTB2_PAN = wx.NewId() self._NTB2_ZOOM = wx.NewId() _NTB2_SAVE = wx.NewId() _NTB2_SUBPLOT = wx.NewId() self.SetToolBitmapSize(wx.Size(16, 16)) self.AddSimpleTool(_NTB2_HOME, 'Home', _load_bitmap('home.png'), 'Reset original view') self.AddSimpleTool(self._NTB2_BACK, 'Back', _load_bitmap('back.png'), 'Back navigation view') self.AddSimpleTool(self._NTB2_FORWARD, 'Forward', _load_bitmap('forward.png'), 'Forward navigation view') # todo: get new bitmap self.AddCheckTool(self._NTB2_PAN, 'Pan', _load_bitmap('move.png'), _load_bitmap('move.png'), long_help_string='Pan with left, zoom with right') self.AddCheckTool(self._NTB2_ZOOM, 'Zoom', _load_bitmap('zoom_to_rect.png'), _load_bitmap('zoom_to_rect.png'), short_help_string='Zoom', long_help_string='Zoom to rectangle') self.AddSeparator() #self.AddSimpleTool(_NTB2_SUBPLOT, 'Configure subplots', _load_bitmap('subplots.png'), # 'Configure subplot parameters') self.AddSimpleTool(_NTB2_SAVE, 'Save', _load_bitmap('filesave.png'), 'Save plot contents to file') self.wind.Bind(wx.EVT_TOOL, self.home, id=_NTB2_HOME) self.wind.Bind(wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) self.wind.Bind(wx.EVT_TOOL, self.back, id=self._NTB2_BACK) self.wind.Bind(wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) self.wind.Bind(wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) #self.wind.Bind(wx.EVT_TOOL, self.configure_subplot, id=_NTB2_SUBPLOT) self.wind.Bind(wx.EVT_TOOL, self.save, id=_NTB2_SAVE) self.Realize()
def __init__(self, parent, canvas, cankill): NavigationToolbar2WxAgg.__init__(self, canvas) self.parent = parent if self.parent.mpl_old: self.wx_ids = {'Pan' : self._NTB2_PAN,'Zoom': self._NTB2_ZOOM} self.AddSeparator() self.AddCheckTool(self.ON_LABELPEAKS, _load_bitmap(os.path.join(self.parent.parent.iconspath, 'profile_label.png')), shortHelp= 'Label Peaks',longHelp= 'Click on a peak to label the d-spacing') self.AddSeparator() wx.EVT_TOOL(self, self.ON_LABELPEAKS, self._on_labelpeaks) self.AddSimpleTool(self.ON_CLEAR, _load_bitmap(os.path.join(self.parent.parent.iconspath, 'profile_good.png')), 'Clear Profiles', 'Clear all except the last profile') wx.EVT_TOOL(self, self.ON_CLEAR, self._on_clear) undo_ico = wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR, (16,16)) self.AddSimpleTool(self.ON_UNDO, undo_ico, 'Undo', 'Go back to the previous profile') wx.EVT_TOOL(self, self.ON_UNDO, self._on_undo)
def __init__(self, canvas, cankill): if wx.Platform != '__WXMAC__': NavToolbar.__init__(self, canvas) else: _realizer = self.Realize def f(): pass self.Realize = f NavToolbar.__init__(self, canvas) self.Realize = _realizer # Get rid of the configure subplots button self.DeleteToolByPos(6) # Add new buttons self.AddSimpleTool(wx.ID_PRINT, wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR), 'Print', 'print graph') self.AddSimpleTool(DATA_SAVE_ID, _load_bitmap('stock_save_as.xpm'), 'Export plot data', 'Export plot data to file') self.AddSeparator() self.AddSimpleTool(wx.ID_CLOSE, _load_bitmap('stock_close.xpm'), 'Close window', 'Close window')
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__init__(self, canvas) # for simplicity I'm going to reuse a bitmap from wx, you'll # probably want to add your own. self.ON_PREVIOUS = wx.NewId() self.ON_NEXT = wx.NewId() self.ON_LISTE = wx.NewId() self.AddSimpleTool(self.ON_PREVIOUS, _load_bitmap('stock_left.xpm'), 'Courbe precedente', 'Courbe precedente') self.AddSimpleTool(self.ON_NEXT, _load_bitmap('stock_right.xpm'), 'Courbe suivante', 'Courbe suivante') self.AddSimpleTool(self.ON_LISTE, _load_bitmap('stock_up.xpm'), 'Liste par date', 'Liste par date') wx.EVT_TOOL(self, self.ON_PREVIOUS, self._on_previous) wx.EVT_TOOL(self, self.ON_NEXT, self._on_next) wx.EVT_TOOL(self, self.ON_LISTE, self._on_liste) self.dirjours ={} for njour in list(datajours): # pour retrouver le jour à partir de la date en clair #self.dirjours[string.strip(datefromday(2005,jour).getString())] = jour self.dirjours[self.get_jour_en_clair(njour)] = njour print self.dirjours keys_sort = self.dirjours.keys() keys_sort.sort() #self.premjour = self.dirjours[keys_sort[0]] self.premjour = datajours[0] #self.derjour = self.dirjours[keys_sort[len(keys_sort)-1]] self.derjour = datajours[len(datajours)-1] self.njour = self.premjour self.compteurjour = 0 self.prepdata() self.draw()
def SetToolBar(self, toolbar): from matplotlib.backends.backend_wx import _load_bitmap toolbar.Hide() tb = self.CreateToolBar((wx.TB_HORIZONTAL | wx.TB_TEXT)) _NTB2_HOME = wx.NewId() _NTB2_BACK = wx.NewId() _NTB2_FORWARD = wx.NewId() _NTB2_PAN = wx.NewId() _NTB2_ZOOM = wx.NewId() _NTB2_SAVE = wx.NewId() _NTB2_SUBPLOT = wx.NewId() tb.AddTool(_NTB2_HOME, "", _load_bitmap('home.png'), 'Home') tb.AddTool(_NTB2_BACK, "", _load_bitmap('back.png'), 'Back') tb.AddTool(_NTB2_FORWARD, "", _load_bitmap('forward.png'), 'Forward') tb.AddCheckTool(_NTB2_PAN, "", _load_bitmap('move.png'), shortHelp='Pan', longHelp='Pan with left, zoom with right') tb.AddCheckTool(_NTB2_ZOOM, "", _load_bitmap('zoom_to_rect.png'), shortHelp='Zoom', longHelp='Zoom to rectangle') tb.AddSeparator() tb.AddTool(_NTB2_SUBPLOT, "", _load_bitmap('subplots.png'), 'Configure subplots') tb.AddTool(_NTB2_SAVE, "", _load_bitmap('filesave.png'), 'Save plot') def on_toggle_pan(evt): tb.ToggleTool(_NTB2_ZOOM, False) evt.Skip() def on_toggle_zoom(evt): tb.ToggleTool(_NTB2_PAN, False) evt.Skip() self.Bind(wx.EVT_TOOL, toolbar.home, id=_NTB2_HOME) self.Bind(wx.EVT_TOOL, toolbar.forward, id=_NTB2_FORWARD) self.Bind(wx.EVT_TOOL, toolbar.back, id=_NTB2_BACK) self.Bind(wx.EVT_TOOL, toolbar.zoom, id=_NTB2_ZOOM) self.Bind(wx.EVT_TOOL, toolbar.pan, id=_NTB2_PAN) self.Bind(wx.EVT_TOOL, self.configure_subplots, id=_NTB2_SUBPLOT) self.Bind(wx.EVT_TOOL, toolbar.save_figure, id=_NTB2_SAVE) self.Bind(wx.EVT_TOOL, on_toggle_zoom, id=_NTB2_ZOOM) self.Bind(wx.EVT_TOOL, on_toggle_pan, id=_NTB2_PAN) tb.Realize()
def _init_toolbar(self): self._parent = self.canvas.GetParent() _NTB2_HOME =wx.NewId() self._NTB2_BACK =wx.NewId() self._NTB2_FORWARD =wx.NewId() self._NTB2_PAN =wx.NewId() self._NTB2_ZOOM =wx.NewId() _NTB2_SAVE = wx.NewId() _NTB2_SUBPLOT =wx.NewId() self.SetToolBitmapSize(wx.Size(16,16)) self.AddSimpleTool(_NTB2_HOME, 'Home', _load_bitmap('home.png'), 'Reset original view') self.AddSimpleTool(self._NTB2_BACK, 'Back', _load_bitmap('back.png'), 'Back navigation view') self.AddSimpleTool(self._NTB2_FORWARD, 'Forward', _load_bitmap('forward.png'), 'Forward navigation view') # todo: get new bitmap self.AddCheckTool(self._NTB2_PAN, 'Pan', _load_bitmap('move.png'), _load_bitmap('move.png'), long_help_string='Pan with left, zoom with right') self.AddCheckTool(self._NTB2_ZOOM, 'Zoom', _load_bitmap('zoom_to_rect.png'), _load_bitmap('zoom_to_rect.png'), short_help_string='Zoom', long_help_string='Zoom to rectangle') self.AddSeparator() #self.AddSimpleTool(_NTB2_SUBPLOT, 'Configure subplots', _load_bitmap('subplots.png'), # 'Configure subplot parameters') self.AddSimpleTool(_NTB2_SAVE, 'Save', _load_bitmap('filesave.png'), 'Save plot contents to file') self.wind.Bind(wx.EVT_TOOL, self.home, id=_NTB2_HOME) self.wind.Bind(wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) self.wind.Bind(wx.EVT_TOOL, self.back, id=self._NTB2_BACK) self.wind.Bind(wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) self.wind.Bind(wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) #self.wind.Bind(wx.EVT_TOOL, self.configure_subplot, id=_NTB2_SUBPLOT) self.wind.Bind(wx.EVT_TOOL, self.save, id=_NTB2_SAVE) self.Realize()
def _init_toolbar(self): self._parent = self.canvas.GetParent() self.wx_ids = {} for text, tooltip_text, image_file, callback in self.toolitems: if text is None: self.AddSeparator() continue self.wx_ids[text] = wx.NewId() try: bitmap = _load_bitmap(image_file + ".png") except IOError: bitmap = wx.Bitmap(image_file + ".png") if text in ["Pan", "Zoom", "ROI"]: self.AddCheckTool(self.wx_ids[text], bitmap, shortHelp=text, longHelp=tooltip_text) else: self.AddSimpleTool(self.wx_ids[text], bitmap, text, tooltip_text) bind(self, wx.EVT_TOOL, getattr(self, callback), id=self.wx_ids[text]) self.ToggleTool(self.wx_ids["ROI"], True) self.Realize()
def _init_toolbar(self): self._parent = self.canvas.GetParent() self.wx_ids = {} for text, tooltip_text, image_file, callback in self.toolitems: if text is None: self.AddSeparator() continue self.wx_ids[text] = wx.NewIdRef() try : bitmap=_load_bitmap(image_file + '.png') except IOError : bitmap=wx.Bitmap(image_file + '.png') if text in ['Pan', 'Zoom', 'ROI']: self.AddCheckTool(self.wx_ids[text], text, bitmap, shortHelp=text, longHelp=tooltip_text) else: self.AddTool(self.wx_ids[text], text, bitmap, tooltip_text) self.Bind(wx.EVT_TOOL, getattr(self, callback), id=self.wx_ids[text]) self.ToggleTool(self.wx_ids['ROI'], True) self.Realize()
def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent from matplotlib.backends.backend_wx import _load_bitmap import pathlib self.figure = mpl.figure.Figure(dpi=None, figsize=(2, 2)) self.canvas = FigureCanvas(self, -1, self.figure) self.axes = self.figure.add_subplot(111) """disini untuk menentukan nilai sumbu x dan sumbu y""" self.x = [1, 2, 3, 4, 5, 6] self.y = [1, 2, 3, 4, 5, 6] self.axes.plot(self.x, self.y) self.toolbar = NavigationToolbar(self.canvas) self.pathimage = pathlib.Path.cwd() / "resources/images/binadata.png" self.newpathimage = pathlib.Path.cwd() / "resources/images/bila.png" self.ON_CUSTOM = wx.NewIdRef() self.image1 = wx.Image(str(self.pathimage)) self.re_image3 = self.image1.Rescale(20, 20) self.re_image3.SaveFile(self.newpathimage.as_posix()) self.newpathimage print(self.re_image3) self.toolbar.AddSimpleTool(self.ON_CUSTOM, _load_bitmap(self.newpathimage),\ 'Pan to the left', 'Pan graph to the left') self.toolbar.Realize() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer)
toolbar.Hide() #toolbar constants TBFLAGS = (wx.TB_HORIZONTAL|wx.TB_TEXT) tsize = (24,24) tb = f.CreateToolBar(TBFLAGS) _NTB2_HOME = wx.NewId() _NTB2_BACK = wx.NewId() _NTB2_FORWARD = wx.NewId() _NTB2_PAN = wx.NewId() _NTB2_ZOOM = wx.NewId() _NTB2_SAVE = wx.NewId() _NTB2_SUBPLOT = wx.NewId() tb.AddSimpleTool(_NTB2_HOME, _load_bitmap('home.png'), 'Home', 'Reset original view') tb.AddSimpleTool(_NTB2_BACK, _load_bitmap('back.png'), 'Back', 'Back navigation view') tb.AddSimpleTool(_NTB2_FORWARD, _load_bitmap('forward.png'), 'Forward', 'Forward navigation view') tb.AddCheckTool(_NTB2_PAN, _load_bitmap('move.png'), shortHelp='Pan', longHelp='Pan with left, zoom with right') tb.AddCheckTool(_NTB2_ZOOM, _load_bitmap('zoom_to_rect.png'), shortHelp='Zoom', longHelp='Zoom to rectangle') tb.AddSeparator() tb.AddSimpleTool(_NTB2_SUBPLOT, _load_bitmap('subplots.png'), 'Configure subplots', 'Configure subplot parameters') tb.AddSimpleTool(_NTB2_SAVE, _load_bitmap('filesave.png'), 'Save', 'Save plot contents to file') f.Bind(wx.EVT_TOOL, toolbar.home, id=_NTB2_HOME) f.Bind(wx.EVT_TOOL, toolbar.forward, id=_NTB2_FORWARD) f.Bind(wx.EVT_TOOL, toolbar.back, id=_NTB2_BACK) f.Bind(wx.EVT_TOOL, toolbar.zoom, id=_NTB2_ZOOM) f.Bind(wx.EVT_TOOL, toolbar.pan, id=_NTB2_PAN)
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__init__(self, canvas) self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('stock_left.xpm'), 'Click me', 'Activate custom contol') wx.EVT_TOOL(self, self.ON_CUSTOM, self._on_custom)
def __init__(self, canvas, cankill): NavigationToolbar2WxAgg.__init__(self, canvas) 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, parent, title, fname, runNumber=1): util.GenericView.__init__(self, parent, title) self.CreateMenuBar() self.runNumber = runNumber self.mykProfileView = None self.SetSize((900, 650)) self.SetPosition((10, 10)) self.sbgen = self.CreateStatusBar() self.sbgen.SetBackgroundColour('WHITE') txt = 'KMatrix file = %s' % fname self.sbgen.SetStatusText(txt) # timer affichage StatusBar self.txtsb = '' self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.refreshSB, self.timer) """ read kmat.h5 file """ self.fh5 = fname self.kmat = rttov.kmatrix.Kmatrix() self.kmat101 = rttov.kmatrix.Kmatrix() """ read profile in kmat.h5 """ self.baseProfile = rttov.profile.Profile() self.baseProfile = rmodel.project.OpenAProfile(self.fh5, 1) t0 = time.clock() frad = h5py.File(self.fh5, 'r') h5 = frad['/'] self.kmat.loadh5(h5) frad.close() t1 = time.clock() txt = 'lecture fichier %s : %d sec.' % (self.fh5, (t1 - t0)) self.sat = self.kmat.misc['SATELLITE'] self.ins = self.kmat.misc['INSTRUMENT'] self.lev = self.kmat.profile['NLEVELS'] self.tabP = self.kmat.profile['P'] # # growth the levels < 101 # # map the levels self.tabilevels = np.zeros(levx, int) for l in range(0, levx): self.tabilevels[l] = round(l * self.lev / levx) if self.lev < levx: tabNP = np.zeros(levx) for l in range(0, levx): tabNP[l] = self.tabP[self.tabilevels[l]] self.tabP = tabNP self.tabW = self.kmat.misc['WAVENUMBERS'] self.tabY = {} self.chn = self.kmat.kmatrix['T'].shape[1] """ gasplot : 0.0 not shown ? """ self.tcomm = {} self.tunit = {} self.tcbar = {} self.gasplot = [] for gas in ['T', 'Q'] + gaslist: if self.kmat.kmatrix[gas] is None: continue kmin = np.amin(self.kmat.kmatrix[gas]) kmax = np.amax(self.kmat.kmatrix[gas]) self.tcbar[gas] = 1 if kmin == 0.0 and kmax == 0.0: self.tcbar[gas] = 0 attr = '%s_ATTRIBUTE' % gas self.tcomm[gas] = self.kmat.kmatrix[attr]['COMMENT'] self.tunit[gas] = self.kmat.kmatrix[attr]['UNITS'] if not gas == 'T' and not gas == 'Q': self.gasplot.append(gas) # # init figure # self.fig = figPlot() self.cnv = FigureCanvas(self, -1, self.fig) self.cnv.mpl_connect('motion_notify_event', self.onMMotion) self.cnv.mpl_connect('key_press_event', self.onkeypress) # # subplot width # self.barwidth = max(1, int(wix / self.chn)) self.yMax = self.lev if self.chn >= chnx: self.xMax = self.chn else: self.xMax = self.barwidth * self.chn self.txtsb = '%s / %s' % (self.sat.replace( ' ', '').upper(), self.ins.upper()) # # choice gas in subplot 313 # self.glabel = {} self.gasID = {} self.tlb = MyCustomToolbar(self.cnv) if len(self.gasplot) > 1: for ig in self.gasplot: self.gasID[ig] = wx.NewId() self.glabel[self.gasID[ig]] = ig ico = os.environ["RTTOV_GUI_PREFIX"] + '/icons/%s.png' % ig self.tlb.AddSimpleTool(self.gasID[ig], _load_bitmap(ico), ig, '') wx.EVT_TOOL(self.tlb, self.gasID[ig], self.gaschoice) # # toolbar : custom buttons # self.LEFTLEFT_ID = wx.NewId() self.tlb.AddSimpleTool(self.LEFTLEFT_ID, _load_bitmap('hand.xpm'), 'One screen left', '') wx.EVT_TOOL(self.tlb, self.LEFTLEFT_ID, self.onleftleft) self.LEFT_ID = wx.NewId() self.tlb.AddSimpleTool(self.LEFT_ID, _load_bitmap('stock_left.xpm'), 'left', '') wx.EVT_TOOL(self.tlb, self.LEFT_ID, self.onleft) self.RIGHT_ID = wx.NewId() self.tlb.AddSimpleTool(self.RIGHT_ID, _load_bitmap('stock_right.xpm'), 'right', '') wx.EVT_TOOL(self.tlb, self.RIGHT_ID, self.onright) self.RIGHTRIGHT_ID = wx.NewId() self.tlb.AddSimpleTool(self.RIGHTRIGHT_ID, _load_bitmap('hand.xpm'), 'One screen right', '') wx.EVT_TOOL(self.tlb, self.RIGHTRIGHT_ID, self.onrightright) self.UP_ID = wx.NewId() self.tlb.AddSimpleTool(self.UP_ID, _load_bitmap('stock_up.xpm'), 'scroll up', '') wx.EVT_TOOL(self.tlb, self.UP_ID, self.onup) self.DOWN_ID = wx.NewId() self.tlb.AddSimpleTool(self.DOWN_ID, _load_bitmap('stock_down.xpm'), 'scroll down', '') wx.EVT_TOOL(self.tlb, self.DOWN_ID, self.ondown) # # add kscale icon : K / K% # self.scalek = 0 self.SCALE10K_ID = wx.NewId() self.tlb.AddSimpleTool( self.SCALE10K_ID, _load_bitmap(os.environ["RTTOV_GUI_PREFIX"] + '/icons/k10.png'), 'scale Kx10%', '') wx.EVT_TOOL(self.tlb, self.SCALE10K_ID, self.onscale10k) self.RESETK_ID = wx.NewId() self.tlb.AddSimpleTool( self.RESETK_ID, _load_bitmap(os.environ["RTTOV_GUI_PREFIX"] + '/icons/reset.png'), 'reset K', '') wx.EVT_TOOL(self.tlb, self.RESETK_ID, self.onresetk) # # add box : select channel # self.SELCHAN_ID = wx.NewId() self.tlb.AddSimpleTool( self.SELCHAN_ID, _load_bitmap(os.environ["RTTOV_GUI_PREFIX"] + '/icons/kP.png'), 'select channnel', '') wx.EVT_TOOL(self.tlb, self.SELCHAN_ID, self.onselchan) self.tlb.Realize() # canvas and toolbar in sizer sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.tlb, 0, wx.GROW) sizer.Add(self.cnv, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(sizer) self.Fit() # self.kprof = None # self.subP = {} self.cax = {} # # subplots T and Q # self.subP['T'] = self.fig.add_subplot(3, 1, 1) self.tabY['T'] = self.extract_kgas('T') tt = '%s : %s' % ('T', self.tcomm['T']) self.subP['T'].set_title(tt) img = self.subP['T'].imshow(self.tabY['T'], origin='upper') self.subP['T'].set_ylabel('P levels') divider = make_axes_locatable(self.subP['T']) self.cax['T'] = divider.append_axes("right", size="1%", pad=0.05) self.fig.colorbar(img, cax=self.cax['T']) self.subP['T'].set_xlim([0, min(self.xMax, wix)]) self.draw_plot('T', 'T', self.kmat.kmatrix['%s_ATTRIBUTE' % 'T']['COMMENT']) self.subP['Q'] = self.fig.add_subplot(3, 1, 2, sharex=self.subP['T'], sharey=self.subP['T']) self.tabY['Q'] = self.extract_kgas('Q') tt = '%s : %s' % ('Q', self.tcomm['Q']) self.subP['Q'].set_title(tt) img = self.subP['Q'].imshow(self.tabY['Q'], origin='upper') self.subP['Q'].set_ylabel('P levels') divider = make_axes_locatable(self.subP['Q']) self.cax['Q'] = divider.append_axes("right", size="1%", pad=0.05) self.fig.colorbar(img, cax=self.cax['Q']) self.subP['Q'].set_xlim([0, min(self.xMax, wix)]) self.draw_plot('Q', 'Q', self.kmat.kmatrix['%s_ATTRIBUTE' % 'Q']['COMMENT']) # # subplot other gases if exist # if self.gasplot: for gas in self.gasplot: self.tabY[gas] = self.extract_kgas(gas) gas = self.gasplot[0] self.subP['G'] = self.fig.add_subplot(3, 1, 3, sharex=self.subP['T'], sharey=self.subP['T']) tt = '%s : %s' % (gas, self.tcomm[gas]) self.subP['G'].set_title(tt) img = self.subP['G'].imshow(self.tabY[gas], origin='upper') self.subP['G'].set_ylabel('P levels') divider = make_axes_locatable(self.subP['G']) self.cax['G'] = divider.append_axes("right", size="1%", pad=0.05) self.fig.colorbar(img, cax=self.cax['G']) self.subP['G'].set_xlim([0, min(self.xMax, wix)]) self.draw_plot('G', gas, self.kmat.kmatrix['%s_ATTRIBUTE' % gas]['COMMENT']) self.fig.tight_layout() self.fig.canvas.draw()
def __init__(self, parent, canvas, cankill, OnUndo): self.cid = 0 self.circles = [] self.point3 = np.array([]) self.point2 = np.array([]) self.lines = [] self.hist = ['start'] NavigationToolbar2WxAgg.__init__(self, canvas) self.statbar = None self.OnUndo = OnUndo self.parent = parent if self.parent.mpl_old: self.wx_ids = {'Pan': self._NTB2_PAN, 'Zoom': self._NTB2_ZOOM} self.AddSeparator() if 'phoenix' in wx.PlatformInfo: self.AddCheckTool( self.ON_MARKRINGS, 'Mark Rings', _load_bitmap(os.path.join(self.parent.iconspath, '3_point.png')), shortHelp='Mark Rings', longHelp="mark 3-points on a ring to find center") else: self.AddCheckTool( self.ON_MARKRINGS, _load_bitmap(os.path.join(self.parent.iconspath, '3_point.png')), shortHelp='Mark Rings', longHelp="mark 3-points on a ring to find center") self.Bind(wx.EVT_TOOL, self._on_markrings, id=self.ON_MARKRINGS) if 'phoenix' in wx.PlatformInfo: self.AddCheckTool(self.ON_MARKSPOTS, 'Mark Spots', _load_bitmap( os.path.join(self.parent.iconspath, '2_point.png')), shortHelp='Mark Spots', longHelp="mark 2 spots to measure distance") else: self.AddCheckTool(self.ON_MARKSPOTS, _load_bitmap( os.path.join(self.parent.iconspath, '2_point.png')), shortHelp='Mark Spots', longHelp="mark 2 spots to measure distance") self.Bind(wx.EVT_TOOL, self._on_markspots, id=self.ON_MARKSPOTS) self.AddSeparator() if 'phoenix' in wx.PlatformInfo: self.AddTool(self.ON_INTEGRATE, 'Profile', _load_bitmap( os.path.join(self.parent.iconspath, 'profile.png')), shortHelp='Profile') else: self.AddSimpleTool( self.ON_INTEGRATE, _load_bitmap(os.path.join(self.parent.iconspath, 'profile.png')), 'Profile', 'Extract profiles from the diffraction pattern') self.Bind(wx.EVT_TOOL, self._on_integrate, id=self.ON_INTEGRATE) undo_ico = wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR, (16, 16)) if 'phoenix' in wx.PlatformInfo: self.AddTool(self.ON_UNDO, 'Undo', undo_ico, shortHelp='Undo last point or ring') else: self.AddSimpleTool(self.ON_UNDO, undo_ico, 'Undo', 'Undo last point or ring') self.Bind(wx.EVT_TOOL, self._on_undo, id=self.ON_UNDO)
toolbar.Hide() #toolbar constants TBFLAGS = (wx.TB_HORIZONTAL | wx.TB_TEXT) tsize = (24, 24) tb = f.CreateToolBar(TBFLAGS) _NTB2_HOME = wx.NewId() _NTB2_BACK = wx.NewId() _NTB2_FORWARD = wx.NewId() _NTB2_PAN = wx.NewId() _NTB2_ZOOM = wx.NewId() _NTB2_SAVE = wx.NewId() _NTB2_SUBPLOT = wx.NewId() tb.AddSimpleTool(_NTB2_HOME, _load_bitmap('home.png'), 'Home', 'Reset original view') tb.AddSimpleTool(_NTB2_BACK, _load_bitmap('back.png'), 'Back', 'Back navigation view') tb.AddSimpleTool(_NTB2_FORWARD, _load_bitmap('forward.png'), 'Forward', 'Forward navigation view') tb.AddCheckTool(_NTB2_PAN, _load_bitmap('move.png'), shortHelp='Pan', longHelp='Pan with left, zoom with right') tb.AddCheckTool(_NTB2_ZOOM, _load_bitmap('zoom_to_rect.png'), shortHelp='Zoom', longHelp='Zoom to rectangle')
def _init_toolbar(self): self._NTB2_HOME = wx.NewId() self._NTB2_PANLEFT = wx.NewId() self._NTB2_PANRIGHT = wx.NewId() self._NTB2_ZOOMOUT = wx.NewId() self._NTB2_ZOOMIN = wx.NewId() self._NTB2_CONFIG = wx.NewId() self._NTB2_SAVE = wx.NewId() self._NTB2_PRINT = wx.NewId() self._NTB2_SETUP = wx.NewId() self._NTB2_PREVIEW = wx.NewId() self._NTB2_TOOL_IND = wx.NewId() self._NTB2_TOOL_HLINE = wx.NewId() self._NTB2_TOOL_VLINE = wx.NewId() self._NTB2_TOOL_OLINE = wx.NewId() self._NTB2_TOOL_FIBO = wx.NewId() self._NTB2_TOOL_TRASH = wx.NewId() self.SetToolBitmapSize(wx.Size(24,24)) self.AddSimpleTool(self._NTB2_HOME, wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR), message('tb_home'), message('tb_home')) self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL)) self.AddSimpleTool(self._NTB2_PANLEFT, wx.ArtProvider.GetBitmap(wx.ART_GO_BACK, wx.ART_TOOLBAR), message('tb_pan_left'), message('tb_pan_left')) self.AddSimpleTool(self._NTB2_PANRIGHT, wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR), message('tb_pan_right'), message('tb_pan_right')) self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL)) self.AddSimpleTool(self._NTB2_ZOOMOUT, _load_bitmap('stock_zoom-out.xpm'), message('tb_zoom_out'), message('tb_zoom_out')) self.AddSimpleTool(self._NTB2_ZOOMIN, _load_bitmap('stock_zoom-in.xpm'), message('tb_zoom_in'), message('tb_zoom_in')) self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL)) self.AddSimpleTool(self._NTB2_CONFIG, wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK, wx.ART_TOOLBAR), message('tb_config'), message('tb_config')) self.AddSimpleTool(self._NTB2_SAVE, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR), message('tb_save_file'), message('tb_save_file')) self.AddSimpleTool(self._NTB2_SETUP, wx.Bitmap(os.path.join(itrade_config.dirRes, 'printsetup.png')), message('tb_setup'), message('tb_setup')) self.AddSimpleTool(self._NTB2_PRINT, wx.Bitmap(os.path.join(itrade_config.dirRes, 'print.png')), message('tb_print'), message('tb_print')) self.AddSimpleTool(self._NTB2_PREVIEW, wx.Bitmap(os.path.join(itrade_config.dirRes, 'printpreview.png')), message('tb_preview'), message('tb_preview')) self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL)) self.AddRadioLabelTool(self._NTB2_TOOL_IND, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toolind.png')), wx.NullBitmap, message('tb_tool_ind'), message('tb_tool_ind')) self.AddRadioLabelTool(self._NTB2_TOOL_HLINE, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toolhline.png')), wx.NullBitmap, message('tb_tool_hline'), message('tb_tool_hline')) self.AddRadioLabelTool(self._NTB2_TOOL_VLINE, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toolvline.png')), wx.NullBitmap, message('tb_tool_vline'), message('tb_tool_vline')) self.AddRadioLabelTool(self._NTB2_TOOL_OLINE, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toololine.png')), wx.NullBitmap, message('tb_tool_oline'), message('tb_tool_oline')) self.AddRadioLabelTool(self._NTB2_TOOL_FIBO, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toolfibo.png')), wx.NullBitmap, message('tb_tool_fibo'), message('tb_tool_fibo')) self.AddRadioLabelTool(self._NTB2_TOOL_TRASH, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'tooltrash.png')), wx.NullBitmap, message('tb_tool_trash'), message('tb_tool_trash')) wx.EVT_TOOL(self, self._NTB2_HOME, self.home) wx.EVT_TOOL(self, self._NTB2_PANLEFT, self.panLeft) wx.EVT_TOOL(self, self._NTB2_PANRIGHT, self.panRight) wx.EVT_TOOL(self, self._NTB2_ZOOMOUT, self.zoomOut) wx.EVT_TOOL(self, self._NTB2_ZOOMIN, self.zoomIn) wx.EVT_TOOL(self, self._NTB2_CONFIG, self.config) wx.EVT_TOOL(self, self._NTB2_SAVE, self.save) wx.EVT_TOOL(self, self._NTB2_SETUP, self.printSetup) wx.EVT_TOOL(self, self._NTB2_PRINT, self.doPrint) wx.EVT_TOOL(self, self._NTB2_PREVIEW, self.doPreview) wx.EVT_TOOL(self, self._NTB2_TOOL_IND, self.toolInd) wx.EVT_TOOL(self, self._NTB2_TOOL_HLINE, self.toolHLine) wx.EVT_TOOL(self, self._NTB2_TOOL_VLINE, self.toolVLine) wx.EVT_TOOL(self, self._NTB2_TOOL_OLINE, self.toolOLine) wx.EVT_TOOL(self, self._NTB2_TOOL_FIBO, self.toolFibo) wx.EVT_TOOL(self, self._NTB2_TOOL_TRASH, self.toolTrash) self.Realize()
def _init_toolbar(self): self._NTB2_HOME = wx.NewId() self._NTB2_PANLEFT = wx.NewId() self._NTB2_PANRIGHT = wx.NewId() self._NTB2_ZOOMOUT = wx.NewId() self._NTB2_ZOOMIN = wx.NewId() self._NTB2_CONFIG = wx.NewId() self._NTB2_SAVE = wx.NewId() self._NTB2_PRINT = wx.NewId() self._NTB2_SETUP = wx.NewId() self._NTB2_PREVIEW = wx.NewId() self._NTB2_TOOL_IND = wx.NewId() self._NTB2_TOOL_HLINE = wx.NewId() self._NTB2_TOOL_VLINE = wx.NewId() self._NTB2_TOOL_OLINE = wx.NewId() self._NTB2_TOOL_FIBO = wx.NewId() self._NTB2_TOOL_TRASH = wx.NewId() self.SetToolBitmapSize(wx.Size(24, 24)) self.AddSimpleTool( self._NTB2_HOME, wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR), message('tb_home'), message('tb_home')) self.AddControl( wx.StaticLine(self, -1, size=(-1, 23), style=wx.LI_VERTICAL)) self.AddSimpleTool( self._NTB2_PANLEFT, wx.ArtProvider.GetBitmap(wx.ART_GO_BACK, wx.ART_TOOLBAR), message('tb_pan_left'), message('tb_pan_left')) self.AddSimpleTool( self._NTB2_PANRIGHT, wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR), message('tb_pan_right'), message('tb_pan_right')) self.AddControl( wx.StaticLine(self, -1, size=(-1, 23), style=wx.LI_VERTICAL)) self.AddSimpleTool(self._NTB2_ZOOMOUT, _load_bitmap('stock_zoom-out.xpm'), message('tb_zoom_out'), message('tb_zoom_out')) self.AddSimpleTool(self._NTB2_ZOOMIN, _load_bitmap('stock_zoom-in.xpm'), message('tb_zoom_in'), message('tb_zoom_in')) self.AddControl( wx.StaticLine(self, -1, size=(-1, 23), style=wx.LI_VERTICAL)) self.AddSimpleTool( self._NTB2_CONFIG, wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK, wx.ART_TOOLBAR), message('tb_config'), message('tb_config')) self.AddSimpleTool( self._NTB2_SAVE, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR), message('tb_save_file'), message('tb_save_file')) self.AddSimpleTool( self._NTB2_SETUP, wx.Bitmap(os.path.join(itrade_config.dirRes, 'printsetup.png')), message('tb_setup'), message('tb_setup')) self.AddSimpleTool( self._NTB2_PRINT, wx.Bitmap(os.path.join(itrade_config.dirRes, 'print.png')), message('tb_print'), message('tb_print')) self.AddSimpleTool( self._NTB2_PREVIEW, wx.Bitmap(os.path.join(itrade_config.dirRes, 'printpreview.png')), message('tb_preview'), message('tb_preview')) self.AddControl( wx.StaticLine(self, -1, size=(-1, 23), style=wx.LI_VERTICAL)) self.AddRadioLabelTool( self._NTB2_TOOL_IND, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toolind.png')), wx.NullBitmap, message('tb_tool_ind'), message('tb_tool_ind')) self.AddRadioLabelTool( self._NTB2_TOOL_HLINE, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toolhline.png')), wx.NullBitmap, message('tb_tool_hline'), message('tb_tool_hline')) self.AddRadioLabelTool( self._NTB2_TOOL_VLINE, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toolvline.png')), wx.NullBitmap, message('tb_tool_vline'), message('tb_tool_vline')) self.AddRadioLabelTool( self._NTB2_TOOL_OLINE, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toololine.png')), wx.NullBitmap, message('tb_tool_oline'), message('tb_tool_oline')) self.AddRadioLabelTool( self._NTB2_TOOL_FIBO, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'toolfibo.png')), wx.NullBitmap, message('tb_tool_fibo'), message('tb_tool_fibo')) self.AddRadioLabelTool( self._NTB2_TOOL_TRASH, '', wx.Bitmap(os.path.join(itrade_config.dirRes, 'tooltrash.png')), wx.NullBitmap, message('tb_tool_trash'), message('tb_tool_trash')) wx.EVT_TOOL(self, self._NTB2_HOME, self.home) wx.EVT_TOOL(self, self._NTB2_PANLEFT, self.panLeft) wx.EVT_TOOL(self, self._NTB2_PANRIGHT, self.panRight) wx.EVT_TOOL(self, self._NTB2_ZOOMOUT, self.zoomOut) wx.EVT_TOOL(self, self._NTB2_ZOOMIN, self.zoomIn) wx.EVT_TOOL(self, self._NTB2_CONFIG, self.config) wx.EVT_TOOL(self, self._NTB2_SAVE, self.save) wx.EVT_TOOL(self, self._NTB2_SETUP, self.printSetup) wx.EVT_TOOL(self, self._NTB2_PRINT, self.doPrint) wx.EVT_TOOL(self, self._NTB2_PREVIEW, self.doPreview) wx.EVT_TOOL(self, self._NTB2_TOOL_IND, self.toolInd) wx.EVT_TOOL(self, self._NTB2_TOOL_HLINE, self.toolHLine) wx.EVT_TOOL(self, self._NTB2_TOOL_VLINE, self.toolVLine) wx.EVT_TOOL(self, self._NTB2_TOOL_OLINE, self.toolOLine) wx.EVT_TOOL(self, self._NTB2_TOOL_FIBO, self.toolFibo) wx.EVT_TOOL(self, self._NTB2_TOOL_TRASH, self.toolTrash) self.Realize()