| 1 |
from briefcase.bootstraps.base import BaseGuiBootstrap |
| 2 |
|
| 3 |
|
| 4 |
class PySide6GuiBootstrap(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 sys |
| 11 |
|
| 12 |
from PySide6 import QtWidgets |
| 13 |
|
| 14 |
|
| 15 |
class {{ cookiecutter.class_name }}(QtWidgets.QMainWindow): |
| 16 |
def __init__(self): |
| 17 |
super().__init__() |
| 18 |
self.init_ui() |
| 19 |
|
| 20 |
def init_ui(self): |
| 21 |
self.setWindowTitle("{{ cookiecutter.app_name }}") |
| 22 |
self.show() |
| 23 |
|
| 24 |
|
| 25 |
def main(): |
| 26 |
# Linux desktop environments use an app's .desktop file to integrate the app |
| 27 |
# in to their application menus. The .desktop file of this app will include |
| 28 |
# the StartupWMClass key, set to app's formal name. This helps associate the |
| 29 |
# app's windows to its menu item. |
| 30 |
# |
| 31 |
# For association to work, any windows of the app must have WMCLASS property |
| 32 |
# set to match the value set in app's desktop file. For PySide6, this is set |
| 33 |
# with setApplicationName(). |
| 34 |
|
| 35 |
# Find the name of the module that was used to start the app |
| 36 |
app_module = sys.modules["__main__"].__package__ |
| 37 |
# Retrieve the app's metadata |
| 38 |
metadata = importlib.metadata.metadata(app_module) |
| 39 |
|
| 40 |
QtWidgets.QApplication.setApplicationName(metadata["Formal-Name"]) |
| 41 |
|
| 42 |
app = QtWidgets.QApplication(sys.argv) |
| 43 |
main_window = {{ cookiecutter.class_name }}() |
| 44 |
sys.exit(app.exec()) |
| 45 |
""" |
| 46 |
|
| 47 |
def pyproject_table_briefcase_app_extra_content(self): |
| 48 |
return """ |
| 49 |
requires = [ |
| 50 |
"PySide6-Essentials~=6.8", |
| 51 |
# "PySide6-Addons~=6.8", |
| 52 |
] |
| 53 |
test_requires = [ |
| 54 |
{% if cookiecutter.test_framework == "pytest" %} |
| 55 |
"pytest", |
| 56 |
{% endif %} |
| 57 |
] |
| 58 |
""" |
| 59 |
|
| 60 |
def pyproject_table_macOS(self): |
| 61 |
return """\ |
| 62 |
universal_build = true |
| 63 |
# As of Pyside 6.8, PySide enforces a macOS 12 minimum on wheels. |
| 64 |
min_os_version = "12.0" |
| 65 |
requires = [ |
| 66 |
"std-nslog~=1.0.3", |
| 67 |
] |
| 68 |
""" |
| 69 |
|
| 70 |
def pyproject_table_linux(self): |
| 71 |
return """\ |
| 72 |
requires = [ |
| 73 |
] |
| 74 |
""" |
| 75 |
|
| 76 |
def pyproject_table_linux_system_debian(self): |
| 77 |
return """\ |
| 78 |
system_requires = [ |
| 79 |
] |
| 80 |
|
| 81 |
system_runtime_requires = [ |
| 82 |
"libgl1", |
| 83 |
"libqt6dbus6", |
| 84 |
"libqt6gui6", |
| 85 |
"libxcb-cursor0", |
| 86 |
# The following packages are explicit dependencies on recent Debian-based |
| 87 |
# distros, but not on Ubuntu 22.04. |
| 88 |
"libxcb-icccm4", |
| 89 |
"libxcb-keysyms1", |
| 90 |
"libxcb-shape0", |
| 91 |
"libxkbcommon-x11-0", |
| 92 |
] |
| 93 |
""" |
| 94 |
|
| 95 |
def pyproject_table_linux_system_rhel(self): |
| 96 |
return """\ |
| 97 |
system_requires = [ |
| 98 |
] |
| 99 |
|
| 100 |
system_runtime_requires = [ |
| 101 |
"qt6-qtbase-gui", |
| 102 |
] |
| 103 |
""" |
| 104 |
|
| 105 |
def pyproject_table_linux_system_suse(self): |
| 106 |
return """\ |
| 107 |
system_requires = [ |
| 108 |
] |
| 109 |
|
| 110 |
system_runtime_requires = [ |
| 111 |
"libgthread-2_0-0", |
| 112 |
"libQt6Gui6", |
| 113 |
] |
| 114 |
""" |
| 115 |
|
| 116 |
def pyproject_table_linux_system_arch(self): |
| 117 |
return """\ |
| 118 |
system_requires = [ |
| 119 |
] |
| 120 |
|
| 121 |
system_runtime_requires = [ |
| 122 |
"qt6-base", |
| 123 |
] |
| 124 |
""" |
| 125 |
|
| 126 |
def pyproject_table_linux_appimage(self): |
| 127 |
return """\ |
| 128 |
manylinux = "manylinux_2_28" |
| 129 |
|
| 130 |
system_requires = [ |
| 131 |
# ?? FIXME |
| 132 |
] |
| 133 |
|
| 134 |
linuxdeploy_plugins = [ |
| 135 |
] |
| 136 |
""" |
| 137 |
|
| 138 |
def pyproject_table_linux_flatpak(self): |
| 139 |
return """\ |
| 140 |
flatpak_runtime = "org.kde.Platform" |
| 141 |
flatpak_runtime_version = "6.9" |
| 142 |
flatpak_sdk = "org.kde.Sdk" |
| 143 |
""" |
| 144 |
|
| 145 |
def pyproject_table_windows(self): |
| 146 |
return """\ |
| 147 |
requires = [ |
| 148 |
] |
| 149 |
""" |
| 150 |
|
| 151 |
def pyproject_table_iOS(self): |
| 152 |
return """\ |
| 153 |
supported = false |
| 154 |
""" |
| 155 |
|
| 156 |
def pyproject_table_android(self): |
| 157 |
return """\ |
| 158 |
supported = false |
| 159 |
""" |
| 160 |
|
| 161 |
def pyproject_table_web(self): |
| 162 |
return """\ |
| 163 |
supported = false |
| 164 |
""" |