Python turtle.pensize() not changing the size of the pen
I am trying to change the the pen size in Python 2.7. I know the pensize() command can be interchanged with width() (neither work), however the size of the pen stays the same no matter what value I enter. We use WingIDE to program in Python, though using the Python IDE doesn't fix the issue.
I have tested this on 3 machines, same issue. I have played with the positioning of the turtle.pensize(), size remains the same. The code below will draw the letter "I" and begin on a second letter:
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
t.reset()
t.color("green");
t.pu();
t.setx(-450);
t.pd();
t.left(90);
t.forward(120);
t.pu();
t.right(90);
t.forward(90);
t.right(90);
t.pd();
#I
t.forward(120);
t.left(90);
t.forward(20);
reset()
I don't really receive an error, but I will post what the WingIDE debugger displays:
> 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
Python Type "help", "copyright", "credits" or "license" for more information.
[evaluate JAMES ILLUMINATI TURTLE FINISHED p1.py]
Traceback (most recent call last):
File "C:/Users/Com Lab 16/Dropbox/Student's Curriculum Folder/0. Student Files/James Dundon/JAMES ILLUMINATI TURTLE FINISHED p1.py", line 50, in <module>
t.right(90);
File "c:Python27Liblib-tkturtle.py", line 1594, in right
self._rotate(-angle)
File "c:Python27Liblib-tkturtle.py", line 3109, in _rotate
self._update()
File "c:Python27Liblib-tkturtle.py", line 2565, in _update
self._update_data()
File "c:Python27Liblib-tkturtle.py", line 2551, in _update_data
self.screen._incrementudc()
File "c:Python27Liblib-tkturtle.py", line 1240, in _incrementudc
raise Terminator
turtle.Terminator:
First time posting here, please let me know if I can be more specific or add additional information.
python python-2.x turtle-graphics
add a comment |
I am trying to change the the pen size in Python 2.7. I know the pensize() command can be interchanged with width() (neither work), however the size of the pen stays the same no matter what value I enter. We use WingIDE to program in Python, though using the Python IDE doesn't fix the issue.
I have tested this on 3 machines, same issue. I have played with the positioning of the turtle.pensize(), size remains the same. The code below will draw the letter "I" and begin on a second letter:
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
t.reset()
t.color("green");
t.pu();
t.setx(-450);
t.pd();
t.left(90);
t.forward(120);
t.pu();
t.right(90);
t.forward(90);
t.right(90);
t.pd();
#I
t.forward(120);
t.left(90);
t.forward(20);
reset()
I don't really receive an error, but I will post what the WingIDE debugger displays:
> 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
Python Type "help", "copyright", "credits" or "license" for more information.
[evaluate JAMES ILLUMINATI TURTLE FINISHED p1.py]
Traceback (most recent call last):
File "C:/Users/Com Lab 16/Dropbox/Student's Curriculum Folder/0. Student Files/James Dundon/JAMES ILLUMINATI TURTLE FINISHED p1.py", line 50, in <module>
t.right(90);
File "c:Python27Liblib-tkturtle.py", line 1594, in right
self._rotate(-angle)
File "c:Python27Liblib-tkturtle.py", line 3109, in _rotate
self._update()
File "c:Python27Liblib-tkturtle.py", line 2565, in _update
self._update_data()
File "c:Python27Liblib-tkturtle.py", line 2551, in _update_data
self.screen._incrementudc()
File "c:Python27Liblib-tkturtle.py", line 1240, in _incrementudc
raise Terminator
turtle.Terminator:
First time posting here, please let me know if I can be more specific or add additional information.
python python-2.x turtle-graphics
1
Please consider adding a code sample, or revising the one you posted in this question. As it currently stands, its formatting and scope make it hard for us to help you; here is a great resource to get you started on that. Good luck with your code!
– Reblochon Masque
Dec 5 '17 at 4:37
1
Hi there, thanks for the advice. I have deleted most of the code and now it only draws 1 letter (probably could have saved me the explanation about the student's word choice so i've taken that out too!)
– njbeep
Dec 5 '17 at 4:52
1
Your call tot.reset()is discarding the turtle options you set on the previous two lines.
– jasonharper
Dec 5 '17 at 6:14
Thank you! Of course, such a simple oversight.
– njbeep
Dec 5 '17 at 7:02
add a comment |
I am trying to change the the pen size in Python 2.7. I know the pensize() command can be interchanged with width() (neither work), however the size of the pen stays the same no matter what value I enter. We use WingIDE to program in Python, though using the Python IDE doesn't fix the issue.
I have tested this on 3 machines, same issue. I have played with the positioning of the turtle.pensize(), size remains the same. The code below will draw the letter "I" and begin on a second letter:
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
t.reset()
t.color("green");
t.pu();
t.setx(-450);
t.pd();
t.left(90);
t.forward(120);
t.pu();
t.right(90);
t.forward(90);
t.right(90);
t.pd();
#I
t.forward(120);
t.left(90);
t.forward(20);
reset()
I don't really receive an error, but I will post what the WingIDE debugger displays:
> 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
Python Type "help", "copyright", "credits" or "license" for more information.
[evaluate JAMES ILLUMINATI TURTLE FINISHED p1.py]
Traceback (most recent call last):
File "C:/Users/Com Lab 16/Dropbox/Student's Curriculum Folder/0. Student Files/James Dundon/JAMES ILLUMINATI TURTLE FINISHED p1.py", line 50, in <module>
t.right(90);
File "c:Python27Liblib-tkturtle.py", line 1594, in right
self._rotate(-angle)
File "c:Python27Liblib-tkturtle.py", line 3109, in _rotate
self._update()
File "c:Python27Liblib-tkturtle.py", line 2565, in _update
self._update_data()
File "c:Python27Liblib-tkturtle.py", line 2551, in _update_data
self.screen._incrementudc()
File "c:Python27Liblib-tkturtle.py", line 1240, in _incrementudc
raise Terminator
turtle.Terminator:
First time posting here, please let me know if I can be more specific or add additional information.
python python-2.x turtle-graphics
I am trying to change the the pen size in Python 2.7. I know the pensize() command can be interchanged with width() (neither work), however the size of the pen stays the same no matter what value I enter. We use WingIDE to program in Python, though using the Python IDE doesn't fix the issue.
I have tested this on 3 machines, same issue. I have played with the positioning of the turtle.pensize(), size remains the same. The code below will draw the letter "I" and begin on a second letter:
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
t.reset()
t.color("green");
t.pu();
t.setx(-450);
t.pd();
t.left(90);
t.forward(120);
t.pu();
t.right(90);
t.forward(90);
t.right(90);
t.pd();
#I
t.forward(120);
t.left(90);
t.forward(20);
reset()
I don't really receive an error, but I will post what the WingIDE debugger displays:
> 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
Python Type "help", "copyright", "credits" or "license" for more information.
[evaluate JAMES ILLUMINATI TURTLE FINISHED p1.py]
Traceback (most recent call last):
File "C:/Users/Com Lab 16/Dropbox/Student's Curriculum Folder/0. Student Files/James Dundon/JAMES ILLUMINATI TURTLE FINISHED p1.py", line 50, in <module>
t.right(90);
File "c:Python27Liblib-tkturtle.py", line 1594, in right
self._rotate(-angle)
File "c:Python27Liblib-tkturtle.py", line 3109, in _rotate
self._update()
File "c:Python27Liblib-tkturtle.py", line 2565, in _update
self._update_data()
File "c:Python27Liblib-tkturtle.py", line 2551, in _update_data
self.screen._incrementudc()
File "c:Python27Liblib-tkturtle.py", line 1240, in _incrementudc
raise Terminator
turtle.Terminator:
First time posting here, please let me know if I can be more specific or add additional information.
python python-2.x turtle-graphics
python python-2.x turtle-graphics
edited Nov 22 '18 at 22:04
cdlane
17.9k21144
17.9k21144
asked Dec 5 '17 at 4:34
njbeepnjbeep
112
112
1
Please consider adding a code sample, or revising the one you posted in this question. As it currently stands, its formatting and scope make it hard for us to help you; here is a great resource to get you started on that. Good luck with your code!
– Reblochon Masque
Dec 5 '17 at 4:37
1
Hi there, thanks for the advice. I have deleted most of the code and now it only draws 1 letter (probably could have saved me the explanation about the student's word choice so i've taken that out too!)
– njbeep
Dec 5 '17 at 4:52
1
Your call tot.reset()is discarding the turtle options you set on the previous two lines.
– jasonharper
Dec 5 '17 at 6:14
Thank you! Of course, such a simple oversight.
– njbeep
Dec 5 '17 at 7:02
add a comment |
1
Please consider adding a code sample, or revising the one you posted in this question. As it currently stands, its formatting and scope make it hard for us to help you; here is a great resource to get you started on that. Good luck with your code!
– Reblochon Masque
Dec 5 '17 at 4:37
1
Hi there, thanks for the advice. I have deleted most of the code and now it only draws 1 letter (probably could have saved me the explanation about the student's word choice so i've taken that out too!)
– njbeep
Dec 5 '17 at 4:52
1
Your call tot.reset()is discarding the turtle options you set on the previous two lines.
– jasonharper
Dec 5 '17 at 6:14
Thank you! Of course, such a simple oversight.
– njbeep
Dec 5 '17 at 7:02
1
1
Please consider adding a code sample, or revising the one you posted in this question. As it currently stands, its formatting and scope make it hard for us to help you; here is a great resource to get you started on that. Good luck with your code!
– Reblochon Masque
Dec 5 '17 at 4:37
Please consider adding a code sample, or revising the one you posted in this question. As it currently stands, its formatting and scope make it hard for us to help you; here is a great resource to get you started on that. Good luck with your code!
– Reblochon Masque
Dec 5 '17 at 4:37
1
1
Hi there, thanks for the advice. I have deleted most of the code and now it only draws 1 letter (probably could have saved me the explanation about the student's word choice so i've taken that out too!)
– njbeep
Dec 5 '17 at 4:52
Hi there, thanks for the advice. I have deleted most of the code and now it only draws 1 letter (probably could have saved me the explanation about the student's word choice so i've taken that out too!)
– njbeep
Dec 5 '17 at 4:52
1
1
Your call to
t.reset() is discarding the turtle options you set on the previous two lines.– jasonharper
Dec 5 '17 at 6:14
Your call to
t.reset() is discarding the turtle options you set on the previous two lines.– jasonharper
Dec 5 '17 at 6:14
Thank you! Of course, such a simple oversight.
– njbeep
Dec 5 '17 at 7:02
Thank you! Of course, such a simple oversight.
– njbeep
Dec 5 '17 at 7:02
add a comment |
1 Answer
1
active
oldest
votes
however the size of the pen stays the same no matter what value i
enter
And well it should as you are in fact working with two different turtles:
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
...
t.forward(120)
You are making the mistake of mixing the functional interface to turtle with the object-oriented interface to turtle. You created your own turtle t, but you changed the pen size of the default turtle. If you want to change your turtle's pen size, you do:
t.pensize(800)
This is a common error so I recommend that Python turtle programmers use this import:
from turtle import Screen, Turtle
It loads the object-oriented code but blocks out the functional interface. Once that's fixed, then you need to address the issue raised by @jasonharper in the comments that calling reset() undoes pensize() and really isn't needed at this point in the program. Your code rewritten accordingly:
from turtle import Screen, Turtle, mainloop
screen = Screen()
screen.bgcolor('black')
t = Turtle()
t.pensize(8)
t.color("green")
t.penup()
t.setx(-450)
t.pendown()
t.left(90)
t.forward(120)
t.penup()
t.right(90)
t.forward(90)
t.right(90)
t.pendown()
t.forward(120)
t.left(90)
t.forward(20)
mainloop() # screen.mainloop() for Python 3
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47646154%2fpython-turtle-pensize-not-changing-the-size-of-the-pen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
however the size of the pen stays the same no matter what value i
enter
And well it should as you are in fact working with two different turtles:
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
...
t.forward(120)
You are making the mistake of mixing the functional interface to turtle with the object-oriented interface to turtle. You created your own turtle t, but you changed the pen size of the default turtle. If you want to change your turtle's pen size, you do:
t.pensize(800)
This is a common error so I recommend that Python turtle programmers use this import:
from turtle import Screen, Turtle
It loads the object-oriented code but blocks out the functional interface. Once that's fixed, then you need to address the issue raised by @jasonharper in the comments that calling reset() undoes pensize() and really isn't needed at this point in the program. Your code rewritten accordingly:
from turtle import Screen, Turtle, mainloop
screen = Screen()
screen.bgcolor('black')
t = Turtle()
t.pensize(8)
t.color("green")
t.penup()
t.setx(-450)
t.pendown()
t.left(90)
t.forward(120)
t.penup()
t.right(90)
t.forward(90)
t.right(90)
t.pendown()
t.forward(120)
t.left(90)
t.forward(20)
mainloop() # screen.mainloop() for Python 3
add a comment |
however the size of the pen stays the same no matter what value i
enter
And well it should as you are in fact working with two different turtles:
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
...
t.forward(120)
You are making the mistake of mixing the functional interface to turtle with the object-oriented interface to turtle. You created your own turtle t, but you changed the pen size of the default turtle. If you want to change your turtle's pen size, you do:
t.pensize(800)
This is a common error so I recommend that Python turtle programmers use this import:
from turtle import Screen, Turtle
It loads the object-oriented code but blocks out the functional interface. Once that's fixed, then you need to address the issue raised by @jasonharper in the comments that calling reset() undoes pensize() and really isn't needed at this point in the program. Your code rewritten accordingly:
from turtle import Screen, Turtle, mainloop
screen = Screen()
screen.bgcolor('black')
t = Turtle()
t.pensize(8)
t.color("green")
t.penup()
t.setx(-450)
t.pendown()
t.left(90)
t.forward(120)
t.penup()
t.right(90)
t.forward(90)
t.right(90)
t.pendown()
t.forward(120)
t.left(90)
t.forward(20)
mainloop() # screen.mainloop() for Python 3
add a comment |
however the size of the pen stays the same no matter what value i
enter
And well it should as you are in fact working with two different turtles:
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
...
t.forward(120)
You are making the mistake of mixing the functional interface to turtle with the object-oriented interface to turtle. You created your own turtle t, but you changed the pen size of the default turtle. If you want to change your turtle's pen size, you do:
t.pensize(800)
This is a common error so I recommend that Python turtle programmers use this import:
from turtle import Screen, Turtle
It loads the object-oriented code but blocks out the functional interface. Once that's fixed, then you need to address the issue raised by @jasonharper in the comments that calling reset() undoes pensize() and really isn't needed at this point in the program. Your code rewritten accordingly:
from turtle import Screen, Turtle, mainloop
screen = Screen()
screen.bgcolor('black')
t = Turtle()
t.pensize(8)
t.color("green")
t.penup()
t.setx(-450)
t.pendown()
t.left(90)
t.forward(120)
t.penup()
t.right(90)
t.forward(90)
t.right(90)
t.pendown()
t.forward(120)
t.left(90)
t.forward(20)
mainloop() # screen.mainloop() for Python 3
however the size of the pen stays the same no matter what value i
enter
And well it should as you are in fact working with two different turtles:
t = turtle.Pen()
turtle.bgcolor("black")
turtle.pensize(800)
...
t.forward(120)
You are making the mistake of mixing the functional interface to turtle with the object-oriented interface to turtle. You created your own turtle t, but you changed the pen size of the default turtle. If you want to change your turtle's pen size, you do:
t.pensize(800)
This is a common error so I recommend that Python turtle programmers use this import:
from turtle import Screen, Turtle
It loads the object-oriented code but blocks out the functional interface. Once that's fixed, then you need to address the issue raised by @jasonharper in the comments that calling reset() undoes pensize() and really isn't needed at this point in the program. Your code rewritten accordingly:
from turtle import Screen, Turtle, mainloop
screen = Screen()
screen.bgcolor('black')
t = Turtle()
t.pensize(8)
t.color("green")
t.penup()
t.setx(-450)
t.pendown()
t.left(90)
t.forward(120)
t.penup()
t.right(90)
t.forward(90)
t.right(90)
t.pendown()
t.forward(120)
t.left(90)
t.forward(20)
mainloop() # screen.mainloop() for Python 3
edited Nov 22 '18 at 22:05
answered Nov 22 '18 at 22:00
cdlanecdlane
17.9k21144
17.9k21144
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47646154%2fpython-turtle-pensize-not-changing-the-size-of-the-pen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Please consider adding a code sample, or revising the one you posted in this question. As it currently stands, its formatting and scope make it hard for us to help you; here is a great resource to get you started on that. Good luck with your code!
– Reblochon Masque
Dec 5 '17 at 4:37
1
Hi there, thanks for the advice. I have deleted most of the code and now it only draws 1 letter (probably could have saved me the explanation about the student's word choice so i've taken that out too!)
– njbeep
Dec 5 '17 at 4:52
1
Your call to
t.reset()is discarding the turtle options you set on the previous two lines.– jasonharper
Dec 5 '17 at 6:14
Thank you! Of course, such a simple oversight.
– njbeep
Dec 5 '17 at 7:02