Example #1
0
 def __init__( self, canvas, parent ):
     self.canvas = canvas
     self.buttons = {}
     qt.QWidget.__init__( self, parent )
     self.layout = qt.QHBoxLayout( self )
     self.layout.setMargin( 2 )
     NavigationToolbar2.__init__( self, canvas )
Example #2
0
 def __init__(self, canvas, window):
     self.window = window
     self.canvas = canvas
     qt.QToolBar.__init__(self, "Navigator2", window, qt.Qt.DockBottom)
     NavigationToolbar2.__init__(self, canvas)
     # If we don't do this, the status bar is hidden until needed.
     self.window.statusBar().message(" ")
Example #3
0
 def release_pan(self, event):
     pos = (event.x, event.y)
     self.callBackHideOverlay()
     NavigationToolbar2.release_pan(self, event)
     if event.button != 2:
         if self.panPos and self.panPos != pos:
             self.clear_auto()
     self.panPos = None
Example #4
0
 def __init__(self, canvas, wind):
     self.wind = wind
     #wx.ToolBar.__init__(self, canvas.GetParent(), -1)
     aui.AuiToolBar.__init__(self, wind, -1, wx.DefaultPosition, wx.DefaultSize, agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW | aui.AUI_TB_VERTICAL)
     NavigationToolbar2.__init__(self, canvas)
     self.canvas = canvas
     self._idle = True
     self.statbar = None
Example #5
0
    def __init__( self, parent, canvas ):
        self.canvas = canvas
        qt.QWidget.__init__( self, parent )

        # Layout toolbar buttons horizontally.
        self.layout = qt.QHBoxLayout( self )
        self.layout.setMargin( 2 )
        
        NavigationToolbar2.__init__( self, canvas )
    def __init__(self, canvas, parent):
        self.canvas = canvas
        QtGui.QWidget.__init__(self, parent)

        self.layout = QtGui.QHBoxLayout(self)
        self.layout.setMargin(0)
        self.layout.setSpacing(0)

        NavigationToolbar2.__init__(self, canvas)
Example #7
0
    def __init__(self, canvas, window):
        self.win = window
        gtk.Toolbar.__init__(self)
        NavigationToolbar2.__init__(self, canvas)
        self._idleId = 0

        def destroy(*args):
            self.fileselect.destroy()
        self.connect("destroy", destroy)
Example #8
0
    def __init__(self, canvas, parent, coordinates=True):
        """ coordinates: should we show the coordinates on the right? """
        self.canvas = canvas
        self.coordinates = coordinates
        self._actions = {}
        """A mapping of toolitem method names to their QActions"""

        QtGui.QToolBar.__init__(self, parent)
        NavigationToolbar2.__init__(self, canvas)
Example #9
0
 def update(self):
     _focus = windowing.FocusManager()
     self._axes = self.canvas.figure.axes
     naxes = len(self._axes)
     #if not hasattr(self, "omenu"):
     #    self.set_active(range(naxes))
     #    self.omenu = AxisMenu(master=self, naxes=naxes)
     #else:
     #    self.omenu.adjust(naxes)
     NavigationToolbar2.update(self)
Example #10
0
 def __init__(self, canvas, view, subplots=False):
     self.view = view
     self.main_window = view.locate_widget('main_window')
     self.toolbar = view.locate_widget('toolbar')
     self.statusbar = view.locate_widget('statusbar')
     self.subplots = subplots
     #Gtk.Toolbar.__init__(self)
     NavigationToolbar2.__init__(self, canvas)
     self._idle_draw_id = 0
     view.ui.main_frame.connect('destroy', self.on_destroy)
Example #11
0
    def __init__(self, canvas, parent):
        self.canvas = canvas
        QtGui.QWidget.__init__( self, parent )

        # Layout toolbar buttons horizontally.
        self.layout = QtGui.QHBoxLayout( self )
        self.layout.setMargin( 2 )
        self.layout.setSpacing( 0 )

        NavigationToolbar2.__init__( self, canvas )
