海龟模块中没有 "setup" 函数来改变 window 大小

No "setup" function in the turtle module to change window size

我一直在尝试更改 运行 我的代码时打开的 window 的大小。

我查了一下,看到有人在用:

screen.setup (width=x_val, height=y_val, startx=start_x, starty=start_y)

当我尝试在自己的代码中使用它时,它甚至没有显示为选项:

它不起作用,因为您在 turtle 实例上调用屏幕方法 .setup()。试试这个方法:

from turtle import Turtle, Screen

screen = Screen()
screen.setup(300, 300)

tortoise = Turtle()

# ...

screen.exitonclick()