Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Deprecate various wx Toolbar attributes.#17292

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 1 commit intomatplotlib:masterfromanntzer:wxtoolbarattrs
May 2, 2020
Merged
Show file tree
Hide file tree
Changes fromall 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
5 changes: 5 additions & 0 deletionsdoc/api/api_changes_3.3/deprecations.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -392,6 +392,11 @@ NavigationToolbar2QT.ctx
~~~~~~~~~~~~~~~~~~~~~~~~
This attribute is deprecated.

NavigationToolbar2Wx attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``prevZoomRect``, ``retinaFix``, ``savedRetinaImage``, ``wxoverlay``,
``zoomAxes``, ``zoomStartX``, and ``zoomStartY`` attributes are deprecated.

NavigationToolbar2.press and .release
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These methods were called when pressing or releasing a mouse button,
Expand Down
76 changes: 42 additions & 34 deletionslib/matplotlib/backends/backend_wx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1126,12 +1126,20 @@ def __init__(self, canvas):

NavigationToolbar2.__init__(self, canvas)
self._idle = True
self.prevZoomRect = None
self._prevZoomRect = None
# for now, use alternate zoom-rectangle drawing on all
# Macs. N.B. In future versions of wx it may be possible to
# detect Retina displays with window.GetContentScaleFactor()
# and/or dc.GetContentScaleFactor()
self.retinaFix = 'wxMac' in wx.PlatformInfo
self._retinaFix = 'wxMac' in wx.PlatformInfo

prevZoomRect = cbook._deprecate_privatize_attribute("3.3")
retinaFix = cbook._deprecate_privatize_attribute("3.3")
savedRetinaImage = cbook._deprecate_privatize_attribute("3.3")
wxoverlay = cbook._deprecate_privatize_attribute("3.3")
zoomAxes = cbook._deprecate_privatize_attribute("3.3")
zoomStartX = cbook._deprecate_privatize_attribute("3.3")
zoomStartY = cbook._deprecate_privatize_attribute("3.3")

