简体   繁体   中英

Defaults of the turtle in Python turtle module

For teaching purposes I need a list of the graphics defaults. Here's what I have by now:

background  white
canvas      950W by 800H
dot         5 (pixels)
fill color  black
heading     0 (East)
home        (0,0) (screen center)
pen color   black
shape       classic (arrow)
speed       3 (of turtle)
width       1 (of line)

Are there any more defaults? Thank you

The turtle.pen() method (often confused with the turtle.Pen() method) allows you to query and set a number of attributes, initially showing their defaults:

>>> turtle.pen()
{'shown': True, 'pendown': True, 'pencolor': 'black', 'fillcolor': 'black', 'pensize': 1, 
'speed': 3, 'resizemode': 'noresize', 'stretchfactor': (1.0, 1.0),
'shearfactor': 0.0, 'outline': 1, 'tilt': 0.0}
>>> 

Where ' shown ' is an alternate term for ' visible '. Other defaults:

mode: 'standard'  # default for turtle.mode()
colormode: 1.0  # default for turtle.colormode()
angle units: degrees  # change with turtle.radians()

The first two are likely screen defaults but the last is set on a per turtle basis. I believe that this is incorrect:

canvas      950W by 800H

The default turtle screen size is 50% of your screen width and 75% of your screen height. The screen setup routine will accept fractions as well as pixels:

turtle.Screen().setup(0.25, 0.25)

Canvas is the only default that is not correct. I believe that 'default' will depend on the environment you are using. For example, in trinket, the default is -200 to +200 in both the x and the y directions.

The student's I teach are complete beginners and I just stick to the ones you listed I find for most of the students that is enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM