龟。在我的电脑上设置应用 window 位置

Turtle. Set the app window position on my computer

有没有办法在我的计算机上更改 turtle 脚本 运行 的默认起始位置 window?

您应该有一个以类似于 screen = Screen() 的方式定义的屏幕。如果这样做,应该很容易设置 window 的起始位置。使用screen.setup()方法如下:

screen.setup(startx=someNumHere, starty=someNumHere)

其中 startx 是距屏幕左边缘的起始位置(以像素为单位),starty 是距屏幕上边缘的起始位置(以像素为单位)。因此,例如,将此添加到您的脚本中:

screen.setup(startx=300, starty=300)

如果您希望 window 距屏幕左侧 300px,距屏幕顶部 300px。

如果您需要有关该主题的更多详细信息,请参阅

Is there a way to change the default position of starting window for turtle scripts running on my computer? ... I did not mean in the program. But someway to change the default of startx, so it opens the window with the new default unless changed in python script.

是的。您可以在 turtle.cfg 配置文件(在您的主目录中)中设置 leftrighttopbottom 属性。这些就像 startxstarty 参数到 setup(),但只要您在 turtle.cfg 文件中设置它们,它们就是默认值:

  • startx:如果为正数,从左边算起的起始位置(以像素为单位) 屏幕边缘,如果从右边缘开始为负 默认情况下,startx=None 是水平居中 window。

  • starty:如果为正,则从顶部开始的像素位置 屏幕边缘,如果从底部边缘开始为负 默认情况下,starty=None 是垂直居中 window。

相应的turtle.cfg文件将包含:

leftright = 100
topbottom = 100

使乌龟 window 始终打开屏幕左侧和顶部 100 像素,除非在脚本本身中另有设置。