Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d927de

Browse filesBrowse files
authored
Merge pull request #13144 from anntzer/deprecate-navtoolbar-ctx
Deprecate NavigationToolbar2GTK3.ctx.
2 parents a6c3c22 + c5946e1 commit 4d927de
Copy full SHA for 4d927de

File tree

Expand file treeCollapse file tree

2 files changed

+15
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-7
lines changed

‎doc/api/api_changes_3.3/deprecations.rst

Copy file name to clipboardExpand all lines: doc/api/api_changes_3.3/deprecations.rst
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ These attributes are deprecated. In order to access the parent window, use
373373
also be accessible as ``toolbar.parent()``. The base directory to the icons
374374
is ``os.path.join(mpl.get_data_path(), "images")``.
375375

376+
NavigationToolbar2QT.ctx
377+
~~~~~~~~~~~~~~~~~~~~~~~~
378+
This attribute is deprecated.
379+
376380
Path helpers in :mod:`.bezier`
377381
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
378382

‎lib/matplotlib/backends/backend_gtk3.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_gtk3.py
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,11 @@ def __init__(self, canvas, window):
452452
self.win = window
453453
GObject.GObject.__init__(self)
454454
NavigationToolbar2.__init__(self, canvas)
455-
self.ctx = None
455+
456+
@cbook.deprecated("3.3")
457+
@property
458+
def ctx(self):
459+
return self.canvas.get_property("window").cairo_create()
456460

457461
def set_message(self, s):
458462
self.message.set_label(s)
@@ -464,7 +468,7 @@ def set_cursor(self, cursor):
464468
def draw_rubberband(self, event, x0, y0, x1, y1):
465469
# adapted from
466470
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189744
467-
self.ctx = self.canvas.get_property("window").cairo_create()
471+
ctx = self.canvas.get_property("window").cairo_create()
468472

469473
# todo: instead of redrawing the entire figure, copy the part of
470474
# the figure that was covered by the previous rubberband rectangle
@@ -477,11 +481,11 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
477481
h = abs(y1 - y0)
478482
rect = [int(val) for val in (min(x0, x1), min(y0, y1), w, h)]
479483

480-
self.ctx.new_path()
481-
self.ctx.set_line_width(0.5)
482-
self.ctx.rectangle(rect[0], rect[1], rect[2], rect[3])
483-
self.ctx.set_source_rgb(0, 0, 0)
484-
self.ctx.stroke()
484+
ctx.new_path()
485+
ctx.set_line_width(0.5)
486+
ctx.rectangle(*rect)
487+
ctx.set_source_rgb(0, 0, 0)
488+
ctx.stroke()
485489

486490
def _init_toolbar(self):
487491
self.set_style(Gtk.ToolbarStyle.ICONS)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.