|
2 | 2 | import io |
3 | 3 | import os |
4 | 4 | from pathlib import Path |
5 | | -import sys |
6 | 5 |
|
7 | 6 | import matplotlib as mpl |
8 | 7 | from matplotlib import _api, backend_tools, cbook |
9 | 8 | from matplotlib._pylab_helpers import Gcf |
10 | 9 | from matplotlib.backend_bases import ( |
11 | | - _Backend, FigureCanvasBase, FigureManagerBase, NavigationToolbar2, |
12 | | - TimerBase, ToolContainerBase) |
13 | | -from matplotlib.backend_tools import Cursors |
14 | | -from matplotlib.figure import Figure |
15 | | -from matplotlib.widgets import SubplotTool |
| 10 | + FigureCanvasBase, FigureManagerBase, ToolContainerBase) |
16 | 11 |
|
17 | 12 | try: |
18 | 13 | import gi |
|
31 | 26 | from gi.repository import Gio, GLib, GObject, Gtk, Gdk, GdkPixbuf |
32 | 27 | from . import _backend_gtk |
33 | 28 | from ._backend_gtk import ( |
34 | | - _create_application, _shutdown_application, |
35 | 29 | backend_version, _BackendGTK, _NavigationToolbar2GTK, |
36 | 30 | TimerGTK as TimerGTK4, |
37 | 31 | ) |
38 | 32 |
|
39 | 33 |
|
40 | | -def _mpl_to_gtk_cursor(mpl_cursor): |
41 | | - return _api.check_getitem({ |
42 | | - Cursors.MOVE: "move", |
43 | | - Cursors.HAND: "pointer", |
44 | | - Cursors.POINTER: "default", |
45 | | - Cursors.SELECT_REGION: "crosshair", |
46 | | - Cursors.WAIT: "wait", |
47 | | - Cursors.RESIZE_HORIZONTAL: "ew-resize", |
48 | | - Cursors.RESIZE_VERTICAL: "ns-resize", |
49 | | - }, cursor=mpl_cursor) |
50 | | - |
51 | | - |
52 | 34 | class FigureCanvasGTK4(Gtk.DrawingArea, FigureCanvasBase): |
53 | 35 | required_interactive_framework = "gtk4" |
54 | 36 | supports_blit = False |
@@ -108,7 +90,7 @@ def destroy(self): |
108 | 90 |
|
109 | 91 | def set_cursor(self, cursor): |
110 | 92 | # docstring inherited |
111 | | - self.set_cursor_from_name(_mpl_to_gtk_cursor(cursor)) |
| 93 | + self.set_cursor_from_name(_backend_gtk.mpl_to_gtk_cursor_name(cursor)) |
112 | 94 |
|
113 | 95 | def _mouse_event_coords(self, x, y): |
114 | 96 | """ |
@@ -281,10 +263,10 @@ class FigureManagerGTK4(FigureManagerBase): |
281 | 263 | The Gtk.VBox containing the canvas and toolbar |
282 | 264 | window : Gtk.Window |
283 | 265 | The Gtk.Window |
284 | | -
|
285 | 266 | """ |
| 267 | + |
286 | 268 | def __init__(self, canvas, num): |
287 | | - app = _create_application() |
| 269 | + app = _backend_gtk._create_application() |
288 | 270 | self.window = Gtk.Window() |
289 | 271 | app.add_window(self.window) |
290 | 272 | super().__init__(canvas, num) |
@@ -422,7 +404,7 @@ def __init__(self, canvas, window): |
422 | 404 | self.message = Gtk.Label() |
423 | 405 | self.append(self.message) |
424 | 406 |
|
425 | | - NavigationToolbar2.__init__(self, canvas) |
| 407 | + _NavigationToolbar2GTK.__init__(self, canvas) |
426 | 408 |
|
427 | 409 | def save_figure(self, *args): |
428 | 410 | dialog = Gtk.FileChooserNative( |
@@ -688,7 +670,7 @@ def trigger(self, *args, **kwargs): |
688 | 670 | Toolbar = ToolbarGTK4 |
689 | 671 |
|
690 | 672 |
|
691 | | -@_Backend.export |
| 673 | +@_BackendGTK.export |
692 | 674 | class _BackendGTK4(_BackendGTK): |
693 | 675 | FigureCanvas = FigureCanvasGTK4 |
694 | 676 | FigureManager = FigureManagerGTK4 |
0 commit comments