Example #12
0
 def pan(self, *args):
     self.pan_selected = not self.pan_selected
     self.zoom_selected = False
     self.canvas.canvas._draw_overlay = False
     if self.pan_selected:
         self.bPan.widget().value(1)
     else:
         self.bPan.widget().value(0)
     if self.zoom_selected:
         self.bZoom.widget().value(1)
     else:
         self.bZoom.widget().value(0)
     NavigationToolbar2.pan(self, args)
Example #13
0
    def __init__(self, canvas, parent, coordinates=True):
        """ coordinates: should we show the coordinates on the right? """
        self.canvas = canvas
        self.parent = parent
        self.coordinates = coordinates
        self._actions = {}

        self.cursor_line = None
        self.cursor_cid = None
        self.color = 'r'

        QToolBar.__init__(self, parent)
        NavigationToolbar2.__init__(self, canvas)
Example #14
0
 def zoom(self, *args):
     self.zoom_selected = not self.zoom_selected
     self.canvas.canvas._draw_overlay = self.zoom_selected
     self.pan_selected = False
     if self.pan_selected:
         self.bPan.widget().value(1)
     else:
         self.bPan.widget().value(0)
     if self.zoom_selected:
         self.bZoom.widget().value(1)
     else:
         self.bZoom.widget().value(0)
     NavigationToolbar2.zoom(self, args)
Example #15
0
    def __init__(self, canvas, window):
        self.win = window
        GObject.GObject.__init__(self)

        self.set_style(Gtk.ToolbarStyle.ICONS)

        self._gtk_ids = {}
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.insert(Gtk.SeparatorToolItem(), -1)
                continue
            image = Gtk.Image.new_from_gicon(
                Gio.Icon.new_for_string(
                    str(cbook._get_data_path('images',
                                             f'{image_file}-symbolic.svg'))),
                Gtk.IconSize.LARGE_TOOLBAR)
            self._gtk_ids[text] = tbutton = (
                Gtk.ToggleToolButton() if callback in ['zoom', 'pan'] else
                Gtk.ToolButton())
            tbutton.set_label(text)
            tbutton.set_icon_widget(image)
            self.insert(tbutton, -1)
            # Save the handler id, so that we can block it as needed.
            tbutton._signal_handler = tbutton.connect(
                'clicked', getattr(self, callback))
            tbutton.set_tooltip_text(tooltip_text)

        toolitem = Gtk.SeparatorToolItem()
        self.insert(toolitem, -1)
        toolitem.set_draw(False)
        toolitem.set_expand(True)

        # This filler item ensures the toolbar is always at least two text
        # lines high. Otherwise the canvas gets redrawn as the mouse hovers
        # over images because those use two-line messages which resize the
        # toolbar.
        toolitem = Gtk.ToolItem()
        self.insert(toolitem, -1)
        label = Gtk.Label()
        label.set_markup(
            '<small>\N{NO-BREAK SPACE}\n\N{NO-BREAK SPACE}</small>')
        toolitem.add(label)

        toolitem = Gtk.ToolItem()
        self.insert(toolitem, -1)
        self.message = Gtk.Label()
        toolitem.add(self.message)

        self.show_all()

        NavigationToolbar2.__init__(self, canvas)
 def __init__(self, canvas, frame):
     self._frame = frame
     self._tools = {}
     self._lastrect = None
     NavigationToolbar2.__init__(self, canvas)
     self._idle = True
     clsCursor = javabridge.JClassWrapper('java.awt.Cursor')
     self.cursor_map = {
         cursors.MOVE: clsCursor(clsCursor.MOVE_CURSOR),
         cursors.HAND: clsCursor(clsCursor.HAND_CURSOR),
         cursors.POINTER: clsCursor(clsCursor.DEFAULT_CURSOR),
         cursors.SELECT_REGION: clsCursor(clsCursor.CROSSHAIR_CURSOR)
     }
     self.white = javabridge.JClassWrapper('java.awt.Color').WHITE
