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

Skip to content

Commit ab6f6f9

Browse files
anntzertimhoffm
authored andcommitted
Reword the LockDraw docstring. (#12112)
Mostly remove the reference to the module-level global `lock`, which has been replaced by a canvas-level lock since ecb9888 (2006...).
1 parent 6ff5287 commit ab6f6f9

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

lib/matplotlib/widgets.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,38 @@
2323
class LockDraw(object):
2424
"""
2525
Some widgets, like the cursor, draw onto the canvas, and this is not
26-
desirable under all circumstances, like when the toolbar is in
27-
zoom-to-rect mode and drawing a rectangle. The module level "lock"
28-
allows someone to grab the lock and prevent other widgets from
29-
drawing. Use ``matplotlib.widgets.lock(someobj)`` to prevent
30-
other widgets from drawing while you're interacting with the canvas.
26+
desirable under all circumstances, like when the toolbar is in zoom-to-rect
27+
mode and drawing a rectangle. To avoid this, a widget can acquire a
28+
canvas' lock with ``canvas.widgetlock(widget)`` before drawing on the
29+
canvas; this will prevent other widgets from doing so at the same time (if
30+
they also try to acquire the lock first).
3131
"""
3232

3333
def __init__(self):
3434
self._owner = None
3535

3636
def __call__(self, o):
37-
"""reserve the lock for *o*"""
37+
"""Reserve the lock for *o*."""
3838
if not self.available(o):
3939
raise ValueError('already locked')
4040
self._owner = o
4141

4242
def release(self, o):
43-
"""release the lock"""
43+
"""Release the lock from *o*."""
4444
if not self.available(o):
4545
raise ValueError('you do not own this lock')
4646
self._owner = None
4747

4848
def available(self, o):
49-
"""drawing is available to *o*"""
49+
"""Return whether drawing is available to *o*."""
5050
return not self.locked() or self.isowner(o)
5151

5252
def isowner(self, o):
53-
"""Return True if *o* owns this lock"""
53+
"""Return whether *o* owns this lock."""
5454
return self._owner is o
5555

5656
def locked(self):
57-
"""Return True if the lock is currently held by an owner"""
57+
"""Return whether the lock is currently held by an owner."""
5858
return self._owner is not None
5959

6060

0 commit comments

Comments
 (0)