Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate NavigationToolbar2GTK3.ctx. #13144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/api/api_changes_3.3/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ These attributes are deprecated. In order to access the parent window, use
also be accessible as ``toolbar.parent()``. The base directory to the icons
is ``os.path.join(mpl.get_data_path(), "images")``.

NavigationToolbar2QT.ctx
~~~~~~~~~~~~~~~~~~~~~~~~
This attribute is deprecated.

Path helpers in :mod:`.bezier`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
18 changes: 11 additions & 7 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,11 @@ def __init__(self, canvas, window):
self.win = window
GObject.GObject.__init__(self)
NavigationToolbar2.__init__(self, canvas)
self.ctx = None

@cbook.deprecated("3.3")
@property
def ctx(self):
return self.canvas.get_property("window").cairo_create()

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

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

self.ctx.new_path()
self.ctx.set_line_width(0.5)
self.ctx.rectangle(rect[0], rect[1], rect[2], rect[3])
self.ctx.set_source_rgb(0, 0, 0)
self.ctx.stroke()
ctx.new_path()
ctx.set_line_width(0.5)
ctx.rectangle(*rect)
ctx.set_source_rgb(0, 0, 0)
ctx.stroke()

def _init_toolbar(self):
self.set_style(Gtk.ToolbarStyle.ICONS)
Expand Down