Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Allow Selectors to be dragged from anywhere within their patch#19657
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Dragging selectors | ||
------------------ | ||
The `~matplotlib.widgets.RectangleSelector` and | ||
`~matplotlib.widgets.EllipseSelector` have a new keyword argument, | ||
*drag_from_anywhere*, which when set to `True` allows you to click and drag | ||
from anywhere inside the selector to move it. Previously it was only possible | ||
to move it by either activating the move modifier button, or clicking on the | ||
central handle. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -44,6 +44,41 @@ def test_rectangle_selector(): | ||
check_rectangle(rectprops=dict(fill=True)) | ||
@pytest.mark.parametrize('drag_from_anywhere, new_center', | ||
[[True, (60, 75)], | ||
[False, (30, 20)]]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. If you're not dragging from the center, and you didn't enable the new option, why is the center now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is because dragging with | ||
def test_rectangle_drag(drag_from_anywhere, new_center): | ||
ax = get_ax() | ||
def onselect(epress, erelease): | ||
pass | ||
tool = widgets.RectangleSelector(ax, onselect, interactive=True, | ||
drag_from_anywhere=drag_from_anywhere) | ||
# Create rectangle | ||
do_event(tool, 'press', xdata=0, ydata=10, button=1) | ||
do_event(tool, 'onmove', xdata=100, ydata=120, button=1) | ||
do_event(tool, 'release', xdata=100, ydata=120, button=1) | ||
assert tool.center == (50, 65) | ||
# Drag inside rectangle, but away from centre handle | ||
# | ||
# If drag_from_anywhere == True, this will move the rectangle by (10, 10), | ||
# giving it a new center of (60, 75) | ||
# | ||
# If drag_from_anywhere == False, this will create a new rectangle with | ||
# center (30, 20) | ||
do_event(tool, 'press', xdata=25, ydata=15, button=1) | ||
do_event(tool, 'onmove', xdata=35, ydata=25, button=1) | ||
do_event(tool, 'release', xdata=35, ydata=25, button=1) | ||
assert tool.center == new_center | ||
# Check that in both cases, dragging outside the rectangle draws a new | ||
# rectangle | ||
do_event(tool, 'press', xdata=175, ydata=185, button=1) | ||
do_event(tool, 'onmove', xdata=185, ydata=195, button=1) | ||
do_event(tool, 'release', xdata=185, ydata=195, button=1) | ||
assert tool.center == (180, 190) | ||
def test_ellipse(): | ||
"""For ellipse, test out the key modifiers""" | ||
ax = get_ax() | ||