예제 #1
0
 def __init__(self, plotCanvas, parent):
     # create the default toolbar
     # plotCanvas is the tk Canvas we want to link to the toolbar,
     # parent is the iseult main app
     NavigationToolbar2Tk.__init__(self, plotCanvas, parent)
     # print(self._nav_stack)
     self.parent = parent
 def __init__(self, canvas_, parent_):
     self.toolitems = (('Home', 'Reset view', 'home',
                        'home'), (None, None, None, None), ('Pan', 'Pan',
                                                            'move', 'pan'),
                       ('Zoom', 'Zoom', 'zoom_to_rect',
                        'zoom'), (None, None, None, None),
                       ('Save', 'Save figure', 'filesave', 'save_figure'))
     NavigationToolbar2TkAgg.__init__(self, canvas_, parent_)
예제 #3
0
 def __init__(self, canvas_, parent_):
     self.toolitems = (
         ('Home', 'Reset original view', 'home', 'home'),
         ('Back', 'Back to previous view', 'back', 'back'),
         ('Forward', 'Forward to next view', 'forward', 'forward'),
         # TODO Get this poor thing a nice gif
         ('Pan', 'Pan axes with left mouse, zoom with right', 'move', 'pan'
          ),
         ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
         ('save_fig', 'Save Figure', 'Filesave', 'save_Figure'))
     NavigationToolbar2Tk.__init__(self, canvas_, parent_)
예제 #4
0
 def __init__(self, canvas_, parent_):
     self.toolitems = (
         ('Home', 'Reset original view', 'home', 'home'),
         ('Back', 'Back to previous view', 'back', 'back'),
         ('Forward', 'Forward to next view', 'forward', 'forward'),
         ('Pan', 'Pan axes with left mouse, zoom with right', 'move',
          'pan'),
         ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
         ('Axes', 'Define the X- and Y-axis limits', 'subplots',
          'plot_axes'),
         ('Subplots', 'Configure subplots', 'subplots',
          'configure_subplots'),
         ('Save', 'Save the figure', 'filesave', 'save_figure'),
     )
     NavigationToolbar2Tk.__init__(self, canvas_, parent_)
예제 #5
0
 def __init__(self, canvas_, parent_):
     self.a = []
     self.toolitems = (
         # Name of tool, tool tip, icon save file, function to be called
         # Icons are saved in /home/zsabry/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/images/
         ('Home', 'Reset original view', 'home', 'home'),
         ('Back', 'Back to previous view', 'back', 'back'),
         ('Forward', 'Forward to next view', 'forward', 'forward'),
         ('Pan', 'Pan axes with left mouse, zoom with right', 'move',
          'pan'),
         ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
         ('Save', 'Save the figure', 'filesave', 'save_figure'),
         # TODO Get this poor thing a nice gif
         #            ('Rectangle', 'Draw Rectangle', 'subplots', 'rectangle'),
         #            ('Ellipse', 'Draw Ellipse', 'subplots', 'ellipse'),
         ('Lasso', 'Draw lasso', 'subplots', 'lasso'),
     )
     NavigationToolbar2Tk.__init__(self, canvas_, parent_)
예제 #6
0
 def __init__(self, canvas_, parent_, mouse_click):
     self.clicked = None
     self.mouse_click = mouse_click
     self.toolitems = (
         ('Home', 'Reset Slice View', 'home',
          'home'),  #My tooltips are 2nd here
         ('Back', 'Previous Slice', 'back', 'back'),
         ('Forward', 'Next Slice', 'forward', 'forward'),
         (None, None, None, None),
         ('Pan', 'Pan axes with left mouse, zoom with right', 'move',
          'pan'),
         ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
         (None, None, None, None),
         ('Subplots', 'Configure Subplots', 'subplots',
          'configure_subplots'),  #subplots is not included in this figure
         ('Save', 'Save Slice', 'filesave', 'save_figure'),
     )
     NavigationToolbar2Tk.__init__(self, canvas_, parent_)
