Skip to content

Commit

Permalink
Set runtime icon for PyGame apps
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed Nov 20, 2023
1 parent ccda123 commit b578b9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes/1532.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The BeeWare icon of Brutus is now used as the runtime icon for new projects created with PyGame.
8 changes: 8 additions & 0 deletions src/briefcase/bootstraps/pygame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def app_source(self):
return """\
import importlib.metadata
import os
import pkg_resources
import sys
import pygame
Expand All @@ -34,6 +35,13 @@ def main():
os.environ["SDL_VIDEO_X11_WMCLASS"] = metadata["Formal-Name"]
# Set the app's runtime icon
pygame.display.set_icon(
pygame.image.load(
pkg_resources.resource_filename(app_module, f"resources/{app_module}.png")
)
)
pygame.init()
pygame.display.set_caption(metadata["Formal-Name"])
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
Expand Down
8 changes: 8 additions & 0 deletions tests/commands/new/test_build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ def test_question_sequence_pygame(new_command):
app_source="""\
import importlib.metadata
import os
import pkg_resources
import sys
import pygame
Expand All @@ -672,6 +673,13 @@ def main():
os.environ["SDL_VIDEO_X11_WMCLASS"] = metadata["Formal-Name"]
# Set the app's runtime icon
pygame.display.set_icon(
pygame.image.load(
pkg_resources.resource_filename(app_module, f"resources/{app_module}.png")
)
)
pygame.init()
pygame.display.set_caption(metadata["Formal-Name"])
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
Expand Down

0 comments on commit b578b9b

Please sign in to comment.