|
| 1 | +from briefcase.bootstraps.base import BaseGuiBootstrap |
| 2 | + |
| 3 | + |
| 4 | +class PygameCEGuiBootstrap(BaseGuiBootstrap): |
| 5 | + display_name_annotation = "does not support iOS/Android deployment" |
| 6 | + |
| 7 | + def app_source(self): |
| 8 | + return """\ |
| 9 | +import importlib.metadata |
| 10 | +import os |
| 11 | +import sys |
| 12 | +
|
| 13 | +import pygame |
| 14 | +
|
| 15 | +
|
| 16 | +SCREEN_WIDTH, SCREEN_HEIGHT = 800, 600 |
| 17 | +BGCOLOR = (255, 255, 255) |
| 18 | +
|
| 19 | +
|
| 20 | +def main(): |
| 21 | + # Linux desktop environments use an app's .desktop file to integrate the app |
| 22 | + # in to their application menus. The .desktop file of this app will include |
| 23 | + # the StartupWMClass key, set to app's formal name. This helps associate the |
| 24 | + # app's windows to its menu item. |
| 25 | + # |
| 26 | + # For association to work, any windows of the app must have WMCLASS property |
| 27 | + # set to match the value set in app's desktop file. For pygame_ce, this is |
| 28 | + # set using the SDL_VIDEO_X11_WMCLASS environment variable. |
| 29 | +
|
| 30 | + # Find the name of the module that was used to start the app |
| 31 | + app_module = sys.modules["__main__"].__package__ |
| 32 | + # Retrieve the app's metadata |
| 33 | + metadata = importlib.metadata.metadata(app_module) |
| 34 | +
|
| 35 | + os.environ["SDL_VIDEO_X11_WMCLASS"] = metadata["Formal-Name"] |
| 36 | +
|
| 37 | + pygame.init() |
| 38 | + pygame.display.set_caption(metadata["Formal-Name"]) |
| 39 | + screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) |
| 40 | +
|
| 41 | + running = True |
| 42 | + while running: |
| 43 | + for event in pygame.event.get(): |
| 44 | + if event.type == pygame.QUIT: |
| 45 | + running = False |
| 46 | + break |
| 47 | +
|
| 48 | + screen.fill(BGCOLOR) |
| 49 | + pygame.display.flip() |
| 50 | +
|
| 51 | + pygame.quit() |
| 52 | +""" |
| 53 | + |
| 54 | + def pyproject_table_briefcase_app_extra_content(self): |
| 55 | + return """ |
| 56 | +requires = [ |
| 57 | + "pygame-ce", |
| 58 | +] |
| 59 | +""" |
| 60 | + |
| 61 | + def pyproject_table_macOS(self): |
| 62 | + return """\ |
| 63 | +universal_build = true |
| 64 | +requires = [ |
| 65 | + "std-nslog~=1.0.0", |
| 66 | +] |
| 67 | +""" |
| 68 | + |
| 69 | + def pyproject_table_linux(self): |
| 70 | + return """\ |
| 71 | +requires = [ |
| 72 | +] |
| 73 | +""" |
| 74 | + |
| 75 | + def pyproject_table_linux_system_debian(self): |
| 76 | + return """\ |
| 77 | +system_requires = [ |
| 78 | +] |
| 79 | +
|
| 80 | +system_runtime_requires = [ |
| 81 | +] |
| 82 | +""" |
| 83 | + |
| 84 | + def pyproject_table_linux_system_rhel(self): |
| 85 | + return """\ |
| 86 | +system_requires = [ |
| 87 | +] |
| 88 | +
|
| 89 | +system_runtime_requires = [ |
| 90 | +] |
| 91 | +""" |
| 92 | + |
| 93 | + def pyproject_table_linux_system_suse(self): |
| 94 | + return """\ |
| 95 | +system_requires = [ |
| 96 | +] |
| 97 | +
|
| 98 | +system_runtime_requires = [ |
| 99 | +] |
| 100 | +""" |
| 101 | + |
| 102 | + def pyproject_table_linux_system_arch(self): |
| 103 | + return """\ |
| 104 | +system_requires = [ |
| 105 | +] |
| 106 | +
|
| 107 | +system_runtime_requires = [ |
| 108 | +] |
| 109 | +""" |
| 110 | + |
| 111 | + def pyproject_table_linux_appimage(self): |
| 112 | + return """\ |
| 113 | +manylinux = "manylinux_2_28" |
| 114 | +
|
| 115 | +system_requires = [ |
| 116 | +] |
| 117 | +
|
| 118 | +linuxdeploy_plugins = [ |
| 119 | +] |
| 120 | +""" |
| 121 | + |
| 122 | + def pyproject_table_linux_flatpak(self): |
| 123 | + return """\ |
| 124 | +flatpak_runtime = "org.freedesktop.Platform" |
| 125 | +flatpak_runtime_version = "23.08" |
| 126 | +flatpak_sdk = "org.freedesktop.Sdk" |
| 127 | +""" |
| 128 | + |
| 129 | + def pyproject_table_windows(self): |
| 130 | + return """\ |
| 131 | +requires = [ |
| 132 | +] |
| 133 | +""" |
| 134 | + |
| 135 | + def pyproject_table_iOS(self): |
| 136 | + return """\ |
| 137 | +supported = false |
| 138 | +""" |
| 139 | + |
| 140 | + def pyproject_table_android(self): |
| 141 | + return """\ |
| 142 | +supported = false |
| 143 | +""" |
| 144 | + |
| 145 | + def pyproject_table_web(self): |
| 146 | + return """\ |
| 147 | +supported = false |
| 148 | +""" |
0 commit comments