diff --git a/examples/toga/README.md b/examples/toga/README.md index ae974ea1..23c1145b 100644 --- a/examples/toga/README.md +++ b/examples/toga/README.md @@ -2,66 +2,40 @@ This is a demo Toga app implementing a Fahrenheit to Celsius converter. +It can be served as a Single Page App from a static web server. + ## Initial setup -1. Create and activate a virtual environment: +1. Create and activate a virtual environment, and move into the `freedom` + project directory: - $ python -m venv venv - $ . ./venv/bin/activate + $ python -m venv venv + $ . ./venv/bin/activate + $ cd freedom -2. Install the demo requirements: +2. Install Briefcase: - $ pip install -r requirements.txt - -### Development details - -This demo symbolically links the pyscript build generated by the npm server -(`../build`) into the `./static/pyscript` directory. This symbolic link should -be restored automatically by git. This also means you'll need to run the main -pyscript demos at least once before running the server-rendered version of the -app. If you experience problems loading pyscript, check whether this link -exists, and the `build/pyscript.js` file has been compiled. - -It also includes an vendored experimental version of toga-core, toga-web and -toga-flask, packaged as wheels in the `./static/wheels` directory. If any changes -are made to the Toga sources, these vendored resources will need to be updated. + $ pip install briefcase ## Web app This app can be viewed as a Single Page App (SPA); this version of the app is -linked from the main PyScript demo pages. +linked from the main PyScript demo pages. To re-build the app and start a +local webserver, run: -It can also be viewed as a server-rendered app. This version of the app is -delivered by a demo Flask server, serving a version of app at the root URL. To -run the web demo server: - - $ cd server - $ PYTHONPATH=../freedom/src python -m demo - -then point your browser at http://localhost:8081/ - -Enter a value in the "Fahrenheit" input, and click the "calculate" button. - -It may take a few seconds for this button to become live; look for the -"Collecting nodes..." entry in the console log. + $ briefcase run web ## Desktop app -To run this app in development mode: +To run this app as a desktop app in development mode: $ briefcase dev -To build and run an app bundle: +To build and run it as an app bundle: $ briefcase run -If you're on an M1 macOS, this will raise an error on first run; if you get this error, run: - - $ briefcase package -p app --adhoc-sign - -then re-run `briefcase run` - -## iOS app +## Mobile app To run this in the iOS simulator, run: diff --git a/examples/toga/freedom.html b/examples/toga/freedom.html index 52d7f407..3b4a7e1c 100644 --- a/examples/toga/freedom.html +++ b/examples/toga/freedom.html @@ -1,55 +1,51 @@ - - - - + + + + Freedom Units - - - + - - - Loading... - - - - - - - - - packages = [ - "./static/wheels/travertino-0.1.3-py3-none-any.whl", - "./static/wheels/toga_core-0.3.0.dev39-py3-none-any.whl", - "./static/wheels/toga_web-0.3.0.dev39-py3-none-any.whl", - "./static/wheels/freedom-0.0.1-py3-none-any.whl" - ] - terminal = false - - -
Loading...
- - from pyscript import Element - from freedom.__main__ import main + + - # Remove text from placeholder - Element('app-placeholder').write('', append=False) - app = main().main_loop() - - + + + + + +
+ + + + + +name = "Freedom Units" +description = "A testing app" +version = "0.0.1" +terminal = false +packages = [ + "./static/wheels/freedom-0.0.1-py3-none-any.whl", + "toga_core==0.3.0", + "toga_web==0.3.0", + "travertino==0.1.3", +] + +[splashscreen] +autoclose = true + + + import runpy + result = runpy.run_module("freedom", run_name="__main__", alter_sys=True) + + diff --git a/examples/toga/freedom/base-wheel.zip b/examples/toga/freedom/base-wheel.zip deleted file mode 100644 index 22e09767..00000000 Binary files a/examples/toga/freedom/base-wheel.zip and /dev/null differ diff --git a/examples/toga/freedom/fake-briefcase.sh b/examples/toga/freedom/fake-briefcase.sh deleted file mode 100755 index df64f988..00000000 --- a/examples/toga/freedom/fake-briefcase.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -mkdir -p ../static/wheels -cd src -unzip ../base-wheel.zip -zip ../../static/wheels/freedom-0.0.1-py3-none-any.whl -r freedom* -rm -rf freedom-0.0.1.dist-info diff --git a/examples/toga/freedom/pyproject.toml b/examples/toga/freedom/pyproject.toml index ba1e5b86..e07dfd62 100644 --- a/examples/toga/freedom/pyproject.toml +++ b/examples/toga/freedom/pyproject.toml @@ -7,42 +7,66 @@ bundle = "org.beeware" version = "0.0.1" url = "https://beeware.org" license = "BSD license" -author = 'Tiberius Yak' +author = "Tiberius Yak" author_email = "tiberius@beeware.org" [tool.briefcase.app.freedom] formal_name = "Freedom Units" description = "A testing app" -sources = ['src/freedom'] +sources = ["src/freedom"] requires = [ - '../static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl', ] - [tool.briefcase.app.freedom.macOS] requires = [ - 'git+https://github.com/beeware/toga.git#egg=toga-cocoa&subdirectory=src/cocoa', - 'std-nslog>=1.0.0', + "toga-cocoa~=0.3.0", + "std-nslog>=1.0.0", ] [tool.briefcase.app.freedom.linux] requires = [ - 'git+https://github.com/beeware/toga.git#egg=toga-gtk&subdirectory=src/gtk', + "toga-gtk~=0.3.0", ] +[tool.briefcase.app.freedom.linux.appimage] +system_requires = [ + "gir1.2-webkit2-4.0", + "libcairo2-dev", + "libgirepository1.0-dev", + "libgtk-3-dev", + "libpango1.0-dev", + "librsvg2-dev", + "libwebkit2gtk-4.0-dev", +] +linuxdeploy_plugins = [ + "DEPLOY_GTK_VERSION=3 gtk", +] + +[tool.briefcase.app.freedom.linux.flatpak] +flatpak_runtime = "org.gnome.Platform" +flatpak_runtime_version = "42" +flatpak_sdk = "org.gnome.Sdk" + [tool.briefcase.app.freedom.windows] requires = [ - 'git+https://github.com/beeware/toga.git#egg=toga-winforms&subdirectory=src/winforms', + "toga-winforms~=0.3.0", ] # Mobile deployments [tool.briefcase.app.freedom.iOS] requires = [ - 'git+https://github.com/beeware/toga.git#egg=toga-iOS&subdirectory=src/iOS', - 'std-nslog>=1.0.0', + "toga-iOS~=0.3.0", + "std-nslog>=1.0.0", ] [tool.briefcase.app.freedom.android] requires = [ - 'git+https://github.com/beeware/toga.git#egg=toga-android&subdirectory=src/android', + "toga-android~=0.3.0", ] + +# Web deployments +[tool.briefcase.app.freedom.web] +requires = [ + "toga-web~=0.3.0", +] +style_framework = "Bootstrap v4.6" diff --git a/examples/toga/freedom/src/freedom/__main__.py b/examples/toga/freedom/src/freedom/__main__.py index 243efbc5..6bd21e05 100644 --- a/examples/toga/freedom/src/freedom/__main__.py +++ b/examples/toga/freedom/src/freedom/__main__.py @@ -1,6 +1,4 @@ from freedom.app import main -print("IN FREEDOM", main) - if __name__ == "__main__": main().main_loop() diff --git a/examples/toga/static/css/briefcase.css b/examples/toga/static/css/briefcase.css new file mode 100644 index 00000000..8f308b43 --- /dev/null +++ b/examples/toga/static/css/briefcase.css @@ -0,0 +1,37 @@ + +/* Unset the overly generic pyscript .label style */ +#app-placeholder .label { + margin-top: inherit; + color: inherit; + text-align: inherit; + width: inherit; + display: inherit; + color: inherit; + font-size: inherit; + margin-top: inherit; + +} + +/******************************************************************* + * WARNING: Do not remove or modify this comment block, or add any + * content below this block. Briefcase will add content here during + * the build step. + ******************* Wheel contributed styles **********************/ + +/******************************************************* + * toga_web 0.3.0::toga.css + *******************************************************/ + +main.toga.window { + margin-top: 5em; + display: flex; + flex-direction: column; +} + +div.toga.box { + display: flex; +} + +span.toga.label { + white-space: nowrap; +} diff --git a/examples/toga/static/logo-32.png b/examples/toga/static/logo-32.png index eae2a2e7..d4ee3c9b 100644 Binary files a/examples/toga/static/logo-32.png and b/examples/toga/static/logo-32.png differ diff --git a/examples/toga/static/toga.css b/examples/toga/static/toga.css deleted file mode 100644 index cdea8be3..00000000 --- a/examples/toga/static/toga.css +++ /dev/null @@ -1,9 +0,0 @@ -main.toga.window { - margin-top: 5em; - display: flex; - flex-direction: column; -} - -div.toga.box { - display: flex; -} diff --git a/examples/toga/static/wheels/README.md b/examples/toga/static/wheels/README.md deleted file mode 100644 index c597914e..00000000 --- a/examples/toga/static/wheels/README.md +++ /dev/null @@ -1 +0,0 @@ -Wheels will go here. diff --git a/examples/toga/static/wheels/freedom-0.0.1-py3-none-any.whl b/examples/toga/static/wheels/freedom-0.0.1-py3-none-any.whl index 51443667..7e7ad913 100644 Binary files a/examples/toga/static/wheels/freedom-0.0.1-py3-none-any.whl and b/examples/toga/static/wheels/freedom-0.0.1-py3-none-any.whl differ diff --git a/examples/toga/static/wheels/toga_core-0.3.0.dev39-py3-none-any.whl b/examples/toga/static/wheels/toga_core-0.3.0.dev39-py3-none-any.whl deleted file mode 100644 index 5d64a3ab..00000000 Binary files a/examples/toga/static/wheels/toga_core-0.3.0.dev39-py3-none-any.whl and /dev/null differ diff --git a/examples/toga/static/wheels/toga_flask-0.3.0.dev33-py3-none-any.whl b/examples/toga/static/wheels/toga_flask-0.3.0.dev33-py3-none-any.whl deleted file mode 100644 index eba5bb5b..00000000 Binary files a/examples/toga/static/wheels/toga_flask-0.3.0.dev33-py3-none-any.whl and /dev/null differ diff --git a/examples/toga/static/wheels/toga_web-0.3.0.dev39-py3-none-any.whl b/examples/toga/static/wheels/toga_web-0.3.0.dev39-py3-none-any.whl deleted file mode 100644 index 3b4d4582..00000000 Binary files a/examples/toga/static/wheels/toga_web-0.3.0.dev39-py3-none-any.whl and /dev/null differ diff --git a/examples/toga/static/wheels/travertino-0.1.3-py3-none-any.whl b/examples/toga/static/wheels/travertino-0.1.3-py3-none-any.whl deleted file mode 100644 index 07a73999..00000000 Binary files a/examples/toga/static/wheels/travertino-0.1.3-py3-none-any.whl and /dev/null differ