pythonnative 0.22.0__tar.gz → 0.23.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pythonnative-0.22.0/src/pythonnative.egg-info → pythonnative-0.23.0}/PKG-INFO +13 -13
- {pythonnative-0.22.0 → pythonnative-0.23.0}/README.md +11 -11
- {pythonnative-0.22.0 → pythonnative-0.23.0}/pyproject.toml +3 -4
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/__init__.py +16 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/animated.py +6 -6
- pythonnative-0.23.0/src/pythonnative/appearance.py +124 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/cli/pn.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/components.py +718 -48
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/events.py +5 -5
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/gestures.py +3 -3
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/hooks.py +44 -3
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/hot_reload.py +4 -4
- pythonnative-0.23.0/src/pythonnative/images.py +196 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/layout.py +3 -3
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/mutations.py +4 -13
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/camera.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/haptics.py +2 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/location.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/permissions.py +2 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/secure_store.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_views/__init__.py +1 -7
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_views/android.py +592 -64
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_views/base.py +3 -3
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_views/desktop.py +85 -26
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_views/ios.py +762 -74
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/navigation.py +4 -4
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/net.py +3 -3
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/platform.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/platform_metrics.py +5 -5
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/preview.py +34 -3
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/builder.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/config.py +4 -12
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/doctor.py +2 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/icons.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/ios.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/permissions.py +2 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/runtime_assets.py +3 -3
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/reconciler.py +9 -9
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/runtime.py +8 -8
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/screen.py +90 -5
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/sdk/_components.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/storage.py +3 -3
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/style.py +66 -7
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/AndroidManifest.xml +2 -1
- pythonnative-0.23.0/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PNAccessibilityDelegate.kt +47 -0
- pythonnative-0.23.0/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PNBorderDrawable.kt +67 -0
- pythonnative-0.23.0/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PNVirtualListView.java +172 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template.xcodeproj/project.pbxproj +2 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITests.swift +1 -1
- pythonnative-0.23.0/src/pythonnative/virtual_rows.py +137 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0/src/pythonnative.egg-info}/PKG-INFO +13 -13
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative.egg-info/SOURCES.txt +9 -0
- pythonnative-0.23.0/tests/test_appearance.py +181 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_components.py +131 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_desktop_backend.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_events.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_hot_reload.py +2 -2
- pythonnative-0.23.0/tests/test_images.py +145 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_ios_log.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_layout.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_metric_hooks.py +49 -0
- pythonnative-0.23.0/tests/test_native_lists.py +292 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_native_views.py +3 -8
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_new_components.py +42 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_ref.py +2 -2
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_screen.py +1 -1
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_style.py +6 -4
- {pythonnative-0.22.0 → pythonnative-0.23.0}/LICENSE +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/setup.cfg +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/_ios_log.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/alerts.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/cli/__init__.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/element.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/__init__.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/app_state.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/battery.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/biometrics.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/clipboard.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/file_system.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/linking.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/net_info.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/notifications.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/native_modules/share.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/__init__.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/project/android.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/sdk/__init__.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/build.gradle +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/proguard-rules.pro +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/androidTest/java/com/pythonnative/android_template/ExampleInstrumentedTest.kt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/MainActivity.kt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/Navigator.kt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/ScreenFragment.kt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/drawable/ic_launcher_background.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/layout/activity_main.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/navigation/nav_graph.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/values/colors.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/values/strings.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/values/themes.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/values-night/themes.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/xml/backup_rules.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/main/res/xml/data_extraction_rules.xml +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/app/src/test/java/com/pythonnative/android_template/ExampleUnitTest.kt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/build.gradle +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.jar +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.properties +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/gradle.properties +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/gradlew +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/gradlew.bat +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/android_template/settings.gradle +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/AppDelegate.swift +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/AccentColor.colorset/Contents.json +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/Contents.json +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/Base.lproj/LaunchScreen.storyboard +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/Base.lproj/Main.storyboard +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/Info.plist +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/SceneDelegate.swift +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template/ViewController.swift +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_template.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_templateTests/ios_templateTests.swift +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITestsLaunchTests.swift +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative/utils.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative.egg-info/dependency_links.txt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative.egg-info/entry_points.txt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative.egg-info/requires.txt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/src/pythonnative.egg-info/top_level.txt +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_alert.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_animated.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_async_hooks.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_cli.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_element.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_extended_components.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_gestures.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_hooks.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_incremental_render.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_mutations.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_native_modules.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_navigation.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_net.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_platform.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_platform_metrics.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_reconciler.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_runtime.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_sdk.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_smoke.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_storage.py +0 -0
- {pythonnative-0.22.0 → pythonnative-0.23.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pythonnative
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
4
4
|
Summary: Cross-platform native UI toolkit for Android and iOS
|
|
5
5
|
Author: Owen Carey
|
|
6
6
|
License: MIT License
|
|
@@ -28,7 +28,7 @@ License: MIT License
|
|
|
28
28
|
Project-URL: Homepage, https://github.com/pythonnative/pythonnative
|
|
29
29
|
Project-URL: Repository, https://github.com/pythonnative/pythonnative
|
|
30
30
|
Project-URL: Issues, https://github.com/pythonnative/pythonnative/issues
|
|
31
|
-
Project-URL: Documentation, https://
|
|
31
|
+
Project-URL: Documentation, https://pythonnative.com/
|
|
32
32
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
33
33
|
Classifier: Intended Audience :: Developers
|
|
34
34
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -83,13 +83,13 @@ Dynamic: license-file
|
|
|
83
83
|
<a href="https://pypi.org/project/pythonnative/"><img src="https://img.shields.io/pypi/v/pythonnative" alt="PyPI Version" /></a>
|
|
84
84
|
<a href="https://pypi.org/project/pythonnative/"><img src="https://img.shields.io/pypi/pyversions/pythonnative" alt="Python Versions" /></a>
|
|
85
85
|
<a href="LICENSE"><img src="https://img.shields.io/pypi/l/pythonnative" alt="License: MIT" /></a>
|
|
86
|
-
<a href="https://
|
|
86
|
+
<a href="https://pythonnative.com/"><img src="https://img.shields.io/website?url=https%3A%2F%2Fpythonnative.com&label=docs" alt="Docs" /></a>
|
|
87
87
|
</p>
|
|
88
88
|
|
|
89
89
|
<p align="center">
|
|
90
|
-
<a href="https://
|
|
91
|
-
<a href="https://
|
|
92
|
-
<a href="https://
|
|
90
|
+
<a href="https://pythonnative.com/">Documentation</a> ·
|
|
91
|
+
<a href="https://pythonnative.com/getting-started/">Getting Started</a> ·
|
|
92
|
+
<a href="https://pythonnative.com/examples/">Examples</a> ·
|
|
93
93
|
<a href="CONTRIBUTING.md">Contributing</a>
|
|
94
94
|
</p>
|
|
95
95
|
|
|
@@ -102,19 +102,19 @@ PythonNative is a cross-platform toolkit for building native Android and iOS app
|
|
|
102
102
|
## Features
|
|
103
103
|
|
|
104
104
|
- **Declarative UI:** Describe *what* your UI should look like with element functions (`Text`, `Button`, `Column`, `Row`, etc.). PythonNative creates and updates native views automatically.
|
|
105
|
-
- **Rich component library:** 25+ built-in components backed by real native widgets
|
|
106
|
-
- **Device APIs:** Cross-platform modules for `Camera`, `Location`, `FileSystem`, `Notifications`, `Clipboard`, `Share`, `Linking`, `Permissions`, `AppState`, `NetInfo`, `SecureStore`, `Battery`, `Haptics` / `Vibration`, and `Biometrics
|
|
105
|
+
- **Rich component library:** 25+ built-in components backed by real native widgets: `TextInput`, `Image` / `ImageBackground`, `ScrollView`, `FlatList` / `SectionList`, `Modal`, `Pressable` / `TouchableOpacity`, `Switch` / `Checkbox`, `Slider`, `SegmentedControl`, `Picker`, `DatePicker`, `ProgressBar` / `ActivityIndicator`, `WebView`, and more.
|
|
106
|
+
- **Device APIs:** Cross-platform modules for `Camera`, `Location`, `FileSystem`, `Notifications`, `Clipboard`, `Share`, `Linking`, `Permissions`, `AppState`, `NetInfo`, `SecureStore`, `Battery`, `Haptics` / `Vibration`, and `Biometrics`, plus reactive `use_app_state` and `use_net_info` hooks.
|
|
107
107
|
- **Hooks and function components:** Manage state with `use_state`, side effects with `use_effect`, and navigation with `use_navigation`, all through one consistent pattern.
|
|
108
108
|
- **Typed `style` prop:** Pass all visual and layout properties through a single `style` dict, fully described by the `pn.Style` `TypedDict` and the ergonomic `pn.style(...)` helper for IDE autocomplete and static checking. Compose reusable styles with `StyleSheet`.
|
|
109
109
|
- **Cross-platform flexbox engine:** A pure-Python, Yoga-style layout engine computes frames once and applies them to native views, so `flex`, `padding`, `aspect_ratio`, and `position: "absolute"` produce the same geometry on Android and iOS.
|
|
110
|
-
- **Virtual view tree + reconciler:** Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation. Each commit lands as **one batched transaction** of mutation ops, and event callbacks are routed through a tag-based registry so re-renders that only change closures cost zero native calls. State updates re-render **locally
|
|
110
|
+
- **Virtual view tree + reconciler:** Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation. Each commit lands as **one batched transaction** of mutation ops, and event callbacks are routed through a tag-based registry so re-renders that only change closures cost zero native calls. State updates re-render **locally**: only the component whose state changed (and its subtree) re-runs, and unchanged leaves reuse cached intrinsic measurements, so deep UIs stay responsive instead of re-rendering the whole app from the root on every tap.
|
|
111
111
|
- **Native-driven animations:** The `Animated` API (timing / spring / decay, awaitable or fire-and-forget) hands animations to Core Animation and `ViewPropertyAnimator` whenever possible, so no Python code runs per frame; a pure-Python ticker covers the rest.
|
|
112
|
-
- **Native gesture system:** Attach `Tap`, `LongPress`, `Pan`, `Swipe`, `Pinch`, and `Rotation` recognizers to any view via the `gestures=` prop
|
|
113
|
-
- **Virtualized lists:** `FlatList` / `SectionList` window their rows in Python over the platform scroll view
|
|
112
|
+
- **Native gesture system:** Attach `Tap`, `LongPress`, `Pan`, `Swipe`, `Pinch`, and `Rotation` recognizers to any view via the `gestures=` prop, backed by `UIGestureRecognizer` on iOS and a unit-testable pure-Python arbiter on Android and desktop.
|
|
113
|
+
- **Virtualized lists:** `FlatList` / `SectionList` window their rows in Python over the platform scroll view: uniform, exact, or measured variable heights, grids, headers/footers, infinite scroll, and an imperative scroll controller, identical on every platform.
|
|
114
114
|
- **Direct native bindings:** Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
|
|
115
115
|
- **Custom-component SDK:** Wrap any platform widget as a first-class element with type-checked props via `pythonnative.sdk` (`Props`, `@native_component`, `element_factory`). Plugins distributed on PyPI auto-register through the `pythonnative.handlers` entry-point group.
|
|
116
116
|
- **CLI scaffolding:** `pn init` creates a ready-to-run project; `pn run android` and `pn run ios` build and launch your app.
|
|
117
|
-
- **Instant desktop preview:** `pn preview` renders your app in a native desktop window via Tkinter with Fast Refresh on every save
|
|
117
|
+
- **Instant desktop preview:** `pn preview` renders your app in a native desktop window via Tkinter with Fast Refresh on every save: iterate on layout, state, and navigation in milliseconds without booting a simulator or device. The reconciler, hooks, layout engine, and navigation are the same code that ships to the phone.
|
|
118
118
|
- **Native-backed navigation:** Declarative `Stack`, `Tab`, and `Drawer` navigators inspired by React Navigation. The root stack drives the platform's native navigation controller (`UINavigationController` on iOS, AndroidX Navigation Component on Android), so transitions, back gestures, and the hardware back button match what users expect.
|
|
119
119
|
- **Fast Refresh hot reload:** `pn run --hot-reload` watches `app/` and patches edits into the running app on save, preserving component state across most changes.
|
|
120
120
|
- **Bundled templates:** Android Gradle and iOS Xcode templates are included, so scaffolding requires no network access.
|
|
@@ -148,7 +148,7 @@ def App():
|
|
|
148
148
|
|
|
149
149
|
## Documentation
|
|
150
150
|
|
|
151
|
-
Visit [
|
|
151
|
+
Visit [pythonnative.com](https://pythonnative.com/) for the full documentation, including getting started guides, platform-specific instructions for Android and iOS, API reference, and working examples.
|
|
152
152
|
|
|
153
153
|
## Contributing
|
|
154
154
|
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
<a href="https://pypi.org/project/pythonnative/"><img src="https://img.shields.io/pypi/v/pythonnative" alt="PyPI Version" /></a>
|
|
13
13
|
<a href="https://pypi.org/project/pythonnative/"><img src="https://img.shields.io/pypi/pyversions/pythonnative" alt="Python Versions" /></a>
|
|
14
14
|
<a href="LICENSE"><img src="https://img.shields.io/pypi/l/pythonnative" alt="License: MIT" /></a>
|
|
15
|
-
<a href="https://
|
|
15
|
+
<a href="https://pythonnative.com/"><img src="https://img.shields.io/website?url=https%3A%2F%2Fpythonnative.com&label=docs" alt="Docs" /></a>
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
18
|
<p align="center">
|
|
19
|
-
<a href="https://
|
|
20
|
-
<a href="https://
|
|
21
|
-
<a href="https://
|
|
19
|
+
<a href="https://pythonnative.com/">Documentation</a> ·
|
|
20
|
+
<a href="https://pythonnative.com/getting-started/">Getting Started</a> ·
|
|
21
|
+
<a href="https://pythonnative.com/examples/">Examples</a> ·
|
|
22
22
|
<a href="CONTRIBUTING.md">Contributing</a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
@@ -31,19 +31,19 @@ PythonNative is a cross-platform toolkit for building native Android and iOS app
|
|
|
31
31
|
## Features
|
|
32
32
|
|
|
33
33
|
- **Declarative UI:** Describe *what* your UI should look like with element functions (`Text`, `Button`, `Column`, `Row`, etc.). PythonNative creates and updates native views automatically.
|
|
34
|
-
- **Rich component library:** 25+ built-in components backed by real native widgets
|
|
35
|
-
- **Device APIs:** Cross-platform modules for `Camera`, `Location`, `FileSystem`, `Notifications`, `Clipboard`, `Share`, `Linking`, `Permissions`, `AppState`, `NetInfo`, `SecureStore`, `Battery`, `Haptics` / `Vibration`, and `Biometrics
|
|
34
|
+
- **Rich component library:** 25+ built-in components backed by real native widgets: `TextInput`, `Image` / `ImageBackground`, `ScrollView`, `FlatList` / `SectionList`, `Modal`, `Pressable` / `TouchableOpacity`, `Switch` / `Checkbox`, `Slider`, `SegmentedControl`, `Picker`, `DatePicker`, `ProgressBar` / `ActivityIndicator`, `WebView`, and more.
|
|
35
|
+
- **Device APIs:** Cross-platform modules for `Camera`, `Location`, `FileSystem`, `Notifications`, `Clipboard`, `Share`, `Linking`, `Permissions`, `AppState`, `NetInfo`, `SecureStore`, `Battery`, `Haptics` / `Vibration`, and `Biometrics`, plus reactive `use_app_state` and `use_net_info` hooks.
|
|
36
36
|
- **Hooks and function components:** Manage state with `use_state`, side effects with `use_effect`, and navigation with `use_navigation`, all through one consistent pattern.
|
|
37
37
|
- **Typed `style` prop:** Pass all visual and layout properties through a single `style` dict, fully described by the `pn.Style` `TypedDict` and the ergonomic `pn.style(...)` helper for IDE autocomplete and static checking. Compose reusable styles with `StyleSheet`.
|
|
38
38
|
- **Cross-platform flexbox engine:** A pure-Python, Yoga-style layout engine computes frames once and applies them to native views, so `flex`, `padding`, `aspect_ratio`, and `position: "absolute"` produce the same geometry on Android and iOS.
|
|
39
|
-
- **Virtual view tree + reconciler:** Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation. Each commit lands as **one batched transaction** of mutation ops, and event callbacks are routed through a tag-based registry so re-renders that only change closures cost zero native calls. State updates re-render **locally
|
|
39
|
+
- **Virtual view tree + reconciler:** Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation. Each commit lands as **one batched transaction** of mutation ops, and event callbacks are routed through a tag-based registry so re-renders that only change closures cost zero native calls. State updates re-render **locally**: only the component whose state changed (and its subtree) re-runs, and unchanged leaves reuse cached intrinsic measurements, so deep UIs stay responsive instead of re-rendering the whole app from the root on every tap.
|
|
40
40
|
- **Native-driven animations:** The `Animated` API (timing / spring / decay, awaitable or fire-and-forget) hands animations to Core Animation and `ViewPropertyAnimator` whenever possible, so no Python code runs per frame; a pure-Python ticker covers the rest.
|
|
41
|
-
- **Native gesture system:** Attach `Tap`, `LongPress`, `Pan`, `Swipe`, `Pinch`, and `Rotation` recognizers to any view via the `gestures=` prop
|
|
42
|
-
- **Virtualized lists:** `FlatList` / `SectionList` window their rows in Python over the platform scroll view
|
|
41
|
+
- **Native gesture system:** Attach `Tap`, `LongPress`, `Pan`, `Swipe`, `Pinch`, and `Rotation` recognizers to any view via the `gestures=` prop, backed by `UIGestureRecognizer` on iOS and a unit-testable pure-Python arbiter on Android and desktop.
|
|
42
|
+
- **Virtualized lists:** `FlatList` / `SectionList` window their rows in Python over the platform scroll view: uniform, exact, or measured variable heights, grids, headers/footers, infinite scroll, and an imperative scroll controller, identical on every platform.
|
|
43
43
|
- **Direct native bindings:** Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
|
|
44
44
|
- **Custom-component SDK:** Wrap any platform widget as a first-class element with type-checked props via `pythonnative.sdk` (`Props`, `@native_component`, `element_factory`). Plugins distributed on PyPI auto-register through the `pythonnative.handlers` entry-point group.
|
|
45
45
|
- **CLI scaffolding:** `pn init` creates a ready-to-run project; `pn run android` and `pn run ios` build and launch your app.
|
|
46
|
-
- **Instant desktop preview:** `pn preview` renders your app in a native desktop window via Tkinter with Fast Refresh on every save
|
|
46
|
+
- **Instant desktop preview:** `pn preview` renders your app in a native desktop window via Tkinter with Fast Refresh on every save: iterate on layout, state, and navigation in milliseconds without booting a simulator or device. The reconciler, hooks, layout engine, and navigation are the same code that ships to the phone.
|
|
47
47
|
- **Native-backed navigation:** Declarative `Stack`, `Tab`, and `Drawer` navigators inspired by React Navigation. The root stack drives the platform's native navigation controller (`UINavigationController` on iOS, AndroidX Navigation Component on Android), so transitions, back gestures, and the hardware back button match what users expect.
|
|
48
48
|
- **Fast Refresh hot reload:** `pn run --hot-reload` watches `app/` and patches edits into the running app on save, preserving component state across most changes.
|
|
49
49
|
- **Bundled templates:** Android Gradle and iOS Xcode templates are included, so scaffolding requires no network access.
|
|
@@ -77,7 +77,7 @@ def App():
|
|
|
77
77
|
|
|
78
78
|
## Documentation
|
|
79
79
|
|
|
80
|
-
Visit [
|
|
80
|
+
Visit [pythonnative.com](https://pythonnative.com/) for the full documentation, including getting started guides, platform-specific instructions for Android and iOS, API reference, and working examples.
|
|
81
81
|
|
|
82
82
|
## Contributing
|
|
83
83
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pythonnative"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.23.0"
|
|
8
8
|
description = "Cross-platform native UI toolkit for Android and iOS"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Owen Carey" }
|
|
@@ -66,7 +66,8 @@ pn = "pythonnative.cli.pn:main"
|
|
|
66
66
|
Homepage = "https://github.com/pythonnative/pythonnative"
|
|
67
67
|
Repository = "https://github.com/pythonnative/pythonnative"
|
|
68
68
|
Issues = "https://github.com/pythonnative/pythonnative/issues"
|
|
69
|
-
Documentation = "https://
|
|
69
|
+
Documentation = "https://pythonnative.com/"
|
|
70
|
+
|
|
70
71
|
|
|
71
72
|
|
|
72
73
|
|
|
@@ -97,8 +98,6 @@ pythonnative = [
|
|
|
97
98
|
target-version = "py39"
|
|
98
99
|
line-length = 120
|
|
99
100
|
extend-exclude = [
|
|
100
|
-
"experiments",
|
|
101
|
-
"apps",
|
|
102
101
|
"templates",
|
|
103
102
|
"docs",
|
|
104
103
|
]
|
|
@@ -60,9 +60,9 @@ Example:
|
|
|
60
60
|
```
|
|
61
61
|
"""
|
|
62
62
|
|
|
63
|
-
__version__ = "0.
|
|
63
|
+
__version__ = "0.23.0"
|
|
64
64
|
|
|
65
|
-
from . import gestures, runtime, sdk
|
|
65
|
+
from . import appearance, gestures, images, runtime, sdk
|
|
66
66
|
from .alerts import Alert
|
|
67
67
|
from .animated import Animated, AnimatedValue, use_animated_value
|
|
68
68
|
from .components import (
|
|
@@ -132,6 +132,7 @@ from .hooks import (
|
|
|
132
132
|
memo,
|
|
133
133
|
use_async_effect,
|
|
134
134
|
use_callback,
|
|
135
|
+
use_color_scheme,
|
|
135
136
|
use_context,
|
|
136
137
|
use_effect,
|
|
137
138
|
use_keyboard_height,
|
|
@@ -185,6 +186,8 @@ from .sdk import (
|
|
|
185
186
|
)
|
|
186
187
|
from .storage import AsyncStorage, use_persisted_state
|
|
187
188
|
from .style import (
|
|
189
|
+
DEFAULT_DARK_THEME,
|
|
190
|
+
DEFAULT_LIGHT_THEME,
|
|
188
191
|
AlignItems,
|
|
189
192
|
AlignSelf,
|
|
190
193
|
AutoCapitalize,
|
|
@@ -207,8 +210,10 @@ from .style import (
|
|
|
207
210
|
TextDecoration,
|
|
208
211
|
ThemeContext,
|
|
209
212
|
TransformSpec,
|
|
213
|
+
default_theme,
|
|
210
214
|
resolve_style,
|
|
211
215
|
style,
|
|
216
|
+
use_theme,
|
|
212
217
|
)
|
|
213
218
|
|
|
214
219
|
__all__ = [
|
|
@@ -280,6 +285,7 @@ __all__ = [
|
|
|
280
285
|
"QueryResult",
|
|
281
286
|
"use_async_effect",
|
|
282
287
|
"use_callback",
|
|
288
|
+
"use_color_scheme",
|
|
283
289
|
"use_context",
|
|
284
290
|
"use_effect",
|
|
285
291
|
"use_focus_effect",
|
|
@@ -306,6 +312,8 @@ __all__ = [
|
|
|
306
312
|
"AlignSelf",
|
|
307
313
|
"AutoCapitalize",
|
|
308
314
|
"Color",
|
|
315
|
+
"DEFAULT_DARK_THEME",
|
|
316
|
+
"DEFAULT_LIGHT_THEME",
|
|
309
317
|
"Dimension",
|
|
310
318
|
"EdgeInsets",
|
|
311
319
|
"FlexDirection",
|
|
@@ -324,8 +332,14 @@ __all__ = [
|
|
|
324
332
|
"TextDecoration",
|
|
325
333
|
"ThemeContext",
|
|
326
334
|
"TransformSpec",
|
|
335
|
+
"default_theme",
|
|
327
336
|
"resolve_style",
|
|
328
337
|
"style",
|
|
338
|
+
"use_theme",
|
|
339
|
+
# Appearance
|
|
340
|
+
"appearance",
|
|
341
|
+
# Image pipeline
|
|
342
|
+
"images",
|
|
329
343
|
# Animation
|
|
330
344
|
"Animated",
|
|
331
345
|
"AnimatedValue",
|
|
@@ -24,7 +24,7 @@ native view the value is attached to
|
|
|
24
24
|
|
|
25
25
|
- **Accepted** (iOS Core Animation, Android ``ViewPropertyAnimator`` /
|
|
26
26
|
``DynamicAnimation``): the platform animates the property entirely
|
|
27
|
-
natively
|
|
27
|
+
natively; no Python code runs per frame. Python receives exactly one
|
|
28
28
|
callback when the animation settles, updates the
|
|
29
29
|
[`AnimatedValue`][pythonnative.animated.AnimatedValue], and resolves
|
|
30
30
|
any awaiting tasks.
|
|
@@ -135,7 +135,7 @@ class AnimatedValue:
|
|
|
135
135
|
Animated components (``Animated.View`` et al.) **attach** the value
|
|
136
136
|
to ``(tag, prop)`` bindings after mount. Setting the value pushes
|
|
137
137
|
the new number to every attached native view through the registry's
|
|
138
|
-
``set_animated_property
|
|
138
|
+
``set_animated_property``, and when an animation can be driven
|
|
139
139
|
natively, the platform animates those same bindings directly.
|
|
140
140
|
|
|
141
141
|
Python-side listeners registered via
|
|
@@ -217,7 +217,7 @@ class AnimatedValue:
|
|
|
217
217
|
def add_listener(self, prop: str, callback: Callable[[float], None]) -> Callable[[], None]:
|
|
218
218
|
"""Register ``callback`` for Python-driven changes to this value.
|
|
219
219
|
|
|
220
|
-
Returns an unsubscribe callable. ``prop`` is metadata only
|
|
220
|
+
Returns an unsubscribe callable. ``prop`` is metadata only; it
|
|
221
221
|
lets the subscriber differentiate this binding from others on
|
|
222
222
|
the same ``AnimatedValue``.
|
|
223
223
|
"""
|
|
@@ -686,7 +686,7 @@ class _AnimationHandle(_AwaitableAnimation):
|
|
|
686
686
|
|
|
687
687
|
Each ``.start()`` call snapshots the value's current state, prefers
|
|
688
688
|
the native driver, and falls back to a fresh Python-ticked
|
|
689
|
-
animation otherwise (matches React Native
|
|
689
|
+
animation otherwise (matches React Native: the ``Animated.timing``
|
|
690
690
|
return value is reusable).
|
|
691
691
|
"""
|
|
692
692
|
|
|
@@ -780,7 +780,7 @@ class _CompositeAnimation(_AwaitableAnimation):
|
|
|
780
780
|
if item is None:
|
|
781
781
|
return
|
|
782
782
|
# ``_AwaitableAnimation`` and plain awaitables/coroutines are
|
|
783
|
-
# both supported
|
|
783
|
+
# both supported: lets users mix in ``asyncio.sleep``.
|
|
784
784
|
await item
|
|
785
785
|
|
|
786
786
|
|
|
@@ -824,7 +824,7 @@ def _make_animated_factory(
|
|
|
824
824
|
|
|
825
825
|
# ``@component`` packs positional children into the ``children``
|
|
826
826
|
# prop (this function declares ``*args``), and the reconciler
|
|
827
|
-
# re-invokes it with keyword props only
|
|
827
|
+
# re-invokes it with keyword props only, so at render time the
|
|
828
828
|
# payload arrives in ``kwargs``, never in ``args``.
|
|
829
829
|
children = list(args) or list(kwargs.pop("children", ()) or ())
|
|
830
830
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""System color-scheme (light / dark mode) tracking.
|
|
2
|
+
|
|
3
|
+
The platform screen host publishes the operating system's current
|
|
4
|
+
appearance here (Android: ``Configuration.uiMode``; iOS:
|
|
5
|
+
``UITraitCollection.userInterfaceStyle``), and components read it back
|
|
6
|
+
through [`use_color_scheme`][pythonnative.use_color_scheme] or
|
|
7
|
+
[`use_theme`][pythonnative.use_theme], both of which re-render when
|
|
8
|
+
the scheme changes.
|
|
9
|
+
|
|
10
|
+
Apps can also *override* the scheme (e.g. an in-app appearance
|
|
11
|
+
setting) with [`set_color_scheme`][pythonnative.appearance.set_color_scheme];
|
|
12
|
+
the override wins over the system value until cleared with ``None``.
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
>>> from pythonnative import appearance
|
|
16
|
+
>>> appearance.get_color_scheme()
|
|
17
|
+
'light'
|
|
18
|
+
>>> appearance.set_color_scheme("dark") # app-level override
|
|
19
|
+
>>> appearance.get_color_scheme()
|
|
20
|
+
'dark'
|
|
21
|
+
>>> appearance.set_color_scheme(None) # follow the system again
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
import threading
|
|
27
|
+
from typing import Callable, List, Literal, Optional
|
|
28
|
+
|
|
29
|
+
ColorScheme = Literal["light", "dark"]
|
|
30
|
+
"""The two supported appearance values."""
|
|
31
|
+
|
|
32
|
+
_system_scheme: str = "light"
|
|
33
|
+
_override_scheme: Optional[str] = None
|
|
34
|
+
|
|
35
|
+
_subscribers: List[Callable[[], None]] = []
|
|
36
|
+
_subscribers_lock = threading.Lock()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _notify_subscribers() -> None:
|
|
40
|
+
"""Invoke every registered subscriber, swallowing exceptions."""
|
|
41
|
+
with _subscribers_lock:
|
|
42
|
+
callbacks = list(_subscribers)
|
|
43
|
+
for cb in callbacks:
|
|
44
|
+
try:
|
|
45
|
+
cb()
|
|
46
|
+
except Exception:
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def subscribe(callback: Callable[[], None]) -> Callable[[], None]:
|
|
51
|
+
"""Register ``callback`` to fire whenever the effective scheme changes.
|
|
52
|
+
|
|
53
|
+
Returns an unsubscribe function. Threadsafe.
|
|
54
|
+
"""
|
|
55
|
+
with _subscribers_lock:
|
|
56
|
+
_subscribers.append(callback)
|
|
57
|
+
|
|
58
|
+
def _unsub() -> None:
|
|
59
|
+
with _subscribers_lock:
|
|
60
|
+
try:
|
|
61
|
+
_subscribers.remove(callback)
|
|
62
|
+
except ValueError:
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
return _unsub
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _coerce(scheme: object) -> Optional[str]:
|
|
69
|
+
if scheme in ("light", "dark"):
|
|
70
|
+
return str(scheme)
|
|
71
|
+
return None
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def set_system_color_scheme(scheme: str) -> None:
|
|
75
|
+
"""Publish the operating system's current scheme.
|
|
76
|
+
|
|
77
|
+
Called by the platform screen host on create/resume and whenever
|
|
78
|
+
the system reports an appearance change. Invalid values are
|
|
79
|
+
ignored. Subscribers are only notified when the *effective* scheme
|
|
80
|
+
(after any app override) actually changes.
|
|
81
|
+
"""
|
|
82
|
+
global _system_scheme
|
|
83
|
+
coerced = _coerce(scheme)
|
|
84
|
+
if coerced is None or coerced == _system_scheme:
|
|
85
|
+
return
|
|
86
|
+
effective_before = get_color_scheme()
|
|
87
|
+
_system_scheme = coerced
|
|
88
|
+
if get_color_scheme() != effective_before:
|
|
89
|
+
_notify_subscribers()
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def set_color_scheme(scheme: Optional[str]) -> None:
|
|
93
|
+
"""Set (or clear) the app-level scheme override.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
scheme: ``"light"`` or ``"dark"`` to force that appearance
|
|
97
|
+
regardless of the system setting, or ``None`` to follow
|
|
98
|
+
the system again.
|
|
99
|
+
"""
|
|
100
|
+
global _override_scheme
|
|
101
|
+
coerced = _coerce(scheme) if scheme is not None else None
|
|
102
|
+
if scheme is not None and coerced is None:
|
|
103
|
+
return
|
|
104
|
+
effective_before = get_color_scheme()
|
|
105
|
+
_override_scheme = coerced
|
|
106
|
+
if get_color_scheme() != effective_before:
|
|
107
|
+
_notify_subscribers()
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def get_color_scheme() -> str:
|
|
111
|
+
"""Return the effective scheme: the app override if set, else the system value."""
|
|
112
|
+
return _override_scheme if _override_scheme is not None else _system_scheme
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def get_system_color_scheme() -> str:
|
|
116
|
+
"""Return the system-reported scheme, ignoring any app override."""
|
|
117
|
+
return _system_scheme
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def reset_color_scheme() -> None:
|
|
121
|
+
"""Reset to system ``"light"`` with no override. Intended for tests."""
|
|
122
|
+
global _system_scheme, _override_scheme
|
|
123
|
+
_system_scheme = "light"
|
|
124
|
+
_override_scheme = None
|
|
@@ -5,7 +5,7 @@ The console script `pn` (declared in `pyproject.toml`) dispatches to:
|
|
|
5
5
|
- `pn init [name]`: scaffold a new project (``pythonnative.toml`` + ``app/``).
|
|
6
6
|
- `pn doctor [platform]`: diagnose the local toolchain and config.
|
|
7
7
|
- `pn preview [component]`: render the app in a desktop (Tkinter) window
|
|
8
|
-
with Fast Refresh
|
|
8
|
+
with Fast Refresh, the fast inner dev loop, no device required.
|
|
9
9
|
- `pn run android|ios`: stage + build + install + launch on a device or
|
|
10
10
|
simulator, with optional on-device hot reload.
|
|
11
11
|
- `pn build android|ios`: produce standalone artifacts (signed APK/AAB,
|