Example #17
0
 def __init__(self, canvas, wind):
     self.wind = wind
     #wx.ToolBar.__init__(self, canvas.GetParent(), -1)
     aui.AuiToolBar.__init__(self,
                             wind,
                             -1,
                             wx.DefaultPosition,
                             wx.DefaultSize,
                             agwStyle=aui.AUI_TB_DEFAULT_STYLE
                             | aui.AUI_TB_OVERFLOW | aui.AUI_TB_VERTICAL)
     NavigationToolbar2.__init__(self, canvas)
     self.canvas = canvas
     self._idle = True
     self.statbar = None
Example #18
0
    def __init__(self, parent, canvas, direction='h'):
        #NavigationToolbar.__init__(self,parent,canevas)
        #self.layout = QVBoxLayout( self )

        self.canvas = canvas
        QWidget.__init__(self, parent)

        if direction == 'h':
            self.layout = QHBoxLayout(self)
        else:
            self.layout = QVBoxLayout(self)

        self.layout.setMargin(2)
        self.layout.setSpacing(0)

        NavigationToolbar2.__init__(self, canvas)
	def __init__(self , parent , canvas , direction = 'h' ) :
		#NavigationToolbar.__init__(self,parent,canevas)
		#self.layout = QVBoxLayout( self )

		self.canvas = canvas
		QWidget.__init__( self, parent )

		if direction=='h' :
			self.layout = QHBoxLayout( self )
		else :
			self.layout = QVBoxLayout( self )

		self.layout.setMargin( 2 )
		self.layout.setSpacing( 0 )

		NavigationToolbar2.__init__( self, canvas )
Example #20
0
    def __init__(self,
                 canvas,
                 parent,
                 coordinates=True,
                 darkMode=True,
                 main_dir=None):
        self.canvas = canvas
        self.parent = parent
        self.coordinates = coordinates
        self._actions = {}

        self.main_dir = main_dir  #* Pass BASEDIR directly from mainwindow
        self.darkMode = darkMode

        QtWidgets.QToolBar.__init__(self, parent)
        NavigationToolbar2.__init__(self, canvas)
Example #21
0
    def __init__(self, canvas, window, *, pack_toolbar=True):
        # Avoid using self.window (prefer self.canvas.get_tk_widget().master),
        # so that Tool implementations can reuse the methods.
        self.window = window

        tk.Frame.__init__(self,
                          master=window,
                          borderwidth=2,
                          width=int(canvas.figure.bbox.width),
                          height=50)

        self._buttons = {}
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                # Add a spacer; return value is unused.
                self._Spacer()
            else:
                self._buttons[text] = button = self._Button(
                    text,
                    str(cbook._get_data_path(f"images/{image_file}.png")),
                    toggle=callback in ["zoom", "pan"],
                    command=getattr(self, callback),
                )
                if tooltip_text is not None:
                    ToolTip.createToolTip(button, tooltip_text)

        self._label_font = tkinter.font.Font(root=window, size=10)

        # This filler item ensures the toolbar is always at least two text
        # lines high. Otherwise the canvas gets redrawn as the mouse hovers
        # over images because those use two-line messages which resize the
        # toolbar.
        label = tk.Label(master=self,
                         font=self._label_font,
                         text='\N{NO-BREAK SPACE}\n\N{NO-BREAK SPACE}')
        label.pack(side=tk.RIGHT)

        self.message = tk.StringVar(master=self)
        self._message_label = tk.Label(master=self,
                                       font=self._label_font,
                                       textvariable=self.message)
        self._message_label.pack(side=tk.RIGHT)

        NavigationToolbar2.__init__(self, canvas)
        if pack_toolbar:
            self.pack(side=tk.BOTTOM, fill=tk.X)
