turtle-graphics

Drawing with turtle(python) using PyCharm

佐手、 提交于 2020-08-22 06:12:42
问题 I'm running the latest PyCharm Pro version and trying to run the below code from a scratch file but it doesn't seem to work import turtle wn = turtle.Screen() alex = turtle.Turtle() alex.forward(150) alex.left(90) alex.forward(75) By not working I mean, no window is popping out however I do see in the output saying Process finished with exit code 0 Any idea If it can be done via PyCharm What am I missing in terms of configuration Cheers 回答1: I ran into the same problem. Turns out the solution

Is setting `turtle.speed(0)` necessary when we have turtle.tracer(0)

若如初见. 提交于 2020-07-22 05:59:39
问题 Is there a difference between: import turtle turtle.tracer(0) turtle.speed(0) while True: turtle.goto(turtle.xcor()+1) turtle.update() And: import turtle turtle.tracer(0) while True: turtle.goto(turtle.xcor()+1) turtle.update() I've heard that setting turtle.speed(0) make things faster, but if so, I don't see any difference. 回答1: According to: https://www.eg.bucknell.edu/~hyde/Python3/TurtleDirections.html The tracer() method: Can be used to accelerate the drawing of complex graphics. Turning

E1101:Module 'turtle' has no 'forward' member

最后都变了- 提交于 2020-07-19 01:58:27
问题 I'm new to programming and I downloaded Python and got it running in Visual Studio Code. I was messing around with the turtle module and its functions. The functions themselves work but pylint marks it as an error and says that there isn't a "member" like what I coded. How would I go about fixing this error? (I don't want to set it to "ignore" the issue but rather recognize that the code I'm typing in is valid and comes from the turtle module) 回答1: The turtle module exposes two interfaces, a

Why does turtle open an even smaller screen when the canvas is small?

天涯浪子 提交于 2020-06-27 14:52:10
问题 I'm trying to draw on a small 200x200 screen using turtle, however the drawing doesn't pop up as full size, it opens a smaller window and I have to scroll up/down, left/right (just a bit) to see the whole drawing. I don't have this problem with larger windows. How do I prevent this? import turtle import random height, width = 200, 200 screen = turtle.Screen() screen.setup(width, height) screen.setworldcoordinates(0, 0, width, height) t = turtle.Turtle() t.speed(1) for _ in range(5): t.penup()

Python Turtle pen colour

冷暖自知 提交于 2020-06-27 13:56:43
问题 When I call t.pencolor('83, 58, 27') (turtle is imported as t) I get the TurtleGraphicsError: bad color string: 83, 58, 27 even though I have (I think) changed my colour mode. t.colormode(255) t.pencolor('83, 58, 27') I run python 2.7 on OS 10.9 回答1: You are passing in a string with three colors, where you need to pass the three colors as three separate integer arguments, like this: t.pencolor(83, 58, 27) There are multiple ways to use pencolor , from the documentation: Four input formats are