Debian Codegraph @

src/briefcase/bootstraps/pygame.py

raw
1 from briefcase.bootstraps.base import BaseGuiBootstrap
2
3
4 class PygameGuiBootstrap(BaseGuiBootstrap):
5 display_name_annotation = "does not support iOS/Android/Web deployment"
6
7 def app_source(self):
8 return """\
9 import importlib.metadata
10 import os
11 import sys
12 from pathlib import Path
13
14 import pygame
15
16 SCREEN_WIDTH, SCREEN_HEIGHT = 800, 600
17 WHITE = (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, this is set
28 # 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(WHITE)
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~=2.6",
58 ]
59 test_requires = [
60 {% if cookiecutter.test_framework == "pytest" %}
61 "pytest",
62 {% endif %}
63 ]
64 """
65
66 def pyproject_table_macOS(self):
67 return """\
68 universal_build = true
69 requires = [
70 "std-nslog~=1.0.3",
71 ]
72 """
73
74 def pyproject_table_linux(self):
75 return """\
76 requires = [
77 ]
78 """
79
80 def pyproject_table_linux_system_debian(self):
81 return """\
82 system_requires = [
83 ]
84
85 system_runtime_requires = [
86 ]
87 """
88
89 def pyproject_table_linux_system_rhel(self):
90 return """\
91 system_requires = [
92 ]
93
94 system_runtime_requires = [
95 ]
96 """
97
98 def pyproject_table_linux_system_suse(self):
99 return """\
100 system_requires = [
101 ]
102
103 system_runtime_requires = [
104 ]
105 """
106
107 def pyproject_table_linux_system_arch(self):
108 return """\
109 system_requires = [
110 ]
111
112 system_runtime_requires = [
113 ]
114 """
115
116 def pyproject_table_linux_appimage(self):
117 return """\
118 manylinux = "manylinux_2_28"
119
120 system_requires = [
121 ]
122
123 linuxdeploy_plugins = [
124 ]
125 """
126
127 def pyproject_table_linux_flatpak(self):
128 return """\
129 flatpak_runtime = "org.freedesktop.Platform"
130 flatpak_runtime_version = "25.08"
131 flatpak_sdk = "org.freedesktop.Sdk"
132 """
133
134 def pyproject_table_windows(self):
135 return """\
136 requires = [
137 ]
138 """
139
140 def pyproject_table_iOS(self):
141 return """\
142 supported = false
143 """
144
145 def pyproject_table_android(self):
146 return """\
147 supported = false
148 """
149
150 def pyproject_table_web(self):
151 return """\
152 supported = false
153 """