Example #22
0
    def __init__(self, canvas):
        self.canvas = canvas
        self.widget = canvas.widget
        NavigationToolbar2.__init__(self, canvas)

        # The rest used to be: def _init_toolbar(self): (before matplotlib 3.3)

        # self.basedir = os.path.join(matplotlib.rcParams['datapath'], 'images')

        descs = []

        for text, tooltip_text, image_file, method_name in self.toolitems:
            desc = Gateway.gateway.jvm.org.omnetpp.scave.pychart.ActionDescription(
                text, tooltip_text, image_file, method_name)
            descs.append(desc)

        Gateway.widget_provider.setPlotActions(self.canvas.num, descs)
Example #23
0
    def __init__(
            self,  # pylint: disable=super-init-not-called
            canvas: FigureCanvasTkAgg,
            window: SessionGraph,
            *,
            pack_toolbar: bool = True) -> None:

        # Avoid using self.window (prefer self.canvas.get_tk_widget().master),
        # so that Tool implementations can reuse the methods.

        ttk.Frame.__init__(
            self,  # pylint:disable=non-parent-init-called
            master=window,
            width=int(canvas.figure.bbox.width),
            height=50)

        sep = ttk.Frame(self, height=2, relief=tk.RIDGE)
        sep.pack(fill=tk.X, pady=(5, 0), side=tk.TOP)

        btnframe = ttk.Frame(
            self)  # Add a button frame to consistently line up GUI
        btnframe.pack(fill=tk.X, padx=5, pady=5, side=tk.RIGHT)

        self._buttons = {}
        for text, tooltip_text, image_file, callback in self.toolitems:
            self._buttons[text] = button = self._Button(
                btnframe,
                text,
                image_file,
                toggle=callback in ["zoom", "pan"],
                command=getattr(self, callback),
            )
            if tooltip_text is not None:
                Tooltip(button, text=tooltip_text, wrap_length=200)

        self.message = tk.StringVar(master=self)
        self._message_label = ttk.Label(master=self, textvariable=self.message)
        self._message_label.pack(side=tk.LEFT,
                                 padx=5)  # Additional left padding

        NavigationToolbar2.__init__(self, canvas)  # pylint:disable=non-parent-init-called
        if pack_toolbar:
            self.pack(side=tk.BOTTOM, fill=tk.X)
Example #24
0
    def send_message(self, event):
        """Call `matplotlib.backend_managers.ToolManager.message_event`."""
        if self.toolmanager.messagelock.locked():
            return

        from matplotlib.backend_bases import NavigationToolbar2
        message = NavigationToolbar2._mouse_event_to_message(event)
        if message is None:
            message = ' '
        self.toolmanager.message_event(message, self)
    def __init__(self, canvas, window):
        self.win = window
        Gtk.Box.__init__(self)

        self.add_css_class('toolbar')

        self._gtk_ids = {}
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.append(Gtk.Separator())
                continue
            image = Gtk.Image.new_from_gicon(
                Gio.Icon.new_for_string(
                    str(
                        cbook._get_data_path('images',
                                             f'{image_file}-symbolic.svg'))))
            self._gtk_ids[text] = button = (Gtk.ToggleButton() if callback in [
                'zoom', 'pan'
            ] else Gtk.Button())
            button.set_child(image)
            button.add_css_class('flat')
            button.add_css_class('image-button')
            # Save the handler id, so that we can block it as needed.
            button._signal_handler = button.connect('clicked',
                                                    getattr(self, callback))
            button.set_tooltip_text(tooltip_text)
            self.append(button)

        # This filler item ensures the toolbar is always at least two text
        # lines high. Otherwise the canvas gets redrawn as the mouse hovers
        # over images because those use two-line messages which resize the
        # toolbar.
        label = Gtk.Label()
        label.set_markup(
            '<small>\N{NO-BREAK SPACE}\n\N{NO-BREAK SPACE}</small>')
        label.set_hexpand(True)  # Push real message to the right.
        self.append(label)

        self.message = Gtk.Label()
        self.append(self.message)

        NavigationToolbar2.__init__(self, canvas)
