Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for background and session-based apps #2651

Merged
merged 21 commits into from
Jun 26, 2024
Merged
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f261f73
Allow for some branches we can't test.
freakboy3742 Jun 14, 2024
356d615
Add status icon example app, and updated API usage of document app ex…
freakboy3742 Jun 14, 2024
a4dfb92
Add API documentation for session and background apps.
freakboy3742 Jun 14, 2024
5913384
Modify core API and tests to support background and session apps.
freakboy3742 Jun 14, 2024
9b74a52
Add backend implementations for background and session apps.
freakboy3742 Jun 15, 2024
6dac1a7
Don't assign main window as app context.
freakboy3742 Jun 17, 2024
55bac77
Don't set the role on windows.
freakboy3742 Jun 17, 2024
1149058
Add testbed tests for session and background apps.
freakboy3742 Jun 17, 2024
e788574
Correct final testing and coverage issues.
freakboy3742 Jun 17, 2024
89c1ec0
Final tweaks to app API docs.
freakboy3742 Jun 17, 2024
72acfc9
Merge branch 'simple-app' into other-app-types
freakboy3742 Jun 24, 2024
635cd89
Add error handling for apps with no open windows.
freakboy3742 Jun 25, 2024
f7ca20e
Split testbed app tests into desktop and mobile modules.
freakboy3742 Jun 25, 2024
35f2dfd
Simplify description of main_window handling, and add release notes.
freakboy3742 Jun 25, 2024
b7e6e5b
Merge branch 'simple-app' into other-app-types
freakboy3742 Jun 25, 2024
767674a
Merge branch 'main' into other-app-types
mhsmith Jun 25, 2024
88dc1f6
Simplify app descriptions.
freakboy3742 Jun 25, 2024
71f78f4
More docs cleanups.
freakboy3742 Jun 25, 2024
3475249
Apply suggestions from code review
mhsmith Jun 26, 2024
5c22048
Fix whitespace
mhsmith Jun 26, 2024
08f7722
Merge branch 'main' into other-app-types
freakboy3742 Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions docs/reference/api/app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ that will be added to the main window of the app.
This approach to app construction is most useful with simple apps. For most complex
apps, you should subclass :class:`toga.App`, and provide an implementation of
:meth:`~toga.App.startup()`. This implementation *must* assign a value to
:attr:`~toga.App.main_window` for the app. The value that is assigned controls the type
of app that is created. The possible values that can be assigned to
:attr:`~toga.App.main_window` is :ref:`discussed below <assigning-main-window>`; the
most common type of app will assign an instance of :any:`toga.MainWindow`:
:attr:`~toga.App.main_window` for the app. The possible values are :ref:`discussed
below <assigning-main-window>`; most apps will assign an instance of
mhsmith marked this conversation as resolved.
Show resolved Hide resolved
:any:`toga.MainWindow`:

.. code-block:: python

Expand Down Expand Up @@ -87,16 +86,16 @@ Assigning a main window
An app *must* assign ``main_window`` as part of the startup process. However, the value
that is assigned as the main window will affect the behavior of the app.

:class:`toga.Window`
~~~~~~~~~~~~~~~~~~~~
:class:`~toga.Window`
~~~~~~~~~~~~~~~~~~~~~

The most common type of app will assign an instance of :class:`toga.Window` (or a
subclass, such as :class:`toga.MainWindow`) as the main window. This window will control
Most apps will assign an instance of :class:`toga.Window` (or a subclass,
such as :class:`toga.MainWindow`) as the main window. This window will control
the life cycle of the app. When the window assigned as the main window is closed, the
app will exit.

This is the type of app that will be created if you use an instance of :any:`toga.App`
passing in a ``startup`` argument to the constructor.
If you create an ``App`` by passing a ``startup`` argument to the constructor, a
:class:`~toga.MainWindow` will be automatically created and assigned to ``main_window``.

``None``
~~~~~~~~
Expand All @@ -106,22 +105,23 @@ are equally important (e.g., a document editor, or a web browser), you can assig
value of ``None`` to :attr:`~toga.App.main_window`. The resulting behavior is slightly
different on each platform, reflecting platform differences.

On macOS, there is only ever a single instance of an App running at any time, and the
app is allowed to continue running without any open windows. The app can open and close
windows as required; the app will keep running until explicitly exited.
On macOS, the app is allowed to continue running without having any open windows. The
app can open and close windows as required; the app will keep running until explicitly
exited.

Linux and Windows allow multiple instances of an app to run; each app instance can open
and close windows as required. When the last window being managed by an app instance is
closed, that app instance will exit.
On Linux and Windows, when an app closes the last window it is managing, the app will
automatically exit. Attempting to close the last window will trigger any app-level
:meth:`~toga.App.on_exit` handling in addition to any window-specific
:meth:`~toga.Window.on_close` handling.

Mobile, web and console platforms *must* define a main window.

:attr:`toga.App.BACKGROUND`
~~~~~~~~~~~~~~~~~~~~~~~~~~~
:attr:`~toga.App.BACKGROUND`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Assigning a value of ``toga.BACKGROUND`` as the main window will allow your app to
persist even if it doesn't have any open windows. It will also hide any app-level icon
from your taskbar.
Assigning a value of :attr:`toga.App.BACKGROUND` as the main window will allow your app
to persist even if it doesn't have any open windows. It will also hide any app-level
icon from your taskbar.

Background apps are not supported on mobile, web and console platforms.

Expand Down
Loading