MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / _undo

Method _undo

Python/Turtle.py:3489–3519  ·  view source on GitHub ↗

Does the main part of the work for undo()

(self, action, data)

Source from the content-addressed store, hash-verified

3487
3488
3489 def _undo(self, action, data):
3490 """Does the main part of the work for undo()
3491 """
3492 if self.undobuffer is None:
3493 return
3494 if action == "rot":
3495 angle, degPAU = data
3496 self._rotate(-angle*degPAU/self._degreesPerAU)
3497 dummy = self.undobuffer.pop()
3498 elif action == "stamp":
3499 stitem = data[0]
3500 self.clearstamp(stitem)
3501 elif action == "go":
3502 self._undogoto(data)
3503 elif action in ["wri", "dot"]:
3504 item = data[0]
3505 self.screen._delete(item)
3506 self.items.remove(item)
3507 elif action == "dofill":
3508 item = data[0]
3509 self.screen._drawpoly(item, ((0, 0),(0, 0),(0, 0)),
3510 fill="", outline="")
3511 elif action == "beginfill":
3512 item = data[0]
3513 self._fillitem = self._fillpath = None
3514 if item in self.items:
3515 self.screen._delete(item)
3516 self.items.remove(item)
3517 elif action == "pen":
3518 TPen.pen(self, data[0])
3519 self.undobuffer.pop()
3520
3521 def undo(self):
3522 """undo (repeatedly) the last turtle action.

Callers 1

undoMethod · 0.95

Calls 8

_rotateMethod · 0.95
clearstampMethod · 0.95
_undogotoMethod · 0.95
_deleteMethod · 0.80
_drawpolyMethod · 0.80
penMethod · 0.80
popMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected