| 1 |
from briefcase.bootstraps.base import BaseGuiBootstrap |
| 2 |
|
| 3 |
|
| 4 |
class TogaGuiBootstrap(BaseGuiBootstrap): |
| 5 |
def app_source(self): |
| 6 |
return '''\ |
| 7 |
import toga |
| 8 |
from toga.style.pack import COLUMN, ROW |
| 9 |
|
| 10 |
|
| 11 |
class {{ cookiecutter.class_name }}(toga.App): |
| 12 |
def startup(self): |
| 13 |
"""Construct and show the Toga application. |
| 14 |
|
| 15 |
Usually, you would add your application to a main content box. |
| 16 |
We then create a main window (with a name matching the app), and |
| 17 |
show the main window. |
| 18 |
""" |
| 19 |
main_box = toga.Box() |
| 20 |
|
| 21 |
self.main_window = toga.MainWindow(title=self.formal_name) |
| 22 |
self.main_window.content = main_box |
| 23 |
self.main_window.show() |
| 24 |
|
| 25 |
|
| 26 |
def main(): |
| 27 |
return {{ cookiecutter.class_name }}() |
| 28 |
''' |
| 29 |
|
| 30 |
def app_start_source(self): |
| 31 |
return """\ |
| 32 |
from {{ cookiecutter.module_name }}.app import main |
| 33 |
|
| 34 |
if __name__ == "__main__": |
| 35 |
main().main_loop() |
| 36 |
""" |
| 37 |
|
| 38 |
def pyproject_table_briefcase_app_extra_content(self): |
| 39 |
return """ |
| 40 |
requires = [ |
| 41 |
] |
| 42 |
test_requires = [ |
| 43 |
{% if cookiecutter.test_framework == "pytest" %} |
| 44 |
"pytest", |
| 45 |
{% endif %} |
| 46 |
] |
| 47 |
""" |
| 48 |
|
| 49 |
def pyproject_table_macOS(self): |
| 50 |
return """\ |
| 51 |
universal_build = true |
| 52 |
requires = [ |
| 53 |
"toga-cocoa~=0.5.0", |
| 54 |
"std-nslog~=1.0.3", |
| 55 |
] |
| 56 |
""" |
| 57 |
|
| 58 |
def pyproject_table_linux(self): |
| 59 |
return """\ |
| 60 |
requires = [ |
| 61 |
"toga-gtk~=0.5.0", |
| 62 |
# PyGObject 3.52.1 enforces a requirement on libgirepository-2.0-dev. This library |
| 63 |
# isn't available on Debian 12/Ubuntu 22.04. If you don't need to support those (or |
| 64 |
# older) releases, you can remove this version pin. See beeware/toga#3143. |
| 65 |
"pygobject < 3.52.1", |
| 66 |
] |
| 67 |
""" |
| 68 |
|
| 69 |
def pyproject_table_linux_system_debian(self): |
| 70 |
return """\ |
| 71 |
system_requires = [ |
| 72 |
# Needed to compile pycairo wheel |
| 73 |
"libcairo2-dev", |
| 74 |
# One of the following two packages are needed to compile PyGObject wheel. If you |
| 75 |
# remove the pygobject pin in the requires list, you should also change to the |
| 76 |
# version 2.0 of the girepository library. See beeware/toga#3143. |
| 77 |
"libgirepository1.0-dev", |
| 78 |
# "libgirepository-2.0-dev", |
| 79 |
] |
| 80 |
|
| 81 |
system_runtime_requires = [ |
| 82 |
# Needed to provide GTK and its GI bindings |
| 83 |
"gir1.2-gtk-3.0", |
| 84 |
# One of the following two packages are needed to use PyGObject at runtime. If you |
| 85 |
# remove the pygobject pin in the requires list, you should also change to the |
| 86 |
# version 2.0 of the girepository library. See beeware/toga#3143. |
| 87 |
"libgirepository-1.0-1", |
| 88 |
# "libgirepository-2.0-0", |
| 89 |
# Dependencies that GTK looks for at runtime |
| 90 |
"libcanberra-gtk3-module", |
| 91 |
# Needed to provide WebKit2 at runtime |
| 92 |
# Note: Debian 11 requires gir1.2-webkit2-4.0 instead |
| 93 |
# "gir1.2-webkit2-4.1", |
| 94 |
] |
| 95 |
""" |
| 96 |
|
| 97 |
def pyproject_table_linux_system_rhel(self): |
| 98 |
return """\ |
| 99 |
system_requires = [ |
| 100 |
# Needed to compile pycairo wheel |
| 101 |
"cairo-gobject-devel", |
| 102 |
# Needed to compile PyGObject wheel |
| 103 |
"gobject-introspection-devel", |
| 104 |
] |
| 105 |
|
| 106 |
system_runtime_requires = [ |
| 107 |
# Needed to support Python bindings to GTK |
| 108 |
"gobject-introspection", |
| 109 |
# Needed to provide GTK |
| 110 |
"gtk3", |
| 111 |
# Dependencies that GTK looks for at runtime |
| 112 |
"libcanberra-gtk3", |
| 113 |
# Needed to provide WebKit2 at runtime |
| 114 |
# "webkit2gtk3", |
| 115 |
] |
| 116 |
""" |
| 117 |
|
| 118 |
def pyproject_table_linux_system_suse(self): |
| 119 |
return """\ |
| 120 |
system_requires = [ |
| 121 |
# Needed to compile pycairo wheel |
| 122 |
"cairo-devel", |
| 123 |
# Needed to compile PyGObject wheel |
| 124 |
"gobject-introspection-devel", |
| 125 |
] |
| 126 |
|
| 127 |
system_runtime_requires = [ |
| 128 |
# Needed to provide GTK |
| 129 |
"gtk3", |
| 130 |
# Needed to support Python bindings to GTK |
| 131 |
"gobject-introspection", "typelib(Gtk) = 3.0", |
| 132 |
# Dependencies that GTK looks for at runtime |
| 133 |
"libcanberra-gtk3-module", |
| 134 |
# Needed to provide WebKit2 at runtime |
| 135 |
# "libwebkit2gtk3", "typelib(WebKit2)", |
| 136 |
] |
| 137 |
""" |
| 138 |
|
| 139 |
def pyproject_table_linux_system_arch(self): |
| 140 |
return """\ |
| 141 |
system_requires = [ |
| 142 |
# Needed to compile pycairo wheel |
| 143 |
"cairo", |
| 144 |
# Needed to compile PyGObject wheel |
| 145 |
"gobject-introspection", |
| 146 |
# Runtime dependencies that need to exist so that the |
| 147 |
# Arch package passes final validation. |
| 148 |
# Needed to provide GTK |
| 149 |
"gtk3", |
| 150 |
# Dependencies that GTK looks for at runtime |
| 151 |
"libcanberra", |
| 152 |
# Needed to provide WebKit2 |
| 153 |
# "webkit2gtk", |
| 154 |
] |
| 155 |
|
| 156 |
system_runtime_requires = [ |
| 157 |
# Needed to provide GTK |
| 158 |
"gtk3", |
| 159 |
# Needed to provide PyGObject bindings |
| 160 |
"gobject-introspection-runtime", |
| 161 |
# Dependencies that GTK looks for at runtime |
| 162 |
"libcanberra", |
| 163 |
# Needed to provide WebKit2 at runtime |
| 164 |
# "webkit2gtk", |
| 165 |
] |
| 166 |
""" |
| 167 |
|
| 168 |
def pyproject_table_linux_appimage(self): |
| 169 |
return """\ |
| 170 |
manylinux = "manylinux_2_28" |
| 171 |
|
| 172 |
system_requires = [ |
| 173 |
# Needed to compile pycairo wheel |
| 174 |
"cairo-gobject-devel", |
| 175 |
# Needed to compile PyGObject wheel |
| 176 |
"gobject-introspection-devel", |
| 177 |
# Needed to provide GTK |
| 178 |
"gtk3-devel", |
| 179 |
# Dependencies that GTK looks for at runtime, that need to be |
| 180 |
# in the build environment to be picked up by linuxdeploy |
| 181 |
"libcanberra-gtk3", |
| 182 |
"PackageKit-gtk3-module", |
| 183 |
"gvfs-client", |
| 184 |
] |
| 185 |
|
| 186 |
linuxdeploy_plugins = [ |
| 187 |
"DEPLOY_GTK_VERSION=3 gtk", |
| 188 |
] |
| 189 |
""" |
| 190 |
|
| 191 |
def pyproject_table_linux_flatpak(self): |
| 192 |
return """\ |
| 193 |
flatpak_runtime = "org.gnome.Platform" |
| 194 |
flatpak_runtime_version = "48" |
| 195 |
flatpak_sdk = "org.gnome.Sdk" |
| 196 |
""" |
| 197 |
|
| 198 |
def pyproject_table_windows(self): |
| 199 |
return """\ |
| 200 |
requires = [ |
| 201 |
"toga-winforms~=0.5.0", |
| 202 |
] |
| 203 |
""" |
| 204 |
|
| 205 |
def pyproject_table_iOS(self): |
| 206 |
return """\ |
| 207 |
requires = [ |
| 208 |
"toga-iOS~=0.5.0", |
| 209 |
"std-nslog~=1.0.3", |
| 210 |
] |
| 211 |
""" |
| 212 |
|
| 213 |
def pyproject_table_android(self): |
| 214 |
return '''\ |
| 215 |
requires = [ |
| 216 |
"toga-android~=0.5.0", |
| 217 |
] |
| 218 |
|
| 219 |
base_theme = "Theme.MaterialComponents.Light.DarkActionBar" |
| 220 |
|
| 221 |
build_gradle_dependencies = [ |
| 222 |
"com.google.android.material:material:1.13.0", |
| 223 |
# Needed for DetailedList |
| 224 |
# "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0", |
| 225 |
# Needed for MapView |
| 226 |
# "org.osmdroid:osmdroid-android:6.1.20", |
| 227 |
# Needed for WebView |
| 228 |
# "androidx.webkit:webkit:1.15.0", |
| 229 |
] |
| 230 |
|
| 231 |
# Needed for WebView |
| 232 |
# build_gradle_extra_content=""" |
| 233 |
# chaquopy.defaultConfig.staticProxy("toga_android.widgets.internal.webview") |
| 234 |
# """ |
| 235 |
''' |
| 236 |
|
| 237 |
def pyproject_table_web(self): |
| 238 |
return """\ |
| 239 |
requires = [ |
| 240 |
"toga-web~=0.5.0", |
| 241 |
] |
| 242 |
""" |