diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-06-22 05:18:54 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-06-22 05:18:54 (GMT) |
commit | f51531e2578452a47914108a44bc74c15431a5b0 (patch) | |
tree | 2934d7292ace5015502daec8f37c6fa80fe41e91 /Lib/turtledemo/clock.py | |
parent | fabefc3c5b9e174e4eef2cb351a6ed8c81d721b0 (diff) | |
download | cpython-f51531e2578452a47914108a44bc74c15431a5b0.zip cpython-f51531e2578452a47914108a44bc74c15431a5b0.tar.gz cpython-f51531e2578452a47914108a44bc74c15431a5b0.tar.bz2 |
Issue #21823: Catch turtle.Terminator exceptions in turtledemo.
Add note to demohelp.txt about doing so.
Diffstat (limited to 'Lib/turtledemo/clock.py')
-rwxr-xr-x | Lib/turtledemo/clock.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/Lib/turtledemo/clock.py b/Lib/turtledemo/clock.py index a0d157b..b7a2f36 100755 --- a/Lib/turtledemo/clock.py +++ b/Lib/turtledemo/clock.py @@ -11,6 +11,7 @@ and time ------------------------------------ """ from turtle import * +from turtle import Terminator # not in __all__ from datetime import datetime mode("logo") @@ -102,22 +103,25 @@ def tick(): sekunde = t.second + t.microsecond*0.000001 minute = t.minute + sekunde/60.0 stunde = t.hour + minute/60.0 - tracer(False) - writer.clear() - writer.home() - writer.forward(65) - writer.write(wochentag(t), - align="center", font=("Courier", 14, "bold")) - writer.back(150) - writer.write(datum(t), - align="center", font=("Courier", 14, "bold")) - writer.forward(85) - tracer(True) - second_hand.setheading(6*sekunde) - minute_hand.setheading(6*minute) - hour_hand.setheading(30*stunde) - tracer(True) - ontimer(tick, 100) + try: + tracer(False) # Terminator can occur here + writer.clear() + writer.home() + writer.forward(65) + writer.write(wochentag(t), + align="center", font=("Courier", 14, "bold")) + writer.back(150) + writer.write(datum(t), + align="center", font=("Courier", 14, "bold")) + writer.forward(85) + tracer(True) + second_hand.setheading(6*sekunde) # or here + minute_hand.setheading(6*minute) + hour_hand.setheading(30*stunde) + tracer(True) + ontimer(tick, 100) + except Terminator: + pass # turtledemo user pressed STOP def main(): tracer(False) |