@@ -136,10 +136,16 @@ def __repr__(self):
136
136
class turtle (object ):
137
137
"""A Turtle that can be given commands to draw."""
138
138
139
- def __init__ (self , display = board .DISPLAY ):
139
+ def __init__ (self , display = None ):
140
+ if display :
141
+ self ._display = display
142
+ else :
143
+ try :
144
+ self ._display = board .DISPLAY
145
+ except AttributeError :
146
+ raise RuntimeError ("No display available. One must be provided." )
140
147
self ._logger = logging .getLogger ("Turtle" )
141
148
self ._logger .setLevel (logging .INFO )
142
- self ._display = display
143
149
self ._w = self ._display .width
144
150
self ._h = self ._display .height
145
151
self ._x = self ._w // 2
@@ -193,9 +199,7 @@ def __init__(self, display=board.DISPLAY):
193
199
self .pencolor (Color .WHITE )
194
200
195
201
self ._display .show (self ._splash )
196
- self ._display .refresh_soon ()
197
202
gc .collect ()
198
- self ._display .wait_for_frame ()
199
203
200
204
def _drawturtle (self ):
201
205
self ._turtle_sprite .x = int (self ._x - 4 )
@@ -298,7 +302,6 @@ def goto(self, x1, y1=None):
298
302
self ._x = y0
299
303
self ._y = x0
300
304
self ._drawturtle ()
301
- time .sleep (0.003 )
302
305
else :
303
306
try :
304
307
self ._plot (int (x0 ), int (y0 ), self ._pencolor )
@@ -307,7 +310,6 @@ def goto(self, x1, y1=None):
307
310
self ._x = x0
308
311
self ._y = y0
309
312
self ._drawturtle ()
310
- time .sleep (0.003 )
311
313
err -= dy
312
314
if err < 0 :
313
315
y0 += ystep
@@ -804,10 +806,8 @@ def clear(self):
804
806
self ._fg_bitmap [w , h ] = 0
805
807
for i , c in enumerate (Color .colors ):
806
808
self ._fg_palette [i + 1 ] = c ^ 0xFFFFFF
807
- self ._display .refresh_soon ()
808
809
for i , c in enumerate (Color .colors ):
809
810
self ._fg_palette [i + 1 ] = c
810
- self ._display .refresh_soon ()
811
811
time .sleep (0.1 )
812
812
813
813
def write (self , arg , move = False , align = "left" , font = ("Arial" , 8 , "normal" )):
0 commit comments