更改海龟图形窗口的屏幕位置? [英] Change the on-screen position of the Turtle Graphics window?

查看:27
本文介绍了更改海龟图形窗口的屏幕位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以改变海龟控制台在屏幕上的位置?

Is it possible to change the position of the turtle console on screen?

我的主要目标是编写可以移动窗口的代码,仅此而已.

My main objective is to write code that can move the window, that's all.

我在 Windows 10 下使用 Python 3.4.0.

I'm using Python 3.4.0 under Windows 10.

如果需要任何额外信息,请询问.

If any extra information is needed please ask.

推荐答案

为什么人们在阅读海龟文档之前总是跳入tkinter?

Why do folks always jump into tkinter before reading the turtle documentation?

是的,您可以使用与设置其大小相同的 setup() 方法来设置海龟图形窗口的屏幕位置:

Yes, you can set the screen position of the turtle graphics window using the same setup() method you use to size it:

from turtle import Turtle, Screen

def animate():
    global offset

    screen.setup(width=0.333, height=0.333, startx=offset, starty=offset)

    turtle.dot(offset)

    offset += 10

    if offset < 300:
        screen.ontimer(animate, 100)

screen = Screen()

turtle = Turtle()

offset = 30

animate()

screen.exitonclick()

startx,如果是正数,则是距屏幕左边缘的起始位置(以像素为单位),如果是负数,则是从右边缘开始的位置.类似地,starty,如果是正数,则是从屏幕上边缘开始的位置,如果是负数,则是从下边缘开始的位置.默认情况下,窗口位于屏幕中央.

startx, if positive, is the starting position in pixels from the left edge of the screen, or from the right edge if negative. Similarly, starty, if positive, is the starting position from the top edge of the screen, or from the bottom edge if negative. By default, the window is centered on the screen.

您的标题询问了 Turtle Graphics 窗口在屏幕上的位置,但您的问题的正文询问了 Turtle Consoleem>.这可能被认为是两个不同的窗口.

Your title asks about the position of the Turtle Graphics window on the screen but the body of your question asks about the Turtle Console. These might be considered two different windows.

我的主要目标是编写可以移动窗口的代码

My main objective is to write code that can move the window

我不知道你是想设置窗口的初始位置还是实际在屏幕上移动窗口,所以我重写了我的例子来演示后者.

I can't tell if you just want to set the initial position of the window or actually move the window around the screen so I rewrote my example to demonstrate the later.

这篇关于更改海龟图形窗口的屏幕位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