def get_canvas(self, frame, fig):
return type(self.canvas)(frame, -1, fig)
Expand DownExpand Up@@ -1201,53 +1209,53 @@ def set_cursor(self, cursor):
def press_zoom(self, event):
super().press_zoom(event)
if self.mode.name == 'ZOOM':
if not self.retinaFix:
self.wxoverlay = wx.Overlay()
if not self._retinaFix:
self._wxoverlay = wx.Overlay()
else:
if event.inaxes is not None:
self.savedRetinaImage = self.canvas.copy_from_bbox(
self._savedRetinaImage = self.canvas.copy_from_bbox(
event.inaxes.bbox)
self.zoomStartX = event.xdata
self.zoomStartY = event.ydata
self.zoomAxes = event.inaxes
self._zoomStartX = event.xdata
self._zoomStartY = event.ydata
self._zoomAxes = event.inaxes

def release_zoom(self, event):
super().release_zoom(event)
if self.mode.name == 'ZOOM':
# When the mouse is released we reset the overlay and it
# restores the former content to the window.
if not self.retinaFix:
self.wxoverlay.Reset()
del self.wxoverlay
if not self._retinaFix:
self._wxoverlay.Reset()
del self._wxoverlay
else:
del self.savedRetinaImage
if self.prevZoomRect:
self.prevZoomRect.pop(0).remove()
self.prevZoomRect = None
if self.zoomAxes:
self.zoomAxes = None
del self._savedRetinaImage
if self._prevZoomRect:
self._prevZoomRect.pop(0).remove()
self._prevZoomRect = None
if self._zoomAxes:
self._zoomAxes = None

def draw_rubberband(self, event, x0, y0, x1, y1):
if self.retinaFix: # On Macs, use the following code
if self._retinaFix: # On Macs, use the following code
# wx.DCOverlay does not work properly on Retina displays.
rubberBandColor = '#C0C0FF'
if self.prevZoomRect:
self.prevZoomRect.pop(0).remove()
self.canvas.restore_region(self.savedRetinaImage)
X0, X1 = self.zoomStartX, event.xdata
Y0, Y1 = self.zoomStartY, event.ydata
if self._prevZoomRect:
self._prevZoomRect.pop(0).remove()
self.canvas.restore_region(self._savedRetinaImage)
X0, X1 = self._zoomStartX, event.xdata
Y0, Y1 = self._zoomStartY, event.ydata
lineX = (X0, X0, X1, X1, X0)
lineY = (Y0, Y1, Y1, Y0, Y0)
self.prevZoomRect = self.zoomAxes.plot(
self._prevZoomRect = self._zoomAxes.plot(
lineX, lineY, '-', color=rubberBandColor)
self.zoomAxes.draw_artist(self.prevZoomRect[0])
self.canvas.blit(self.zoomAxes.bbox)
self._zoomAxes.draw_artist(self._prevZoomRect[0])
self.canvas.blit(self._zoomAxes.bbox)
return

# Use an Overlay to draw a rubberband-like bounding box.

dc = wx.ClientDC(self.canvas)
odc = wx.DCOverlay(self.wxoverlay, dc)
odc = wx.DCOverlay(self._wxoverlay, dc)
odc.Clear()

# Mac's DC is already the same as a GCDC, and it causes
Expand DownExpand Up@@ -1439,14 +1447,14 @@ def set_cursor(self, cursor):
class RubberbandWx(backend_tools.RubberbandBase):
def __init__(self, *args, **kwargs):
backend_tools.RubberbandBase.__init__(self, *args, **kwargs)
self.wxoverlay = None
self._wxoverlay = None

def draw_rubberband(self, x0, y0, x1, y1):
# Use an Overlay to draw a rubberband-like bounding box.
if self.wxoverlay is None:
self.wxoverlay = wx.Overlay()
if self._wxoverlay is None:
self._wxoverlay = wx.Overlay()
dc = wx.ClientDC(self.canvas)
odc = wx.DCOverlay(self.wxoverlay, dc)
odc = wx.DCOverlay(self._wxoverlay, dc)
odc.Clear()

dc = wx.GCDC(dc)
Expand DownExpand Up@@ -1477,10 +1485,10 @@ def draw_rubberband(self, x0, y0, x1, y1):
dc.DrawRectangle(rect)

def remove_rubberband(self):
if self.wxoverlay is None:
if self._wxoverlay is None:
return
self.wxoverlay.Reset()
self.wxoverlay = None
self._wxoverlay.Reset()
self._wxoverlay = None

else:
# on Mac OS retina displays DCOverlay does not work
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/cbook/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@
from .deprecation import (
deprecated, warn_deprecated,
_rename_parameter, _delete_parameter, _make_keyword_only,
_deprecate_method_override,
_deprecate_method_override, _deprecate_privatize_attribute,
_suppress_matplotlib_deprecation_warning,
MatplotlibDeprecationWarning, mplDeprecation)

Expand Down
23 changes: 23 additions & 0 deletionslib/matplotlib/cbook/deprecation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -251,6 +251,29 @@ def wrapper(*args, **kwargs):
return deprecate


class _deprecate_privatize_attribute:
"""
Helper to deprecate public access to an attribute.

This helper should only be used at class scope, as follows::

class Foo:
attr = _deprecate_privatize_attribute(*args, **kwargs)

where *all* parameters are forwarded to `deprecated`. This form makes
``attr`` a property which forwards access to ``self._attr`` (same name but
with a leading underscore), with a deprecation warning. Note that the
attribute name is derived from *the name this helper is assigned to*.
"""

def __init__(self, *args, **kwargs):
self.deprecator = deprecated(*args, **kwargs)

def __set_name__(self, owner, name):
setattr(owner, name, self.deprecator(
property(lambda self: getattr(self, f"_{name}")), name=name))


def _rename_parameter(since, old, new, func=None):
"""
Decorator indicating that parameter *old* of *func* is renamed to *new*.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp