mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-17 13:58:05 +00:00
Initial import of Briefcase plugin
This commit is contained in:
parent
86befbe769
commit
4aae1aa3af
5 changed files with 138 additions and 1 deletions
3
.github/workflows/ci.yaml
vendored
3
.github/workflows/ci.yaml
vendored
|
@ -215,6 +215,9 @@ jobs:
|
||||||
- name: Run ruff linter
|
- name: Run ruff linter
|
||||||
working-directory: api/python/slint
|
working-directory: api/python/slint
|
||||||
run: uv tool run ruff check
|
run: uv tool run ruff check
|
||||||
|
- name: Run ruff linter
|
||||||
|
working-directory: api/python/briefcase
|
||||||
|
run: uv tool run ruff check
|
||||||
|
|
||||||
cpp_test_driver:
|
cpp_test_driver:
|
||||||
needs: files-changed
|
needs: files-changed
|
||||||
|
|
2
.github/workflows/upgrade_version.yaml
vendored
2
.github/workflows/upgrade_version.yaml
vendored
|
@ -26,7 +26,7 @@ jobs:
|
||||||
sed -i 's/ VERSION [0-9]*\.[0-9]*\.[0-9]*)$/ VERSION ${{ github.event.inputs.new_version }})/' api/cpp/CMakeLists.txt
|
sed -i 's/ VERSION [0-9]*\.[0-9]*\.[0-9]*)$/ VERSION ${{ github.event.inputs.new_version }})/' api/cpp/CMakeLists.txt
|
||||||
|
|
||||||
# The version is also in these files
|
# The version is also in these files
|
||||||
sed -i "s/^version = \"[0-9]*\.[0-9]*\.[0-9]*\(.*\)\"/version = \"${{ github.event.inputs.new_version }}\1\"/" api/cpp/docs/conf.py api/python/slint/pyproject.toml
|
sed -i "s/^version = \"[0-9]*\.[0-9]*\.[0-9]*\(.*\)\"/version = \"${{ github.event.inputs.new_version }}\1\"/" api/cpp/docs/conf.py api/python/slint/pyproject.toml api/python/briefcase/pyproject.toml
|
||||||
|
|
||||||
# Version in package.json files
|
# Version in package.json files
|
||||||
git ls-files | grep package.json | xargs sed -i 's/"version": ".*"/"version": "${{ github.event.inputs.new_version }}"/'
|
git ls-files | grep package.json | xargs sed -i 's/"version": ".*"/"version": "${{ github.event.inputs.new_version }}"/'
|
||||||
|
|
17
api/python/briefcase/README.md
Normal file
17
api/python/briefcase/README.md
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!-- Copyright © SixtyFPS GmbH <info@slint.dev> ; SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 -->
|
||||||
|
|
||||||
|
# Briefcase Slint Plugin
|
||||||
|
|
||||||
|
The `briefcasex-slint` package extends the [Briefcase](https://briefcase.readthedocs.io/en/stable/) tool
|
||||||
|
with support for Slint as toolkit for standalone applications.
|
||||||
|
|
||||||
|
Install it in your Python environment, and `briefcase new` will offer you Slint as GUI framework for your next application.
|
||||||
|
|
||||||
|
## Get Started
|
||||||
|
|
||||||
|
In a terminal, create a new Python environment and run the following commands:
|
||||||
|
|
||||||
|
1. `pip install briefcasex-slint`
|
||||||
|
2. `briefcase new -Q bootstrap=Slint`
|
||||||
|
|
||||||
|
Following the instructions on the screen.
|
17
api/python/briefcase/pyproject.toml
Normal file
17
api/python/briefcase/pyproject.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "briefcasex-slint"
|
||||||
|
version = "1.12.1b1"
|
||||||
|
description = "Plugin for Briefcase to offer Slint application templates"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.10"
|
||||||
|
dependencies = ["briefcase>=0.3.23"]
|
||||||
|
|
||||||
|
[project.entry-points."briefcase.bootstraps"]
|
||||||
|
Slint = "briefcasex_slint:SlintGuiBootstrap"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["hatchling"]
|
||||||
|
build-backend = "hatchling.build"
|
100
api/python/briefcase/src/briefcasex_slint/__init__.py
Normal file
100
api/python/briefcase/src/briefcasex_slint/__init__.py
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from briefcase.bootstraps.base import BaseGuiBootstrap
|
||||||
|
|
||||||
|
|
||||||
|
class SlintGuiBootstrap(BaseGuiBootstrap):
|
||||||
|
display_name_annotation = "does not support Android/Web deployment"
|
||||||
|
|
||||||
|
def app_source(self):
|
||||||
|
return """\
|
||||||
|
import slint
|
||||||
|
|
||||||
|
class {{ cookiecutter.class_name }}(slint.loader.{{ cookiecutter.module_name }}.resources.app_window.AppWindow):
|
||||||
|
@slint.callback
|
||||||
|
def request_increase_value(self):
|
||||||
|
self.counter = self.counter + 1
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
main_window = {{ cookiecutter.class_name }}()
|
||||||
|
main_window.show()
|
||||||
|
main_window.run()
|
||||||
|
"""
|
||||||
|
|
||||||
|
def app_start_source(self):
|
||||||
|
return """\
|
||||||
|
from {{ cookiecutter.module_name }}.app import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
"""
|
||||||
|
|
||||||
|
def pyproject_table_briefcase_app_extra_content(self):
|
||||||
|
return """
|
||||||
|
requires = [
|
||||||
|
]
|
||||||
|
test_requires = [
|
||||||
|
{% if cookiecutter.test_framework == "pytest" %}
|
||||||
|
"pytest",
|
||||||
|
{% endif %}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
def pyproject_table_macOS(self):
|
||||||
|
return """\
|
||||||
|
universal_build = false
|
||||||
|
requires = [
|
||||||
|
"slint",
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
def pyproject_table_linux(self):
|
||||||
|
return """\
|
||||||
|
requires = [
|
||||||
|
"slint",
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
def pyproject_table_windows(self):
|
||||||
|
return """\
|
||||||
|
requires = [
|
||||||
|
"slint",
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
def pyproject_table_iOS(self):
|
||||||
|
return """\
|
||||||
|
requires = [
|
||||||
|
"slint",
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
def post_generate(self, base_path: Path) -> None:
|
||||||
|
target_dir = base_path / self.context["source_dir"] / "resources"
|
||||||
|
target_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
with open(target_dir / "app-window.slint", "w") as slint_file:
|
||||||
|
slint_file.write(r"""
|
||||||
|
import { Button, VerticalBox, AboutSlint } from "std-widgets.slint";
|
||||||
|
|
||||||
|
export component AppWindow inherits Window {
|
||||||
|
in-out property<int> counter: 42;
|
||||||
|
callback request-increase-value();
|
||||||
|
VerticalBox {
|
||||||
|
alignment: center;
|
||||||
|
AboutSlint {}
|
||||||
|
Text {
|
||||||
|
text: "Counter: \{root.counter}";
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "Increase value";
|
||||||
|
clicked => {
|
||||||
|
root.request-increase-value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""")
|
Loading…
Add table
Add a link
Reference in a new issue