如何在python乌龟模块中使画布更大 [英] How to make canvas bigger in the python turtle module

查看:35
本文介绍了如何在python乌龟模块中使画布更大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用python做了一个画海龟的程序,但是我画海龟的画布不够大.我正在尝试使这个画布更大,以便我可以在页面上容纳更多内容并使内容更大.我正在trinket.io中编程.

I made a turtle drawing program in python, but my canvas in which the turtle draws is not big enough. I am trying to make this canvas bigger so that I can fit more on the page and make the stuff bigger. I am programming this in trinket.io.

推荐答案

我正在trinket.io中编程.

I am programming this in trinket.io.

那是你的问题——不幸的是,这在trinket.io 中是不可能的.

That is your problem -- Unfortunately, this is not possible in trinket.io.

Trinket.io 不支持所有的 turtle 方法.您可以在此处阅读支持哪些功能;我认为其余的不受支持.

Trinket.io does not support all the turtle methods. You can read which ones are supported here; I assume the rest are unsupported.

这将适用于您的本地 python 解释器:

This will work on your local python interpreter:

import turtle

print(turtle.Screen().screensize()) # returns (400,300) for me

但这会在 Trinket.io 中失败,并显示如下消息:

But this will fail in Trinket.io, with a message like:

> AttributeError: 'Screen' object has no attribute 'screensize' on line 3 in main.py

文档暗示支持 turtle.setup(),但是,它似乎不支持,因为这将在您的本地 python 解释器上运行并在 trinket.io 中失败.

The documentation implies that turtle.setup() is supported, however, it seems not to be, because this will work on your local python interpreter and fail in trinket.io.

import turtle

turtle.setup(500,500)

我在 trinket.io 中唯一能做的就是能够返回(未设置)尺寸,通过:

The only thing I have been able to do in trinket.io is to be able to return (not set) the dimensions, via:

print(turtle.window_height())
print(turtle.window_width())

这篇关于如何在python乌龟模块中使画布更大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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