【问题标题】:Python Turtle: How do you set screen size in TurtlePython Turtle:如何在 Turtle 中设置屏幕大小
【发布时间】:2021-04-25 11:49:09
【问题描述】:

我想用 Python Turtle 制作这个简单的游戏,但是,在使窗口保持相同大小且无法调整大小方面遇到了很多麻烦。我已经确定检查了谷歌的第二页,是的。

import turtle


class Window:
    def __init__(self, dim):
        self.win = turtle.Screen()
        assert type(dim) == type((1, 2))
        self.win.setup(width=dim[0], height=dim[1])
        self.win.setworldcoordinates(0, 0, dim[0], dim[1])

    def init(self):
        self.win.mainloop()


a = Window((100, 100))
a.init()

这是我的代码,希望你有愉快的一天!

【问题讨论】:

  • 我的意思是我还在问一个问题

标签: python-3.x turtle-graphics python-turtle


【解决方案1】:

尝试像这样使用turtle.screensize()

import turtle

turtle.screensize(canvwidth=400, canvheight=400)

【讨论】:

  • 哟,非常感谢!这是一个非常古老的问题,我不再需要它了,但仍然...... tysm!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-14
  • 2014-09-24
相关资源
最近更新 更多