|
11 | 11 | ------------------------------------ |
12 | 12 | """ |
13 | 13 | from turtle import * |
| 14 | +from turtle import Terminator # not in __all__ |
14 | 15 | from datetime import datetime |
15 | 16 |
|
16 | 17 | mode("logo") |
@@ -102,22 +103,25 @@ def tick(): |
102 | 103 | sekunde = t.second + t.microsecond*0.000001 |
103 | 104 | minute = t.minute + sekunde/60.0 |
104 | 105 | stunde = t.hour + minute/60.0 |
105 | | - tracer(False) |
106 | | - writer.clear() |
107 | | - writer.home() |
108 | | - writer.forward(65) |
109 | | - writer.write(wochentag(t), |
110 | | - align="center", font=("Courier", 14, "bold")) |
111 | | - writer.back(150) |
112 | | - writer.write(datum(t), |
113 | | - align="center", font=("Courier", 14, "bold")) |
114 | | - writer.forward(85) |
115 | | - tracer(True) |
116 | | - second_hand.setheading(6*sekunde) |
117 | | - minute_hand.setheading(6*minute) |
118 | | - hour_hand.setheading(30*stunde) |
119 | | - tracer(True) |
120 | | - ontimer(tick, 100) |
| 106 | + try: |
| 107 | + tracer(False) # Terminator can occur here |
| 108 | + writer.clear() |
| 109 | + writer.home() |
| 110 | + writer.forward(65) |
| 111 | + writer.write(wochentag(t), |
| 112 | + align="center", font=("Courier", 14, "bold")) |
| 113 | + writer.back(150) |
| 114 | + writer.write(datum(t), |
| 115 | + align="center", font=("Courier", 14, "bold")) |
| 116 | + writer.forward(85) |
| 117 | + tracer(True) |
| 118 | + second_hand.setheading(6*sekunde) # or here |
| 119 | + minute_hand.setheading(6*minute) |
| 120 | + hour_hand.setheading(30*stunde) |
| 121 | + tracer(True) |
| 122 | + ontimer(tick, 100) |
| 123 | + except Terminator: |
| 124 | + pass # turtledemo user pressed STOP |
121 | 125 |
|
122 | 126 | def main(): |
123 | 127 | tracer(False) |
|
0 commit comments