[Tutor] serious problem with graphics module
Gregor Lingl
gregor.lingl at aon.at
Tue May 26 00:28:31 CEST 2009
roberto schrieb:
> hello everyone
>
Hello Roberto,
First question:
Do you use Python from the command line (terminal) or do you use IDLE?
I ask this, because these two show different behaviour.
> i have a problem with python 3.0 graphics module:
>
> no problem while importing the module
>
>>>> import turtle
>>>>
>
> but when i issue any command like:
>
>>>> t = turtle.pen()
>>>>
After performing this command you should be able to observe
a blank window with a tiny black arrow - it's the turtle
pen() is a function in the module turtle. It returns a dictionary
of the attributes of the turtle's pen. Have a look at it:
>>> print(t)
{'pensize': 1, 'resizemode': 'noresize', 'pendown': True, 'fillcolor':
'black',
'speed': 3, 'shown': True, 'outline': 1, 'tilt': 0.0, 'pencolor': 'black',
'stretchfactor': (1.0, 1.0), 'shearfactor': 0.0}
>>>
>>>> t = turtle.forward(60)
>>>>
>
> nothing appears on the screen, only a blank window, with nothing inside;
> may you give me some hint ?
>
Hmm, in my window the turtle goes 60 pixels to the right and draws a
black line.
The statement
>>> t = turtle.forward(60)
doesn't make much sense, though. It calls the forward() function of the
turtle module and names it's return value t. Alas:
>>> print(t)
None
>>>
Not really useful.
>>> turtle.forward(60)
is sufficient.
What happens if you do this?
>>> from turtle import *
>>> for i in range(4):
forward(100)
left(90)
Regards,
Gregor
>
> OS: win Xp
>
> thank you in advance !
>
>
More information about the Tutor
mailing list