J'ai donc commencé à utiliser python et pygame pour commencer à construire un programme de poker, et j'ai téléchargé un tas d'images pour les cartes. J'ai commencé à faire un programme de test pour les images:objet 'module' de pygame non appelable
import pygame
pygame.init()
screen = pygame.display.set_mode((1200, 675)) #Sets the screen to a 16:9 ratio display
pygame.display.set_caption('Poker Program') #Used to set the window name as whatever's in the brackets
feltGreen = (0,200,0) #What is used for the color (r,g,b)(the higher the number, the lighter the colour)
screen.fill(feltGreen)
pygame.display.update() #Updates the screen
twoc = pygame.image("2_of_clubs.png")
twod = pygame.image("2_of_diamonds.png")
twoh = pygame.image("2_of_hearts.png")
twos = pygame.image("2_of_spades.png")
threec = pygame.image("3_of_clubs.png")
threed = pygame.image("3_of_diamonds.png")
threeh = pygame.image("3_of_hearts.png")
threes = pygame.image("3_of_spades.png")
Pour la première fois, cela fonctionne parfaitement. Mais alors je reçois ceci:
Traceback (most recent call last):
File "C:/Users/Z & Z Azam/Desktop/New folder (2)/Python Stuff/PycharmProjects/ProjectGambler/Graphics-Cards.py", line 15, in <module>
twoc = pygame.image("2_of_clubs.png")
TypeError: 'module' object is not callable
J'ai tout essayé, mais ça dit toujours ça. Y a-t-il quelque chose que je puisse faire pour que ça marche? PS Le dossier dans lequel je stocke les cartes se trouve dans le dossier scripts de Python35.
Mise à jour: Je l'ai remplacé tous les pygame.image avec pygame.image.load, mais maintenant je reçois ceci:
Traceback (most recent call last):
File "C:/Users/Z & Z Azam/Desktop/New folder (2)/Python Stuff/PycharmProjects/ProjectGambler/Graphics-Cards.py", line 15, in <module>
twoc = pygame.image.load("2_of_clubs.png") #Lines 15-66 bring all the cards into the program
pygame.error: Couldn't open 2_of_clubs.png