Example #26
0
    def __init__(self, canvas, parent, coordinates=True):
        """coordinates: should we show the coordinates on the right?"""
        QtWidgets.QToolBar.__init__(self, parent)
        self.setAllowedAreas(
            QtCore.Qt.ToolBarArea(
                _to_int(_enum("QtCore.Qt.ToolBarArea").TopToolBarArea)
                | _to_int(_enum("QtCore.Qt.ToolBarArea").BottomToolBarArea)))

        self.coordinates = coordinates
        self._actions = {}  # mapping of toolitem method names to QActions.
        self._subplot_dialog = None

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.addSeparator()
            else:
                a = self.addAction(self._icon(image_file + '.png'), text,
                                   getattr(self, callback))
                self._actions[callback] = a
                if callback in ['zoom', 'pan']:
                    a.setCheckable(True)
                if tooltip_text is not None:
                    a.setToolTip(tooltip_text)

        # Add the (x, y) location widget at the right side of the toolbar
        # The stretch factor is 1 which means any resizing of the toolbar
        # will resize this label instead of the buttons.
        if self.coordinates:
            self.locLabel = QtWidgets.QLabel("", self)
            self.locLabel.setAlignment(
                QtCore.Qt.AlignmentFlag(
                    _to_int(_enum("QtCore.Qt.AlignmentFlag").AlignRight)
                    | _to_int(_enum("QtCore.Qt.AlignmentFlag").AlignVCenter)))
            self.locLabel.setSizePolicy(
                QtWidgets.QSizePolicy(
                    _enum("QtWidgets.QSizePolicy.Policy").Expanding,
                    _enum("QtWidgets.QSizePolicy.Policy").Ignored,
                ))
            labelAction = self.addWidget(self.locLabel)
            labelAction.setVisible(True)

        NavigationToolbar2.__init__(self, canvas)
Example #27
0
    def __init__(self, canvas):
        # Taken from matplotlib/backend_wx.py but added style:
        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
        self.statbar = None
        self.prevZoomRect = None
        self.zoom()  # NOTE: #22 BREAK cursors #12!
        self.retinaFix = 'wxMac' in wx.PlatformInfo
        # --- Modif
        #NavigationToolbar2Wx.__init__(self, plotCanvas)
        self.DeleteToolByPos(1)
        self.DeleteToolByPos(1)
        self.DeleteToolByPos(3)
Example #28
0
    def __init__(self, canvas, window):
        self.win = window
        GObject.GObject.__init__(self)

        self.set_style(Gtk.ToolbarStyle.ICONS)

        self._gtk_ids = {}
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.insert(Gtk.SeparatorToolItem(), -1)
                continue
            image = Gtk.Image.new_from_gicon(
                Gio.Icon.new_for_string(
                    str(
                        cbook._get_data_path('images',
                                             f'{image_file}-symbolic.svg'))),
                Gtk.IconSize.LARGE_TOOLBAR)
            self._gtk_ids[text] = tbutton = (Gtk.ToggleToolButton()
                                             if callback in ['zoom', 'pan']
                                             else Gtk.ToolButton())
            tbutton.set_label(text)
            tbutton.set_icon_widget(image)
            self.insert(tbutton, -1)
            # Save the handler id, so that we can block it as needed.
            tbutton._signal_handler = tbutton.connect('clicked',
                                                      getattr(self, callback))
            tbutton.set_tooltip_text(tooltip_text)

        toolitem = Gtk.SeparatorToolItem()
        self.insert(toolitem, -1)
        toolitem.set_draw(False)
        toolitem.set_expand(True)

        toolitem = Gtk.ToolItem()
        self.insert(toolitem, -1)
        self.message = Gtk.Label()
        toolitem.add(self.message)

        self.show_all()

        NavigationToolbar2.__init__(self, canvas)
