Skip to content

Commit

Permalink
add locking behavior for panning (#2)
Browse files Browse the repository at this point in the history
* add locking behavior for panning

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ianhi and pre-commit-ci[bot] authored Jul 16, 2022
1 parent 24035a5 commit 018adf2
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 32 deletions.
2 changes: 0 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
[![codecov](https://codecov.io/gh/ianhi/mpl-pan-zoom/branch/master/graph/badge.svg)](https://codecov.io/gh/ianhi/mpl-pan-zoom)

Panning and zooming with the mouse in Matplotlib.


1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# -- Path setup --------------------------------------------------------------

import inspect

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
5 changes: 3 additions & 2 deletions mpl_pan_zoom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
__author__ = "Ian Hunt-Isaak"
__email__ = "ianhuntisaak@gmail.com"

from ._zoom import zoom_factory
from ._pan import PanManager
from matplotlib.backend_bases import MouseButton

from ._pan import PanManager
from ._zoom import zoom_factory

__all__ = [
"__version__",
"__author__",
Expand Down
9 changes: 9 additions & 0 deletions mpl_pan_zoom/_pan.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,26 @@ def disable(self):

self._id_press = None
self._id_release = None
# just to be sure
if self.fig.canvas.widgetlock.isowner(self):
self.fig.canvas.widgetlock.release(self)

def _cancel_action(self):
self._xypress = []
if self._id_drag:
self.fig.canvas.mpl_disconnect(self._id_drag)
self._id_drag = None
if self.fig.canvas.widgetlock.isowner(self):
self.fig.canvas.widgetlock.release(self)

def press(self, event):
if event.button != self.button:
self._cancel_action()
return
if not self.fig.canvas.widgetlock.available(self):
return

self.fig.canvas.widgetlock(self)

x, y = event.x, event.y

Expand Down
1 change: 0 additions & 1 deletion mpl_pan_zoom/_zoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,3 @@ def disconnect_zoom():

# return the disconnect function
return disconnect_zoom

45 changes: 20 additions & 25 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,72 +1,67 @@

[metadata]
name = mpl-pan-zoom
url = https://github.com/ianhi/mpl-pan-zoom
author = Ian Hunt-Isaak
author_email = ianhuntisaak@gmail.com


name = mpl_pan_zoom
description = Panning and zooming with the mouse for matplotlib
long_description = file: README.md
long_description_content_type = text/markdown
license = BSD license
url = https://github.com/ianhi/mpl-pan-zoom
author = Ian Hunt-Isaak
author_email = ianhuntisaak@gmail.com
license = BSD-3-Clause
license_file = LICENSE
classifiers =
Development Status :: 2 - Pre-Alpha
License :: OSI Approved :: BSD License
Natural Language :: English
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: Implementation :: CPython
project_urls =
Source Code =https://github.com/ianhi/mpl-pan-zoom

[options]
zip_safe = False
packages = find:
python_requires = >=3.7
install_requires =
numpy
matplotlib
numpy
python_requires = >=3.7
zip_safe = False

[options.extras_require]
testing =
tox
tox-conda
pytest
pytest-cov
nbval
dev =
ipython
jedi<0.18.0
black
flake8
flake8-docstrings
ipython
isort
jedi<0.18.0
mypy
pre-commit
pydocstyle
pytest
doc =
Sphinx>=1.5
jupyter-sphinx
myst-nb
numpydoc
Sphinx >= 1.5
sphinx-book-theme
sphinx-copybutton
sphinx-panels
sphinx-thebe
sphinx-togglebutton


testing =
nbval
pytest
pytest-cov
tox
tox-conda

[bdist_wheel]
universal = 1



[flake8]
exclude = docs, _version.py, .eggs, example
max-line-length = 88
docstring-convention = "numpy"
# ignore = D100, D213, D401, D413, D107, W503

0 comments on commit 018adf2

Please sign in to comment.