Python Turtle:如何在 Turtle 中设置屏幕大小
Python Turtle: How do you set screen size in Turtle
我想在 Python Turtle 中制作这个简单的游戏,但是,我在使 window 保持相同大小且不可调整大小方面遇到了很多麻烦。我已经确保检查了 Google 的第二页,是的。
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()
这是我的代码,希望您有愉快的一天!
尝试像这样使用 turtle.screensize()
:
import turtle
turtle.screensize(canvwidth=400, canvheight=400)
我想在 Python Turtle 中制作这个简单的游戏,但是,我在使 window 保持相同大小且不可调整大小方面遇到了很多麻烦。我已经确保检查了 Google 的第二页,是的。
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()
这是我的代码,希望您有愉快的一天!
尝试像这样使用 turtle.screensize()
:
import turtle
turtle.screensize(canvwidth=400, canvheight=400)