最后 2 个打印有一些错误,调试说“屏幕”不是一个类。 但是从文档中它说“屏幕是 TurtleScreen 的子类”。 那么这里有什么问题呢? 它与称为 Singolton 对象的东西有关吗? ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我一直在尝试使用python的turtle库创建游戏,但遇到了问题。 当我尝试注册形状时,出现此错误。
Traceback (most recent call last):
File "C:\Users\QuartzMiner6000\PycharmProjects\Test1\src\main.py", line 309, in <module>
screen.register_shape('player.gif')
File "C:\Users\QuartzMiner6000\AppData\Local\Programs\Python\Python36\lib\turtle.py", line 1133, in register_shape
shape = Shape("image", self._image(name))
File "C:\Users\QuartzMiner6000\AppData\Local\Programs\Python\Python36\lib\turtle.py", line 479, in _image
return TK.PhotoImage(file=filename)
File "C:\Users\QuartzMiner6000\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 3542, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Users\QuartzMiner6000\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 3498, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: encountered an unsupported criticial chunk type "mkBF"
这是我的代码
import turtle
from src.variables import *
from math import ceil
TILESIZE = 20
# the number of inventory resources per row
INVWIDTH = 8
drawing = False
# create a new 'screen' object
screen = turtle.Screen()
# calculate the width and height
width = (TILESIZE * MAPWIDTH) + max(200, INVWIDTH * 50)
num_rows = int(ceil((len(resources) / INVWIDTH)))
inventory_height = num_rows * 120 + 40
height = (TILESIZE * MAPHEIGHT) + inventory_height
screen.setup(width, height)
screen.setworldcoordinates(0, 0, width, height)
screen.bgcolor(BACKGROUNDCOLOUR)
screen.listen()
我试图给它完整的图像路径,并将其转换为png,但没有任何效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.