Helper class: Datatype to store Turtle attributes
| 2480 | |
| 2481 | |
| 2482 | class _TurtleImage(object): |
| 2483 | """Helper class: Datatype to store Turtle attributes |
| 2484 | """ |
| 2485 | |
| 2486 | def __init__(self, screen, shapeIndex): |
| 2487 | self.screen = screen |
| 2488 | self._type = None |
| 2489 | self._setshape(shapeIndex) |
| 2490 | |
| 2491 | def _setshape(self, shapeIndex): |
| 2492 | screen = self.screen |
| 2493 | self.shapeIndex = shapeIndex |
| 2494 | if self._type == "polygon" == screen._shapes[shapeIndex]._type: |
| 2495 | return |
| 2496 | if self._type == "image" == screen._shapes[shapeIndex]._type: |
| 2497 | return |
| 2498 | if self._type in ["image", "polygon"]: |
| 2499 | screen._delete(self._item) |
| 2500 | elif self._type == "compound": |
| 2501 | for item in self._item: |
| 2502 | screen._delete(item) |
| 2503 | self._type = screen._shapes[shapeIndex]._type |
| 2504 | if self._type == "polygon": |
| 2505 | self._item = screen._createpoly() |
| 2506 | elif self._type == "image": |
| 2507 | self._item = screen._createimage(screen._shapes["blank"]._data) |
| 2508 | elif self._type == "compound": |
| 2509 | self._item = [screen._createpoly() for item in |
| 2510 | screen._shapes[shapeIndex]._data] |
| 2511 | |
| 2512 | |
| 2513 | class RawTurtle(TPen, TNavigator): |