Example #29
0
    def __init__(self, canvas, parent, coordinates=True):
        """coordinates: should we show the coordinates on the right?"""
        QtWidgets.QToolBar.__init__(self, parent)

        self._parent = parent
        self.coordinates = coordinates
        self._actions = {}  # mapping of toolitem method names to QActions.

        background_color = self.palette().color(self.backgroundRole())
        foreground_color = self.palette().color(self.foregroundRole())
        icon_color = (foreground_color
                      if background_color.value() < 128 else None)

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.addSeparator()
            else:
                a = self.addAction(self._icon(image_file + '.png', icon_color),
                                   text, getattr(self, callback))
                self._actions[callback] = a
                if callback in ['zoom', 'pan']:
                    a.setCheckable(True)
                if tooltip_text is not None:
                    a.setToolTip(tooltip_text)

        # Add the (x, y) location widget at the right side of the toolbar
        # The stretch factor is 1 which means any resizing of the toolbar
        # will resize this label instead of the buttons.
        if self.coordinates:
            self.locLabel = QtWidgets.QLabel("", self)
            self.locLabel.setAlignment(QtCore.Qt.AlignRight
                                       | QtCore.Qt.AlignTop)
            self.locLabel.setSizePolicy(
                QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                      QtWidgets.QSizePolicy.Ignored))
            labelAction = self.addWidget(self.locLabel)
            labelAction.setVisible(True)

        NavigationToolbar2.__init__(self, canvas)
Example #30
0
    def __init__(self, canvas, parent, coordinates=True):
        """ coordinates: should we show the coordinates on the right? """
        self.canvas = canvas
        self.parent = parent
        self._nav_stack = cbook.Stack()
        self.coordinates = coordinates
        self._actions = {}
        """A mapping of toolitem method names to their QActions"""
        self.toolitems = (
            ('Home', 'Reset original view', 'home', 'home'),
            ('Back', 'Back to previous view', 'back', 'back'),
            ('Forward', 'Forward to next view', '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'),
            # ('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'),
            (None, None, None, None),
            # ('Save', 'Save the figure', 'filesave', 'save_figure'),
        )

        QtWidgets.QToolBar.__init__(self, parent)
        NavigationToolbar2.__init__(self, canvas)
Example #31
0
def test_interactive_colorbar(plot_func, orientation, tool, button, expected):
    fig, ax = plt.subplots()
    data = np.arange(12).reshape((4, 3))
    vmin0, vmax0 = 0, 10
    coll = getattr(ax, plot_func)(data, vmin=vmin0, vmax=vmax0)

    cb = fig.colorbar(coll, ax=ax, orientation=orientation)
    if plot_func == "contourf":
        # Just determine we can't navigate and exit out of the test
        assert not cb.ax.get_navigate()
        return

    assert cb.ax.get_navigate()

    # Mouse from 4 to 6 (data coordinates, "d").
    vmin, vmax = 4, 6
    # The y coordinate doesn't matter, it just needs to be between 0 and 1
    # However, we will set d0/d1 to the same y coordinate to test that small
    # pixel changes in that coordinate doesn't cancel the zoom like a normal
    # axes would.
    d0 = (vmin, 0.5)
    d1 = (vmax, 0.5)
    # Swap them if the orientation is vertical
    if orientation == "vertical":
        d0 = d0[::-1]
        d1 = d1[::-1]
    # Convert to screen coordinates ("s").  Events are defined only with pixel
    # precision, so round the pixel values, and below, check against the
    # corresponding xdata/ydata, which are close but not equal to d0/d1.
    s0 = cb.ax.transData.transform(d0).astype(int)
    s1 = cb.ax.transData.transform(d1).astype(int)

    # Set up the mouse movements
    start_event = MouseEvent("button_press_event", fig.canvas, *s0, button)
    stop_event = MouseEvent("button_release_event", fig.canvas, *s1, button)

    tb = NavigationToolbar2(fig.canvas)
    if tool == "zoom":
        tb.zoom()
        tb.press_zoom(start_event)
        tb.drag_zoom(stop_event)
        tb.release_zoom(stop_event)
    else:
        tb.pan()
        tb.press_pan(start_event)
        tb.drag_pan(stop_event)
        tb.release_pan(stop_event)

    # Should be close, but won't be exact due to screen integer resolution
    assert (cb.vmin, cb.vmax) == pytest.approx(expected, abs=0.15)
Example #32
0
def test_interactive_zoom():
    fig, ax = plt.subplots()
    ax.set(xscale="logit")
    assert ax.get_navigate_mode() is None

    tb = NavigationToolbar2(fig.canvas)
    tb.zoom()
    assert ax.get_navigate_mode() == 'ZOOM'

    xlim0 = ax.get_xlim()
    ylim0 = ax.get_ylim()

    # Zoom from x=1e-6, y=0.1 to x=1-1e-5, 0.8 (data coordinates, "d").
    d0 = (1e-6, 0.1)
    d1 = (1 - 1e-5, 0.8)
    # Convert to screen coordinates ("s").  Events are defined only with pixel
    # precision, so round the pixel values, and below, check against the
    # corresponding xdata/ydata, which are close but not equal to d0/d1.
    s0 = ax.transData.transform(d0).astype(int)
    s1 = ax.transData.transform(d1).astype(int)

    # Zoom in.
    start_event = MouseEvent("button_press_event", fig.canvas, *s0,
                             MouseButton.LEFT)
    fig.canvas.callbacks.process(start_event.name, start_event)
    stop_event = MouseEvent("button_release_event", fig.canvas, *s1,
                            MouseButton.LEFT)
    fig.canvas.callbacks.process(stop_event.name, stop_event)
    assert ax.get_xlim() == (start_event.xdata, stop_event.xdata)
    assert ax.get_ylim() == (start_event.ydata, stop_event.ydata)

    # Zoom out.
    start_event = MouseEvent("button_press_event", fig.canvas, *s1,
                             MouseButton.RIGHT)
    fig.canvas.callbacks.process(start_event.name, start_event)
    stop_event = MouseEvent("button_release_event", fig.canvas, *s0,
                            MouseButton.RIGHT)
    fig.canvas.callbacks.process(stop_event.name, stop_event)
    # Absolute tolerance much less than original xmin (1e-7).
    assert ax.get_xlim() == pytest.approx(xlim0, rel=0, abs=1e-10)
    assert ax.get_ylim() == pytest.approx(ylim0, rel=0, abs=1e-10)

    tb.zoom()
    assert ax.get_navigate_mode() is None

    assert not ax.get_autoscalex_on() and not ax.get_autoscaley_on()
Example #33
0
 def __init__(self, canvas, window):
     self.win = window
     GObject.GObject.__init__(self)
     NavigationToolbar2.__init__(self, canvas)
     self.ctx = None
Example #34
0
 def __init__(self, canvas, parent, coordinates=True):
     """ coordinates: should we show the coordinates on the right? """
     self.canvas = canvas
     self.coordinates = coordinates
     QtGui.QToolBar.__init__(self, parent)
     NavigationToolbar2.__init__(self, canvas)
Example #35
0
 def __init__(self, canvas, window):
     self.canvas = canvas
     # Avoid using self.window (prefer self.canvas.manager.window), so that
     # Tool implementations can reuse the methods.
     self.window = window
     NavigationToolbar2.__init__(self, canvas)
Example #36
0
 def __init__(self, canvas, window):
     self.win = window
     GObject.GObject.__init__(self)
     NavigationToolbar2.__init__(self, canvas)
     self.ctx = None
Example #37
0
 def __init__(self, canvas, parent):
     self.canvas = canvas
     NavigationToolbar2.__init__(self, canvas)
