I am making an analog clock with python, using turtle module.
I could configue a window size and a circle, But i can't finish outliner of a circle.
I didn't give any integer to get the complete ouliner. But it doesn't surround a circle entire.
Please, tell me if there is a something missing.
window = turtle.Screen()
window.setup(1000, 800)
window.bgcolor("black")
window.title("Analog Clock")
window.tracer(0)
t = turtle.Turtle()
t.color("#FFD700")
t.penup()
t.speed(0)
t.pensize(25)
t.hideturtle()
t.goto(0, -290)
t.pendown()
t.fillcolor("white")
t.begin_fill()
t.circle(300, 360)
t.end_fill()
thank you
CodePudding user response:
The problem is your use of tracer()
without any call to update()
. You can either remove the window.tracer(0)
line, or add a window.update()
line after your t.end_fill()
line.
I usually recommend avoiding tracer()
and update()
until you have your code basically working, just to avoid bugs like this.
from turtle import Screen, Turtle
screen = Screen()
screen.setup(1000, 800)
screen.bgcolor('black')
screen.title("Analog Clock")
screen.tracer(0)
turtle = Turtle()
turtle.hideturtle()
turtle.speed('fastest') # no-op if `tracer(0)`
turtle.color('#FFD700')
turtle.pensize(25)
turtle.penup()
turtle.sety(-290)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(300)
turtle.end_fill()
screen.update()
screen.mainloop()
CodePudding user response:
Here is the solution to your problem with your posted code working properly :)
window = turtle.Screen()
window.setup(1000, 800)
window.bgcolor("black")
window.title("Analog Clock")
t = turtle.Turtle()
t.color("#FFD700")
t.penup()
t.speed(0)
t.pensize(25)
t.hideturtle()
t.goto(0, -290)
t.pendown()
t.fillcolor("white")
t.begin_fill()
t.circle(300, 360)
t.end_fill()
window.update()