|
23 | 23 | class LockDraw(object): |
24 | 24 | """ |
25 | 25 | 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). |
31 | 31 | """ |
32 | 32 |
|
33 | 33 | def __init__(self): |
34 | 34 | self._owner = None |
35 | 35 |
|
36 | 36 | def __call__(self, o): |
37 | | - """reserve the lock for *o*""" |
| 37 | + """Reserve the lock for *o*.""" |
38 | 38 | if not self.available(o): |
39 | 39 | raise ValueError('already locked') |
40 | 40 | self._owner = o |
41 | 41 |
|
42 | 42 | def release(self, o): |
43 | | - """release the lock""" |
| 43 | + """Release the lock from *o*.""" |
44 | 44 | if not self.available(o): |
45 | 45 | raise ValueError('you do not own this lock') |
46 | 46 | self._owner = None |
47 | 47 |
|
48 | 48 | def available(self, o): |
49 | | - """drawing is available to *o*""" |
| 49 | + """Return whether drawing is available to *o*.""" |
50 | 50 | return not self.locked() or self.isowner(o) |
51 | 51 |
|
52 | 52 | def isowner(self, o): |
53 | | - """Return True if *o* owns this lock""" |
| 53 | + """Return whether *o* owns this lock.""" |
54 | 54 | return self._owner is o |
55 | 55 |
|
56 | 56 | 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.""" |
58 | 58 | return self._owner is not None |
59 | 59 |
|
60 | 60 |
|
|
0 commit comments