PermissionError:[Errno 13]权限被拒绝:(执行一分钟后,程序暂停)

时间:2018-10-14 20:02:54

标签: python pygame

执行大约需要一分钟后,我一直收到此错误。我认为这与路径问题无关,因为所有图片都在当前文件夹中。自从我在一分钟后得到这个消息后,我感到困惑。 有人可以帮我吗?

class PVCScreen (Screen):
def __init__(self, gameDisplay, screenX, screenY):
    self._gameDisplay = gameDisplay
    self._screenX = screenX
    self._screenY = screenY
    self._prompt_level = Button(gameDisplay, (5 * screenX // 24), (screenY // 18), (7 * screenX // 12), (screenY // 4), "prompt_level.jpg", "resized_prompt_level.jpg")
    self._easy_button = Button(gameDisplay, (5 * screenX // 24), (screenY // 2.25), (5 * screenX // 32), (5 * screenY // 36), "easy_button.png", "resized_easy_button.png")
    self._medium_button = Button(gameDisplay, (61 * screenX // 96), (screenY // 2.25), (5 * screenX // 32), (5 * screenY // 36), "medium_button.png", "resized_medium_button.png")
    self._hard_button = Button(gameDisplay, (5 * screenX // 24), (screenY // 1.25), (5 * screenX // 32), (5 * screenY // 36), "hard_button.png", "resized_hard_button.png")
    self._extreme_button = Button(gameDisplay, (61 * screenX // 96), (screenY // 1.25), (5 * screenX // 32), (5 * screenY // 36), "extreme_button.gif", "resized_extreme_button.gif")

我遇到的任何我所做的按钮都出错。

这是Button类:

class Button:
def __init__(self, display, x, y, width, height, img_name_old, img_name_new):
    self._display = display
    self._x = x
    self._y = y
    self._width = width
    self._height = height
    self.resizeImage(img_name_old, img_name_new, width, height)
    button_image = pygame.image.load(img_name_old)
    display.blit(button_image, [x,y])
    # yukarisina gerek olmayabilir


# new size of the pic is passed as x and y.
def resizeImage(self, img_name_old, img_name_new, width, height):
    img = Image.open(img_name_old)
    img = img.resize((width, height), PIL.Image.ANTIALIAS)
    img.save(img_name_old)
    return img

先谢谢您。

0 个答案:

没有答案