예제 #7
0
    def __init__(self,canvas_,parent_,width_,GUI_DIR_):
        self.basedir = os.path.join(rcParams['datapath'], 'images')
        self.GUI_DIR = GUI_DIR_
        self.toolitems = (
            ('Home', 'Reset original view', 'home', 'home'),
            ('Back', 'Back to previous view', 'back', 'back'),
            ('Forward', 'Forward to next view', 'forward', 'forward'),
            ('Pan', 'Pan axes with left mouse, zoom with right mouse or scroll wheel', 'move', 'pan'),
            ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
##            ('Redraw','Recalculate points',self.GUI_DIR+'/assets/recalculate','redraw'),
            ('Slider','Width slider','subplots','slider'),
            (None,None,None,None),
            ('Save', 'Save image of figure', 'filesave', 'save_figure'),
            (None,None,None,None),
##            ('Help','Graph help',self.GUI_DIR+'/assets/help','help'),
            )
        self.parent = parent_
        self.canvas = canvas_
        self.width = width_ #width used with slider tool
        self.axes_list = self.canvas.figure.get_axes()
        self.templateDict = self.parent.root.placed
        self.graph_list = self.parent.fig_info[18]
        self.template = self.templateDict[self.parent.region] #corresponding template for a region in tao
        self.templateGraphList = []
        for i in self.graph_list:
            self.templateGraphList.append(self.template + '.' + i.split('.')[1])
        self.gRangeList = [] #list of original x min, x max, y min, and y max for each graph
        try:
            for i in self.templateGraphList:
                gInfo=self.parent.pipe.cmd_in('python plot_graph '+i,no_warn = True).splitlines()
                gRange = []
                gInfoDict = {}
                for i in range(len(gInfo)):
                    gInfoDict[gInfo[i].split(';')[0]]=str_to_tao_param(gInfo[i])
                gRange.append(gInfoDict['x'].get_component('min'))
                gRange.append(gInfoDict['x'].get_component('max'))
                gRange.append(gInfoDict['y'].get_component('min'))
                gRange.append(gInfoDict['y'].get_component('max'))
                self.gRangeList.append(gRange)
        except IndexError: #incase number of graphs changes, like in wave analysis
            pass
        NavigationToolbar2Tk.__init__(self,canvas_,parent_)
예제 #8
0
 def __init__(self, canvas_, parent_):
     """Initialise toolbar with custom button added to toolitems"""
     self.toolitems = (
         ('Home', 'Reset original view', 'home', 'home'),
         ('Back', 'Back to previous view', 'back', 'back'),
         ('Forward', 'Forward to next view', 'forward', 'forward'),
         ('Pan', 'Pan axes with left mouse, zoom with right', 'move',
          'pan'),
         ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
         ('Subplots', 'Configure subplots', 'subplots',
          'configure_subplots'),
         (None, None, None, None),
         ('Save', 'Save the figure', 'filesave', 'save_figure'),
         (None, None, None, None),
         (None, None, None, None),
         ('Save High Quality', 'Save a high quality figure', 'filesave',
          'save_highdef'),
     )
     self.inputdpi = 600
     self.button_pressed = None
     NavigationToolbar2Tk.__init__(self, canvas_, parent_)
예제 #9
0
 def __init__(self, canvas_, parent_, tkbase_, toolitems):
     self.tkbase_ = tkbase_
     self.parent_ = parent_
     self.toolitems = toolitems
     NavigationToolbar2Tk.__init__(self, canvas_, parent_)
예제 #10
0
파일: viewer.py 프로젝트: chippey/SpecDAL
 def __init__(self, canvas_, parent, ax):
     NavigationToolbar2Tk.__init__(self, canvas_, parent)
     self._xlim = (0, 1)
     self._ylim = (0, 1)
     self._ax = ax
     self._canvas_ = canvas_
예제 #11
0
 def __init__(self, plot_canvas, parent):
     NavigationToolbar2Tk.__init__(self, plot_canvas, parent)
예제 #12
0
 def __init__(self, canvas, window, gui):
     self.gui = gui
     NavigationToolbar2Tk.__init__(self, canvas, window)
예제 #13
0
 def __init__(self, canvas, window):
     NavigationToolbar2Tk.__init__(self, canvas, window)
예제 #14
0
 def __init__(self, canvas, window, tight_layout_cmd, toggle_grid_cmd):
     self.tight_layout = tight_layout_cmd
     self.toggle_grid = toggle_grid_cmd
     NavigationToolbar2Tk.__init__(self, canvas, window)
예제 #15
0
 def __init__(self, canvas_, parent_):
     self.toolitems = (('Zoom', 'Zoom to rectangle', 'zoom_to_rect',
                        'zoom'), )
     NavigationToolbar2Tk.__init__(self, canvas_, parent_)
예제 #16
0
 def __init__(self, canvas, window, image_dpi=None):
     self.canvas = canvas
     self.window = window
     self._image_dpi = image_dpi
     NavigationToolbar2Tk.__init__(self, canvas, window)
예제 #17
0
 def __init__(self, canvas_, parent_):
     self.toolitems = (('Subplots', 'putamus parum claram', 'subplots',
                        'configure_subplots'),
                       ('Save', 'sollemnes in futurum', 'filesave',
                        'save_figure'), (None, None, None, None))
     NavigationToolbar2Tk.__init__(self, canvas_, parent_)
 def __init__(self, canvas, window):
     self.canvas = canvas
     self.window = window
     NavigationToolbar2Tk.__init__(self, canvas, window)
