Set or return backgroundcolor of the TurtleScreen. Four input formats are allowed: - bgcolor() Return the current background color as color specification string or as a tuple (see example). May be used as input to another color/pencolor/fillcol
(self, *args)
| 1212 | return self._turtles |
| 1213 | |
| 1214 | def bgcolor(self, *args): |
| 1215 | """Set or return backgroundcolor of the TurtleScreen. |
| 1216 | |
| 1217 | Four input formats are allowed: |
| 1218 | - bgcolor() |
| 1219 | Return the current background color as color specification |
| 1220 | string or as a tuple (see example). May be used as input |
| 1221 | to another color/pencolor/fillcolor/bgcolor call. |
| 1222 | - bgcolor(colorstring) |
| 1223 | Set the background color to colorstring, which is a Tk color |
| 1224 | specification string, such as "red", "yellow", or "#33cc8c". |
| 1225 | - bgcolor((r, g, b)) |
| 1226 | Set the background color to the RGB color represented by |
| 1227 | the tuple of r, g, and b. Each of r, g, and b must be in |
| 1228 | the range 0..colormode, where colormode is either 1.0 or 255 |
| 1229 | (see colormode()). |
| 1230 | - bgcolor(r, g, b) |
| 1231 | Set the background color to the RGB color represented by |
| 1232 | r, g, and b. Each of r, g, and b must be in the range |
| 1233 | 0..colormode. |
| 1234 | |
| 1235 | Example (for a TurtleScreen instance named screen): |
| 1236 | >>> screen.bgcolor("orange") |
| 1237 | >>> screen.bgcolor() |
| 1238 | 'orange' |
| 1239 | >>> colormode(255) |
| 1240 | >>> screen.bgcolor('#800080') |
| 1241 | >>> screen.bgcolor() |
| 1242 | (128.0, 0.0, 128.0) |
| 1243 | """ |
| 1244 | if args: |
| 1245 | color = self._colorstr(args) |
| 1246 | else: |
| 1247 | color = None |
| 1248 | color = self._bgcolor(color) |
| 1249 | if color is not None: |
| 1250 | color = self._color(color) |
| 1251 | return color |
| 1252 | |
| 1253 | def tracer(self, n=None, delay=None): |
| 1254 | """Turns turtle animation on/off and set delay for update drawings. |