Example #38
0
 def release_zoom(self, event):
     self.callBackHideOverlay()
     NavigationToolbar2.release_zoom(self, event)
     self.clear_auto()
Example #39
0
 def __init__(self, canvas, window):
     self.canvas = canvas
     self.window = window
     self._idle = True
     NavigationToolbar2.__init__(self, canvas)
 def __init__(self, canvas):
     NavigationToolbar2.__init__(self, canvas)
Example #41
0
 def pan(self, *args):
     NavigationToolbar2.pan(self, *args)
Example #42
0
 def update(self):
     self._axes = self.canvas.figure.axes
     naxes = len(self._axes)
     self.omenu.adjust(naxes)
     NavigationToolbar2.update(self)
Example #43
0
 def zoom(self, *args):
     NavigationToolbar2.zoom(self, *args)
Example #44
0
 def __init__(self, canvas, figman):
     self.canvas = canvas
     self.figman = figman
     NavigationToolbar2.__init__(self, canvas)
     self.pan_selected = False
     self.zoom_selected = False
Example #45
0
 def drag_pan(self, event):
     if not self.panPos:
         self.panPos = (event.x, event.y)
     NavigationToolbar2.drag_pan(self, event)
Example #46
0
 def update(self):
     self._axes = self.canvas.figure.axes
     naxes = len(self._axes)
     self.omenu.adjust(naxes)
     NavigationToolbar2.update(self)
Example #47
0
 def __init__(self, canvas, parent, coordinates=True):
     """ coordinates: should we show the coordinates on the right? """
     self.canvas = canvas
     self.coordinates = coordinates
     QtGui.QToolBar.__init__( self, parent )
     NavigationToolbar2.__init__( self, canvas )
Example #48
0
 def update(self):
     self._axes = self.canvas.figure.axes
     with _restore_foreground_window_at_end():
         NavigationToolbar2.update(self)
Example #49
0
 def forward(self, event):
     self.callBackHideOverlay()
     NavigationToolbar2.forward(self, event)
     self.clear_auto()
Example #50
0
 def __init__(self, canvas, window):
     self.canvas = canvas
     self.window = window
     self._idle = True
     #Tk.Frame.__init__(self, master=self.canvas._tkcanvas)
     NavigationToolbar2.__init__(self, canvas)
Example #51
0
 def pan( self, *args ):
     self.buttons[ 'Zoom' ].setOn( False )
     NavigationToolbar2.pan( self, *args )
Example #52
0
 def __init__(self, canvas, window):
     self.win = window
     gtk.Toolbar.__init__(self)
     NavigationToolbar2.__init__(self, canvas)
     self._idle_draw_id = 0
Example #53
0
 def zoom( self, *args ):
     self.buttons[ 'Pan' ].setOn( False )
     NavigationToolbar2.zoom( self, *args )
Example #54
0
 def __init__(self, canvas, window):
     self.win = window
     gtk.Toolbar.__init__(self)
     NavigationToolbar2.__init__(self, canvas)
     self._idle_draw_id = 0
Example #55
0
 def __init__(self, canvas, window):
     self.canvas = canvas
     self.window = window
     NavigationToolbar2.__init__(self, canvas)
Example #56
0
 def update(self):
     _focus = windowing.FocusManager()
     self._axes = self.canvas.figure.axes
     NavigationToolbar2.update(self)
Example #57
0
 def update(self):
     _focus = windowing.FocusManager()
     self._axes = self.canvas.figure.axes
     NavigationToolbar2.update(self)
Example #58
0
 def __init__(self, canvas, window):
     self.canvas = canvas
     self.window = window
     self._idle = True
     #Tk.Frame.__init__(self, master=self.canvas._tkcanvas)
     NavigationToolbar2.__init__(self, canvas)
Example #59
0
 def __init__(self, canvas, figman):
     self.canvas = canvas
     self.figman = figman
     NavigationToolbar2.__init__(self, canvas)
     self.pan_selected = False
     self.zoom_selected = False