Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
target
target
__pycache__
*.pyc
13 changes: 12 additions & 1 deletion src/main/python/preponderous/graphik/graphik.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,15 @@ def drawButton(self, xpos, ypos, width, height, colorBox, colorText, sizeText, t
if (xpos + width > mouse[0] > xpos and ypos + height > mouse[1] > ypos):
click = pygame.mouse.get_pressed()
if click[0] == 1:
function()
function()

def drawImage(self, filePath, xpos, ypos, width, height):
try:
image = pygame.image.load(filePath)
image = pygame.transform.scale(image, (width, height))
self.gameDisplay.blit(image, (xpos, ypos))
except FileNotFoundError as e:
# Preserve the original exception and chain it
raise FileNotFoundError(f"Failed to load image from '{filePath}': {e}") from e
except pygame.error as e:
raise pygame.error(f"Failed to load image from '{filePath}': {e}") from e