我用python做了一个画乌龟的程序,但是我画乌龟的画布不够大。我正在尝试使这个画布更大,以便我可以在页面上容纳更多内容并使内容更大。我正在trinket.io 中对此进行编程。
我正在trinket.io 中对此进行编程。
那是你的问题——不幸的是,这在trinket.io 中是不可能的。
Trinket.io 不支持所有turtle方法。您可以在此处阅读支持哪些功能;我认为其余的不受支持。
这将适用于您的本地 python 解释器:
import turtle
print(turtle.Screen().screensize()) # returns (400,300) for me
Run Code Online (Sandbox Code Playgroud)
但这将在 Trinket.io 中失败,并显示如下消息:
> AttributeError: 'Screen' object has no attribute 'screensize' on line 3 in main.py
Run Code Online (Sandbox Code Playgroud)
文档暗示turtle.setup()支持它,但是,它似乎不支持,因为这将在您的本地 python 解释器上运行并在 trinket.io 中失败。
import turtle
turtle.setup(500,500)
Run Code Online (Sandbox Code Playgroud)
我在 trinket.io 中唯一能做的就是能够通过以下方式返回(未设置)尺寸:
print(turtle.window_height())
print(turtle.window_width())
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22417 次 |
| 最近记录: |