예제 #19
0
 def __init__(self, canvas, window, message_parent):
     self._message_parent = message_parent
     NavigationToolbar2Tk.__init__(self, canvas, window)
예제 #20
0
 def __init__(self, canvas, window, homeCallback=None):
     NavigationToolbar2Tk.__init__(self, canvas, window)
예제 #21
0
    def __init__(self,
                 root,
                 canvas_,
                 parent_,
                 master_class,
                 axis_id=None,
                 poppedout_id=None,
                 direction="x"):

        # Safe the root and id
        self.root = root
        self.master_class = master_class
        self.axis_id = axis_id
        self.poppedout_id = poppedout_id
        self.direction = direction

        # Make sure we know which buttons to plot
        if not hasattr(self.master_class, 'btn_popout'):
            self.master_class.btn_popout = True
        if not hasattr(self.master_class, 'btn_reread'):
            self.master_class.btn_reread = True

        # Get the width of the canvas
        canvas_frame = canvas_.get_tk_widget()
        canvas_frame.update()
        root.update_idletasks()
        self.width = canvas_frame.winfo_width()

        # Make the option window object for each toolbar, the id is used to know which canvas it is linked to
        self.class_optionWindow = OptionsWindow(self.root, self.master_class,
                                                self.axis_id,
                                                self.poppedout_id)

        # Safe the custom buttons
        self.customButtons = []

        # Initiate the standard toolbar (which is empty) and manually add it to the canvas so we can use grid()
        self.toolitems = ()
        NavigationToolbar2Tk.__init__(self,
                                      canvas_,
                                      parent_,
                                      pack_toolbar=False)
        if self.direction == "x": self.grid(row=1, column=0, stick='NSEW')
        if self.direction == "y": self.grid(row=0, column=0, stick='NSEW')

        # There is a tk.Label object at the end of the toolbar which has the wrong color so remove it
        # See /usr/local/lib/python3.6/dist-packages/matplotlib/backends/_backend_tk.py line 521
        list_widgets = self.pack_slaves()
        for i in range(len(list_widgets)):
            list_widgets[i].destroy()

        # Define our own custom buttons
        self.tool_buttons = []
        num = 0
        self.extratoolitems = (('Save', 'Save the figure', 'icon',
                                'save_figure'), ('Home', 'Reset original view',
                                                 'icon', 'home'),
                               ('Back', 'Back to previous view', 'icon',
                                'back'), ('Forward', 'Forward to next view',
                                          'icon', 'forward'),
                               ('Pan',
                                'Pan axes with left mouse, zoom with right',
                                'icon', 'pan'), ('Zoom', 'Zoom to rectangle',
                                                 'icon', 'zoom'), (None, None,
                                                                   None, None),
                               ('Reset', 'Reset the figure', 'icon',
                                'reset'), ('Options', 'Figure options', 'icon',
                                           'options'),
                               ('PopOut', 'Open the figure in a new window',
                                'icon', 'popout_window'))

        # If the time is dark, use white icons instead of black icons
        extension = "_inv" if self.root.theme == "awdark" else ""
        self.toolbar_icons = [
            "filesave", "home", "back", "forward", "move", "zoom_to_rect",
            "reload", "subplots", "qt4_editor_options"
        ]
        self.toolbar_icons = [
            CONFIG['PATHS']['stellapy'] + "GUI/images/" + icon + extension +
            ".png" for icon in self.toolbar_icons
        ]
        self.toolbar_icons.insert(6, None)
        self.toolbar_icons.append(None)

        # Add the icons to the toolbar
        for text, tooltip_text, image_file, callback in self.extratoolitems:  #@unusedvariable
            if text is None:
                self.add_customLabelSpacing(num)
            else:
                if  not (text=='PopOut' and self.master_class.btn_popout == "N.A.")\
                and not (text=='Reread' and self.master_class.btn_reread == "N.A."):
                    try:
                        button = self.add_customButtonWithIcon(
                            text=text,
                            file=self.toolbar_icons[num],
                            command=getattr(self, callback),
                            i=num)
                        if tooltip_text is not None:
                            # Custom tooltip class with a half second delay
                            ToolTip(self.root, button, tooltip_text)
                    except IndexError:
                        pass
            num += 1

        # Configure the grid: put fillers before and after the buttons so its centered
        if self.direction == "x":
            tk.Grid.rowconfigure(self, 0, weight=0)
            tk.Grid.columnconfigure(self, 0, weight=1)
            tk.Grid.columnconfigure(self, num + 1, weight=1)
        if self.direction == "y":
            tk.Grid.columnconfigure(self, 0, weight=0)
            tk.Grid.rowconfigure(self, 0, weight=1)
            tk.Grid.rowconfigure(self, num + 1, weight=1)
            tk.Grid.rowconfigure(self, num + 2, weight=1)