-
-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for third-party GUI framework plugins
- Loading branch information
Showing
13 changed files
with
1,565 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Creating new projects with arbitrary third-party GUI frameworks is now supported via plugins. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from briefcase.plugins.frameworks.base import BaseGuiPlugin # noqa: F401 | ||
from briefcase.plugins.frameworks.pursuedpybear import ( # noqa: F401 | ||
PursuedPyBearGuiPlugin, | ||
) | ||
from briefcase.plugins.frameworks.pygame import PygameGuiPlugin # noqa: F401 | ||
from briefcase.plugins.frameworks.pyside2 import PySide2GuiPlugin # noqa: F401 | ||
from briefcase.plugins.frameworks.pyside6 import PySide6GuiPlugin # noqa: F401 | ||
from briefcase.plugins.frameworks.toga import TogaGuiPlugin # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
from __future__ import annotations | ||
|
||
from abc import ABC | ||
from typing import Literal | ||
|
||
|
||
class BaseGuiPlugin(ABC): | ||
name: str | ||
fields: list[str] = [ | ||
"app_source", | ||
"start_app_source", | ||
"requires", | ||
"macos_requires", | ||
"macos_universal_build", | ||
"linux_requires", | ||
"linux_system_debian_system_requires", | ||
"linux_system_debian_system_runtime_requires", | ||
"linux_system_rhel_system_requires", | ||
"linux_system_rhel_system_runtime_requires", | ||
"linux_system_suse_system_requires", | ||
"linux_system_suse_system_runtime_requires", | ||
"linux_system_arch_system_requires", | ||
"linux_system_arch_system_runtime_requires", | ||
"linux_appimage_manylinux", | ||
"linux_appimage_system_requires", | ||
"linux_appimage_linuxdeploy_plugins", | ||
"linux_flatpak_runtime", | ||
"linux_flatpak_runtime_version", | ||
"linux_flatpak_sdk", | ||
"windows_requires", | ||
"ios_requires", | ||
"ios_supported", | ||
"android_requires", | ||
"android_supported", | ||
"web_requires", | ||
"web_supported", | ||
"web_style_framework", | ||
] | ||
|
||
def __init__(self, context: dict[str, str | int | bool]): | ||
# context contains metadata about the app: | ||
# formal_name | ||
# app_name | ||
# class_name | ||
# module_name | ||
# project_name | ||
# description | ||
# author | ||
# author_email | ||
# bundle | ||
# url | ||
# license | ||
self.context = context | ||
|
||
def app_source(self) -> str | None: | ||
"""The Python source code for the project.""" | ||
|
||
def start_app_source(self) -> str | None: | ||
"""The Python source code to start the app from __main__.py.""" | ||
|
||
def requires(self) -> str | None: | ||
"""List of package requirements for all platforms.""" | ||
|
||
def macos_requires(self) -> str | None: | ||
"""List of package requirements for macOS.""" | ||
|
||
def macos_universal_build(self) -> Literal["true", "false"] | None: | ||
"""Whether to create a universal build for macOS.""" | ||
|
||
def linux_requires(self) -> str | None: | ||
"""List of package requirements for Linux.""" | ||
|
||
def linux_system_debian_system_requires(self) -> str | None: | ||
"""List of system package requirements to build the app.""" | ||
|
||
def linux_system_debian_system_runtime_requires(self) -> str | None: | ||
"""List of system package requirements to run the app on Debian.""" | ||
|
||
def linux_system_rhel_system_requires(self) -> str | None: | ||
"""List of system package requirements to build the app on RHEL.""" | ||
|
||
def linux_system_rhel_system_runtime_requires(self) -> str | None: | ||
"""List of system package requirements to run the app on RHEL.""" | ||
|
||
def linux_system_suse_system_requires(self) -> str | None: | ||
"""List of system package requirements to build the app on SUSE.""" | ||
|
||
def linux_system_suse_system_runtime_requires(self) -> str | None: | ||
"""List of system package requirements to run the app on SUSE.""" | ||
|
||
def linux_system_arch_system_requires(self) -> str | None: | ||
"""List of system package requirements to build the app on Arch.""" | ||
|
||
def linux_system_arch_system_runtime_requires(self) -> str | None: | ||
"""List of system package requirements to run the app on Arch.""" | ||
|
||
def linux_appimage_manylinux(self) -> str | None: | ||
"""The manylinux base, e.g. manylinux2014, to use to build the app.""" | ||
|
||
def linux_appimage_system_requires(self) -> str | None: | ||
"""List of system package requirements to build the app in to an AppImage.""" | ||
|
||
def linux_appimage_linuxdeploy_plugins(self) -> str | None: | ||
"""List of linuxdeploy plugins to use to build the app in to an AppImage.""" | ||
|
||
def linux_flatpak_runtime(self) -> str | None: | ||
"""The Flatpak runtime, e.g. org.gnome.Platform, for the app.""" | ||
|
||
def linux_flatpak_runtime_version(self) -> str | None: | ||
"""The Flatpak runtime version, e.g. 44, for the app.""" | ||
|
||
def linux_flatpak_sdk(self) -> str | None: | ||
"""The Flatpak SDK, e.g. org.gnome.Sdk, for the app.""" | ||
|
||
def windows_requires(self) -> str | None: | ||
"""List of package requirements for Windows.""" | ||
|
||
def ios_requires(self) -> str | None: | ||
"""List of package requirements for iOS.""" | ||
|
||
def ios_supported(self) -> Literal["true", "false"] | None: | ||
"""Whether the GUI framework supports iOS.""" | ||
|
||
def android_requires(self) -> str | None: | ||
"""List of package requirements for Android.""" | ||
|
||
def android_supported(self) -> Literal["true", "false"] | None: | ||
"""Whether the GUI framework supports Android.""" | ||
|
||
def web_requires(self) -> str | None: | ||
"""List of package requirements for Web.""" | ||
|
||
def web_supported(self) -> Literal["true", "false"] | None: | ||
"""Whether the GUI framework supports Web.""" | ||
|
||
def web_style_framework(self) -> str | None: | ||
"""The style framework, e.g. Bootstrap or Shoelace, for web.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from briefcase.plugins.frameworks.base import BaseGuiPlugin | ||
|
||
|
||
class PursuedPyBearGuiPlugin(BaseGuiPlugin): | ||
name = "PursuedPyBear" | ||
|
||
def app_source(self): | ||
return """ | ||
import os | ||
import sys | ||
try: | ||
from importlib import metadata as importlib_metadata | ||
except ImportError: | ||
# Backwards compatibility - importlib.metadata was added in Python 3.8 | ||
import importlib_metadata | ||
import ppb | ||
class {{ cookiecutter.class_name }}(ppb.Scene): | ||
def __init__(self, **props): | ||
super().__init__(**props) | ||
self.add(ppb.Sprite( | ||
image=ppb.Image('{{ cookiecutter.module_name }}/resources/{{ cookiecutter.app_name }}.png'), | ||
)) | ||
def main(): | ||
# Linux desktop environments use app's .desktop file to integrate the app | ||
# to their application menus. The .desktop file of this app will include | ||
# StartupWMClass key, set to app's formal name, which helps associate | ||
# app's windows to its menu item. | ||
# | ||
# For association to work any windows of the app must have WMCLASS | ||
# property set to match the value set in app's desktop file. For PPB this | ||
# is set using environment variable. | ||
# Find the name of the module that was used to start the app | ||
app_module = sys.modules['__main__'].__package__ | ||
# Retrieve the app's metadata | ||
metadata = importlib_metadata.metadata(app_module) | ||
os.environ['SDL_VIDEO_X11_WMCLASS'] = metadata['Formal-Name'] | ||
ppb.run( | ||
starting_scene={{ cookiecutter.class_name }}, | ||
title=metadata['Formal-Name'], | ||
) | ||
""" | ||
|
||
def requires(self): | ||
return """ | ||
"ppb~=1.1", | ||
""" | ||
|
||
def linux_appimage_manylinux(self): | ||
return "manylinux2014" | ||
|
||
def linux_flatpak_runtime(self): | ||
return "org.freedesktop.Platform" | ||
|
||
def linux_flatpak_runtime_version(self): | ||
return "22.08" | ||
|
||
def linux_flatpak_sdk(self): | ||
return "org.freedesktop.Sdk" | ||
|
||
|
||
plugin = PursuedPyBearGuiPlugin |
Oops, something went wrong.