Helper class: Datatype to store Turtle attributes
| 2378 | |
| 2379 | |
| 2380 | class _TurtleImage(object): |
| 2381 | """Helper class: Datatype to store Turtle attributes |
| 2382 | """ |
| 2383 | |
| 2384 | def __init__(self, screen, shapeIndex): |
| 2385 | self.screen = screen |
| 2386 | self._type = None |
| 2387 | self._setshape(shapeIndex) |
| 2388 | |
| 2389 | def _setshape(self, shapeIndex): |
| 2390 | screen = self.screen |
| 2391 | self.shapeIndex = shapeIndex |
| 2392 | if self._type == "polygon" == screen._shapes[shapeIndex]._type: |
| 2393 | return |
| 2394 | if self._type == "image" == screen._shapes[shapeIndex]._type: |
| 2395 | return |
| 2396 | if self._type in ["image", "polygon"]: |
| 2397 | screen._delete(self._item) |
| 2398 | elif self._type == "compound": |
| 2399 | for item in self._item: |
| 2400 | screen._delete(item) |
| 2401 | self._type = screen._shapes[shapeIndex]._type |
| 2402 | if self._type == "polygon": |
| 2403 | self._item = screen._createpoly() |
| 2404 | elif self._type == "image": |
| 2405 | self._item = screen._createimage(screen._shapes["blank"]._data) |
| 2406 | elif self._type == "compound": |
| 2407 | self._item = [screen._createpoly() for item in |
| 2408 | screen._shapes[shapeIndex]._data] |
| 2409 | |
| 2410 | |
| 2411 | class RawTurtle(TPen, TNavigator): |