pythonnative 0.3.0__tar.gz → 0.5.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.
Files changed (111) hide show
  1. {pythonnative-0.3.0 → pythonnative-0.5.0}/LICENSE +1 -1
  2. pythonnative-0.5.0/PKG-INFO +161 -0
  3. pythonnative-0.5.0/README.md +98 -0
  4. {pythonnative-0.3.0 → pythonnative-0.5.0}/pyproject.toml +28 -1
  5. pythonnative-0.5.0/src/pythonnative/__init__.py +54 -0
  6. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/cli/pn.py +16 -10
  7. pythonnative-0.5.0/src/pythonnative/components.py +241 -0
  8. pythonnative-0.5.0/src/pythonnative/element.py +47 -0
  9. pythonnative-0.5.0/src/pythonnative/native_views.py +800 -0
  10. pythonnative-0.5.0/src/pythonnative/page.py +468 -0
  11. pythonnative-0.5.0/src/pythonnative/reconciler.py +129 -0
  12. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/build.gradle +2 -2
  13. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PageFragment.kt +2 -1
  14. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/navigation/nav_graph.xml +1 -1
  15. pythonnative-0.5.0/src/pythonnative/templates/android_template/build.gradle +7 -0
  16. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.properties +1 -1
  17. pythonnative-0.5.0/src/pythonnative/utils.py +83 -0
  18. pythonnative-0.5.0/src/pythonnative.egg-info/PKG-INFO +161 -0
  19. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative.egg-info/SOURCES.txt +7 -24
  20. {pythonnative-0.3.0 → pythonnative-0.5.0}/tests/test_cli.py +4 -3
  21. pythonnative-0.5.0/tests/test_components.py +194 -0
  22. pythonnative-0.5.0/tests/test_element.py +71 -0
  23. pythonnative-0.5.0/tests/test_reconciler.py +280 -0
  24. pythonnative-0.5.0/tests/test_smoke.py +32 -0
  25. pythonnative-0.3.0/PKG-INFO +0 -137
  26. pythonnative-0.3.0/README.md +0 -74
  27. pythonnative-0.3.0/src/pythonnative/__init__.py +0 -74
  28. pythonnative-0.3.0/src/pythonnative/activity_indicator_view.py +0 -71
  29. pythonnative-0.3.0/src/pythonnative/button.py +0 -109
  30. pythonnative-0.3.0/src/pythonnative/date_picker.py +0 -72
  31. pythonnative-0.3.0/src/pythonnative/image_view.py +0 -76
  32. pythonnative-0.3.0/src/pythonnative/label.py +0 -66
  33. pythonnative-0.3.0/src/pythonnative/list_view.py +0 -73
  34. pythonnative-0.3.0/src/pythonnative/material_activity_indicator_view.py +0 -69
  35. pythonnative-0.3.0/src/pythonnative/material_button.py +0 -65
  36. pythonnative-0.3.0/src/pythonnative/material_date_picker.py +0 -85
  37. pythonnative-0.3.0/src/pythonnative/material_progress_view.py +0 -66
  38. pythonnative-0.3.0/src/pythonnative/material_search_bar.py +0 -65
  39. pythonnative-0.3.0/src/pythonnative/material_switch.py +0 -65
  40. pythonnative-0.3.0/src/pythonnative/material_time_picker.py +0 -72
  41. pythonnative-0.3.0/src/pythonnative/page.py +0 -396
  42. pythonnative-0.3.0/src/pythonnative/picker_view.py +0 -65
  43. pythonnative-0.3.0/src/pythonnative/progress_view.py +0 -68
  44. pythonnative-0.3.0/src/pythonnative/scroll_view.py +0 -63
  45. pythonnative-0.3.0/src/pythonnative/search_bar.py +0 -65
  46. pythonnative-0.3.0/src/pythonnative/stack_view.py +0 -60
  47. pythonnative-0.3.0/src/pythonnative/switch.py +0 -66
  48. pythonnative-0.3.0/src/pythonnative/templates/android_template/build.gradle +0 -7
  49. pythonnative-0.3.0/src/pythonnative/text_field.py +0 -67
  50. pythonnative-0.3.0/src/pythonnative/text_view.py +0 -70
  51. pythonnative-0.3.0/src/pythonnative/time_picker.py +0 -73
  52. pythonnative-0.3.0/src/pythonnative/utils.py +0 -91
  53. pythonnative-0.3.0/src/pythonnative/view.py +0 -25
  54. pythonnative-0.3.0/src/pythonnative/web_view.py +0 -58
  55. pythonnative-0.3.0/src/pythonnative.egg-info/PKG-INFO +0 -137
  56. pythonnative-0.3.0/tests/test_smoke.py +0 -2
  57. {pythonnative-0.3.0 → pythonnative-0.5.0}/setup.cfg +0 -0
  58. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/cli/__init__.py +0 -0
  59. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/collection_view.py +0 -0
  60. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/material_bottom_navigation_view.py +0 -0
  61. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/material_toolbar.py +0 -0
  62. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/proguard-rules.pro +0 -0
  63. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/androidTest/java/com/pythonnative/android_template/ExampleInstrumentedTest.kt +0 -0
  64. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/AndroidManifest.xml +0 -0
  65. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/MainActivity.kt +0 -0
  66. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/Navigator.kt +0 -0
  67. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/drawable/ic_launcher_background.xml +0 -0
  68. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +0 -0
  69. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/layout/activity_main.xml +0 -0
  70. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -0
  71. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -0
  72. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
  73. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
  74. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
  75. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
  76. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
  77. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
  78. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
  79. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
  80. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
  81. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
  82. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/values/colors.xml +0 -0
  83. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/values/strings.xml +0 -0
  84. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/values/themes.xml +0 -0
  85. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/values-night/themes.xml +0 -0
  86. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/xml/backup_rules.xml +0 -0
  87. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/main/res/xml/data_extraction_rules.xml +0 -0
  88. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/app/src/test/java/com/pythonnative/android_template/ExampleUnitTest.kt +0 -0
  89. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.jar +0 -0
  90. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/gradle.properties +0 -0
  91. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/gradlew +0 -0
  92. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/gradlew.bat +0 -0
  93. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/android_template/settings.gradle +0 -0
  94. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/AppDelegate.swift +0 -0
  95. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/AccentColor.colorset/Contents.json +0 -0
  96. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
  97. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/Contents.json +0 -0
  98. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/Base.lproj/LaunchScreen.storyboard +0 -0
  99. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/Base.lproj/Main.storyboard +0 -0
  100. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/Info.plist +0 -0
  101. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/SceneDelegate.swift +0 -0
  102. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template/ViewController.swift +0 -0
  103. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template.xcodeproj/project.pbxproj +0 -0
  104. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_template.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  105. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_templateTests/ios_templateTests.swift +0 -0
  106. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITests.swift +0 -0
  107. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITestsLaunchTests.swift +0 -0
  108. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative.egg-info/dependency_links.txt +0 -0
  109. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative.egg-info/entry_points.txt +0 -0
  110. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative.egg-info/requires.txt +0 -0
  111. {pythonnative-0.3.0 → pythonnative-0.5.0}/src/pythonnative.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 PythonNative
3
+ Copyright (c) 2026 Owen Carey
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: pythonnative
3
+ Version: 0.5.0
4
+ Summary: Cross-platform native UI toolkit for Android and iOS
5
+ Author: Owen Carey
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Owen Carey
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ THE SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/pythonnative/pythonnative
29
+ Project-URL: Repository, https://github.com/pythonnative/pythonnative
30
+ Project-URL: Issues, https://github.com/pythonnative/pythonnative/issues
31
+ Project-URL: Documentation, https://docs.pythonnative.com/
32
+ Classifier: Development Status :: 2 - Pre-Alpha
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3 :: Only
37
+ Classifier: Programming Language :: Python :: 3.9
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Classifier: Topic :: Software Development :: User Interfaces
42
+ Requires-Python: >=3.9
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Requires-Dist: requests>=2.31.0
46
+ Provides-Extra: ios
47
+ Requires-Dist: rubicon-objc<0.5.0,>=0.4.6; extra == "ios"
48
+ Provides-Extra: docs
49
+ Requires-Dist: mkdocs>=1.5; extra == "docs"
50
+ Requires-Dist: mkdocs-material[imaging]>=9.5; extra == "docs"
51
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
52
+ Provides-Extra: dev
53
+ Requires-Dist: black>=24.0; extra == "dev"
54
+ Requires-Dist: ruff>=0.5; extra == "dev"
55
+ Requires-Dist: mypy>=1.10; extra == "dev"
56
+ Requires-Dist: pytest>=8.0; extra == "dev"
57
+ Provides-Extra: ci
58
+ Requires-Dist: black>=24.0; extra == "ci"
59
+ Requires-Dist: ruff>=0.5; extra == "ci"
60
+ Requires-Dist: mypy>=1.10; extra == "ci"
61
+ Requires-Dist: pytest>=8.0; extra == "ci"
62
+ Dynamic: license-file
63
+
64
+ <p align="center">
65
+ <img src="docs/assets/banner.jpg" alt="PythonNative" width="800" />
66
+ </p>
67
+
68
+ <p align="center">
69
+ <em>Build native Android and iOS apps in Python.</em>
70
+ </p>
71
+
72
+ <p align="center">
73
+ <a href="https://github.com/pythonnative/pythonnative/actions/workflows/ci.yml"><img src="https://github.com/pythonnative/pythonnative/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
74
+ <a href="https://github.com/pythonnative/pythonnative/actions/workflows/release.yml"><img src="https://github.com/pythonnative/pythonnative/actions/workflows/release.yml/badge.svg" alt="Release" /></a>
75
+ <a href="https://pypi.org/project/pythonnative/"><img src="https://img.shields.io/pypi/v/pythonnative" alt="PyPI Version" /></a>
76
+ <a href="https://pypi.org/project/pythonnative/"><img src="https://img.shields.io/pypi/pyversions/pythonnative" alt="Python Versions" /></a>
77
+ <a href="LICENSE"><img src="https://img.shields.io/pypi/l/pythonnative" alt="License: MIT" /></a>
78
+ <a href="https://docs.pythonnative.com/"><img src="https://img.shields.io/website?url=https%3A%2F%2Fdocs.pythonnative.com&label=docs" alt="Docs" /></a>
79
+ </p>
80
+
81
+ <p align="center">
82
+ <a href="https://docs.pythonnative.com/">Documentation</a> ·
83
+ <a href="https://docs.pythonnative.com/getting-started/">Getting Started</a> ·
84
+ <a href="https://docs.pythonnative.com/examples/">Examples</a> ·
85
+ <a href="CONTRIBUTING.md">Contributing</a>
86
+ </p>
87
+
88
+ ---
89
+
90
+ ## Overview
91
+
92
+ PythonNative is a cross-platform toolkit for building native Android and iOS apps in Python. It provides a **declarative, React-like component model** with automatic reconciliation, powered by Chaquopy on Android and rubicon-objc on iOS. Describe your UI as a tree of elements, manage state with `set_state()`, and let PythonNative handle creating and updating native views.
93
+
94
+ ## Features
95
+
96
+ - **Declarative UI:** Describe *what* your UI should look like with element functions (`Text`, `Button`, `Column`, `Row`, etc.). PythonNative creates and updates native views automatically.
97
+ - **Reactive state:** Call `self.set_state(key=value)` and the framework re-renders only what changed — no manual view mutation.
98
+ - **Virtual view tree + reconciler:** Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation.
99
+ - **Direct native bindings:** Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
100
+ - **CLI scaffolding:** `pn init` creates a ready-to-run project; `pn run android` and `pn run ios` build and launch your app.
101
+ - **Navigation:** Push and pop screens with argument passing for multi-page apps.
102
+ - **Bundled templates:** Android Gradle and iOS Xcode templates are included — scaffolding requires no network access.
103
+
104
+ ## Quick Start
105
+
106
+ ### Installation
107
+
108
+ ```bash
109
+ pip install pythonnative
110
+ ```
111
+
112
+ ### Usage
113
+
114
+ ```python
115
+ import pythonnative as pn
116
+
117
+
118
+ class MainPage(pn.Page):
119
+ def __init__(self, native_instance):
120
+ super().__init__(native_instance)
121
+ self.state = {"count": 0}
122
+
123
+ def render(self):
124
+ return pn.Column(
125
+ pn.Text(f"Count: {self.state['count']}", font_size=24),
126
+ pn.Button(
127
+ "Tap me",
128
+ on_click=lambda: self.set_state(count=self.state["count"] + 1),
129
+ ),
130
+ spacing=12,
131
+ padding=16,
132
+ )
133
+ ```
134
+
135
+ ### Available Components
136
+
137
+ | Component | Description |
138
+ |---|---|
139
+ | `Text` | Display text |
140
+ | `Button` | Tappable button with `on_click` callback |
141
+ | `Column` / `Row` | Vertical / horizontal layout containers |
142
+ | `ScrollView` | Scrollable wrapper |
143
+ | `TextInput` | Text entry field with `on_change` callback |
144
+ | `Image` | Display images |
145
+ | `Switch` | Toggle with `on_change` callback |
146
+ | `ProgressBar` | Determinate progress (0.0–1.0) |
147
+ | `ActivityIndicator` | Indeterminate loading spinner |
148
+ | `WebView` | Embedded web content |
149
+ | `Spacer` | Empty space |
150
+
151
+ ## Documentation
152
+
153
+ Visit [docs.pythonnative.com](https://docs.pythonnative.com/) for the full documentation, including getting started guides, platform-specific instructions for Android and iOS, API reference, and working examples.
154
+
155
+ ## Contributing
156
+
157
+ Contributions are welcome. Please see [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions, coding standards, and guidelines for submitting pull requests.
158
+
159
+ ## License
160
+
161
+ [MIT](LICENSE)
@@ -0,0 +1,98 @@
1
+ <p align="center">
2
+ <img src="docs/assets/banner.jpg" alt="PythonNative" width="800" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <em>Build native Android and iOS apps in Python.</em>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/pythonnative/pythonnative/actions/workflows/ci.yml"><img src="https://github.com/pythonnative/pythonnative/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
11
+ <a href="https://github.com/pythonnative/pythonnative/actions/workflows/release.yml"><img src="https://github.com/pythonnative/pythonnative/actions/workflows/release.yml/badge.svg" alt="Release" /></a>
12
+ <a href="https://pypi.org/project/pythonnative/"><img src="https://img.shields.io/pypi/v/pythonnative" alt="PyPI Version" /></a>
13
+ <a href="https://pypi.org/project/pythonnative/"><img src="https://img.shields.io/pypi/pyversions/pythonnative" alt="Python Versions" /></a>
14
+ <a href="LICENSE"><img src="https://img.shields.io/pypi/l/pythonnative" alt="License: MIT" /></a>
15
+ <a href="https://docs.pythonnative.com/"><img src="https://img.shields.io/website?url=https%3A%2F%2Fdocs.pythonnative.com&label=docs" alt="Docs" /></a>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <a href="https://docs.pythonnative.com/">Documentation</a> ·
20
+ <a href="https://docs.pythonnative.com/getting-started/">Getting Started</a> ·
21
+ <a href="https://docs.pythonnative.com/examples/">Examples</a> ·
22
+ <a href="CONTRIBUTING.md">Contributing</a>
23
+ </p>
24
+
25
+ ---
26
+
27
+ ## Overview
28
+
29
+ PythonNative is a cross-platform toolkit for building native Android and iOS apps in Python. It provides a **declarative, React-like component model** with automatic reconciliation, powered by Chaquopy on Android and rubicon-objc on iOS. Describe your UI as a tree of elements, manage state with `set_state()`, and let PythonNative handle creating and updating native views.
30
+
31
+ ## Features
32
+
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
+ - **Reactive state:** Call `self.set_state(key=value)` and the framework re-renders only what changed — no manual view mutation.
35
+ - **Virtual view tree + reconciler:** Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation.
36
+ - **Direct native bindings:** Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
37
+ - **CLI scaffolding:** `pn init` creates a ready-to-run project; `pn run android` and `pn run ios` build and launch your app.
38
+ - **Navigation:** Push and pop screens with argument passing for multi-page apps.
39
+ - **Bundled templates:** Android Gradle and iOS Xcode templates are included — scaffolding requires no network access.
40
+
41
+ ## Quick Start
42
+
43
+ ### Installation
44
+
45
+ ```bash
46
+ pip install pythonnative
47
+ ```
48
+
49
+ ### Usage
50
+
51
+ ```python
52
+ import pythonnative as pn
53
+
54
+
55
+ class MainPage(pn.Page):
56
+ def __init__(self, native_instance):
57
+ super().__init__(native_instance)
58
+ self.state = {"count": 0}
59
+
60
+ def render(self):
61
+ return pn.Column(
62
+ pn.Text(f"Count: {self.state['count']}", font_size=24),
63
+ pn.Button(
64
+ "Tap me",
65
+ on_click=lambda: self.set_state(count=self.state["count"] + 1),
66
+ ),
67
+ spacing=12,
68
+ padding=16,
69
+ )
70
+ ```
71
+
72
+ ### Available Components
73
+
74
+ | Component | Description |
75
+ |---|---|
76
+ | `Text` | Display text |
77
+ | `Button` | Tappable button with `on_click` callback |
78
+ | `Column` / `Row` | Vertical / horizontal layout containers |
79
+ | `ScrollView` | Scrollable wrapper |
80
+ | `TextInput` | Text entry field with `on_change` callback |
81
+ | `Image` | Display images |
82
+ | `Switch` | Toggle with `on_change` callback |
83
+ | `ProgressBar` | Determinate progress (0.0–1.0) |
84
+ | `ActivityIndicator` | Indeterminate loading spinner |
85
+ | `WebView` | Embedded web content |
86
+ | `Spacer` | Empty space |
87
+
88
+ ## Documentation
89
+
90
+ Visit [docs.pythonnative.com](https://docs.pythonnative.com/) for the full documentation, including getting started guides, platform-specific instructions for Android and iOS, API reference, and working examples.
91
+
92
+ ## Contributing
93
+
94
+ Contributions are welcome. Please see [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions, coding standards, and guidelines for submitting pull requests.
95
+
96
+ ## License
97
+
98
+ [MIT](LICENSE)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pythonnative"
7
- version = "0.3.0"
7
+ version = "0.5.0"
8
8
  description = "Cross-platform native UI toolkit for Android and iOS"
9
9
  authors = [
10
10
  { name = "Owen Carey" }
@@ -88,3 +88,30 @@ ignore = []
88
88
  [tool.black]
89
89
  line-length = 120
90
90
  target-version = ['py39']
91
+
92
+ # ── Semantic Release ────────────────────────────────────────────────
93
+
94
+ [tool.semantic_release]
95
+ version_toml = ["pyproject.toml:project.version"]
96
+ version_variables = ["src/pythonnative/__init__.py:__version__"]
97
+ commit_message = "chore(release): v{version}"
98
+ tag_format = "v{version}"
99
+ major_on_zero = false
100
+
101
+ [tool.semantic_release.branches.main]
102
+ match = "main"
103
+ prerelease = false
104
+
105
+ [tool.semantic_release.changelog]
106
+ changelog_file = "CHANGELOG.md"
107
+ exclude_commit_patterns = [
108
+ "^chore\\(release\\):",
109
+ ]
110
+
111
+ [tool.semantic_release.commit_parser_options]
112
+ allowed_tags = [
113
+ "build", "chore", "ci", "docs", "feat", "fix",
114
+ "perf", "refactor", "revert", "style", "test",
115
+ ]
116
+ minor_tags = ["feat"]
117
+ patch_tags = ["fix", "perf"]
@@ -0,0 +1,54 @@
1
+ """PythonNative — declarative native UI for Android and iOS.
2
+
3
+ Public API::
4
+
5
+ import pythonnative as pn
6
+
7
+ class MainPage(pn.Page):
8
+ def __init__(self, native_instance):
9
+ super().__init__(native_instance)
10
+ self.state = {"count": 0}
11
+
12
+ def render(self):
13
+ return pn.Column(
14
+ pn.Text(f"Count: {self.state['count']}", font_size=24),
15
+ pn.Button("Increment", on_click=lambda: self.set_state(count=self.state["count"] + 1)),
16
+ spacing=12,
17
+ )
18
+ """
19
+
20
+ __version__ = "0.5.0"
21
+
22
+ from .components import (
23
+ ActivityIndicator,
24
+ Button,
25
+ Column,
26
+ Image,
27
+ ProgressBar,
28
+ Row,
29
+ ScrollView,
30
+ Spacer,
31
+ Switch,
32
+ Text,
33
+ TextInput,
34
+ WebView,
35
+ )
36
+ from .element import Element
37
+ from .page import Page
38
+
39
+ __all__ = [
40
+ "ActivityIndicator",
41
+ "Button",
42
+ "Column",
43
+ "Element",
44
+ "Image",
45
+ "Page",
46
+ "ProgressBar",
47
+ "Row",
48
+ "ScrollView",
49
+ "Spacer",
50
+ "Switch",
51
+ "Text",
52
+ "TextInput",
53
+ "WebView",
54
+ ]
@@ -41,7 +41,6 @@ def init_project(args: argparse.Namespace) -> None:
41
41
 
42
42
  os.makedirs(app_dir, exist_ok=True)
43
43
 
44
- # Minimal hello world app scaffold (no bootstrap function; host instantiates Page directly)
45
44
  main_page_py = os.path.join(app_dir, "main_page.py")
46
45
  if not os.path.exists(main_page_py) or args.force:
47
46
  with open(main_page_py, "w", encoding="utf-8") as f:
@@ -52,15 +51,22 @@ def init_project(args: argparse.Namespace) -> None:
52
51
  class MainPage(pn.Page):
53
52
  def __init__(self, native_instance):
54
53
  super().__init__(native_instance)
55
-
56
- def on_create(self):
57
- super().on_create()
58
- stack = pn.StackView()
59
- stack.add_view(pn.Label("Hello from PythonNative!"))
60
- button = pn.Button("Tap me")
61
- button.set_on_click(lambda: print("Button clicked"))
62
- stack.add_view(button)
63
- self.set_root_view(stack)
54
+ self.state = {"count": 0}
55
+
56
+ def increment(self):
57
+ self.set_state(count=self.state["count"] + 1)
58
+
59
+ def render(self):
60
+ return pn.ScrollView(
61
+ pn.Column(
62
+ pn.Text("Hello from PythonNative!", font_size=24, bold=True),
63
+ pn.Text(f"Tapped {self.state['count']} times"),
64
+ pn.Button("Tap me", on_click=self.increment),
65
+ spacing=12,
66
+ padding=16,
67
+ alignment="fill",
68
+ )
69
+ )
64
70
  """
65
71
  )
66
72
 
@@ -0,0 +1,241 @@
1
+ """Built-in element-creating functions for declarative UI composition.
2
+
3
+ Each function returns an :class:`Element` describing a native UI widget.
4
+ These are pure data — no native views are created until the reconciler
5
+ mounts the element tree.
6
+
7
+ Naming follows React Native conventions:
8
+
9
+ - ``Text`` (was *Label*)
10
+ - ``Button``
11
+ - ``Column`` / ``Row`` (was *StackView* vertical/horizontal)
12
+ - ``ScrollView``
13
+ - ``TextInput`` (was *TextField*)
14
+ - ``Image`` (was *ImageView*)
15
+ - ``Switch``
16
+ - ``ProgressBar`` (was *ProgressView*)
17
+ - ``ActivityIndicator`` (was *ActivityIndicatorView*)
18
+ - ``WebView``
19
+ - ``Spacer`` (new)
20
+ """
21
+
22
+ from typing import Any, Callable, Dict, Optional, Union
23
+
24
+ from .element import Element
25
+
26
+
27
+ def _filter_none(**kwargs: Any) -> Dict[str, Any]:
28
+ """Return *kwargs* with ``None``-valued entries removed."""
29
+ return {k: v for k, v in kwargs.items() if v is not None}
30
+
31
+
32
+ # ---------------------------------------------------------------------------
33
+ # Leaf components
34
+ # ---------------------------------------------------------------------------
35
+
36
+
37
+ def Text(
38
+ text: str = "",
39
+ *,
40
+ font_size: Optional[float] = None,
41
+ color: Optional[str] = None,
42
+ bold: bool = False,
43
+ text_align: Optional[str] = None,
44
+ background_color: Optional[str] = None,
45
+ max_lines: Optional[int] = None,
46
+ key: Optional[str] = None,
47
+ ) -> Element:
48
+ """Display text."""
49
+ props = _filter_none(
50
+ text=text,
51
+ font_size=font_size,
52
+ color=color,
53
+ bold=bold or None,
54
+ text_align=text_align,
55
+ background_color=background_color,
56
+ max_lines=max_lines,
57
+ )
58
+ return Element("Text", props, [], key=key)
59
+
60
+
61
+ def Button(
62
+ title: str = "",
63
+ *,
64
+ on_click: Optional[Callable[[], None]] = None,
65
+ color: Optional[str] = None,
66
+ background_color: Optional[str] = None,
67
+ font_size: Optional[float] = None,
68
+ enabled: bool = True,
69
+ key: Optional[str] = None,
70
+ ) -> Element:
71
+ """Create a tappable button."""
72
+ props: Dict[str, Any] = {"title": title}
73
+ if on_click is not None:
74
+ props["on_click"] = on_click
75
+ if color is not None:
76
+ props["color"] = color
77
+ if background_color is not None:
78
+ props["background_color"] = background_color
79
+ if font_size is not None:
80
+ props["font_size"] = font_size
81
+ if not enabled:
82
+ props["enabled"] = False
83
+ return Element("Button", props, [], key=key)
84
+
85
+
86
+ def TextInput(
87
+ *,
88
+ value: str = "",
89
+ placeholder: str = "",
90
+ on_change: Optional[Callable[[str], None]] = None,
91
+ secure: bool = False,
92
+ font_size: Optional[float] = None,
93
+ color: Optional[str] = None,
94
+ background_color: Optional[str] = None,
95
+ key: Optional[str] = None,
96
+ ) -> Element:
97
+ """Create a single-line text entry field."""
98
+ props: Dict[str, Any] = {"value": value}
99
+ if placeholder:
100
+ props["placeholder"] = placeholder
101
+ if on_change is not None:
102
+ props["on_change"] = on_change
103
+ if secure:
104
+ props["secure"] = True
105
+ if font_size is not None:
106
+ props["font_size"] = font_size
107
+ if color is not None:
108
+ props["color"] = color
109
+ if background_color is not None:
110
+ props["background_color"] = background_color
111
+ return Element("TextInput", props, [], key=key)
112
+
113
+
114
+ def Image(
115
+ source: str = "",
116
+ *,
117
+ width: Optional[float] = None,
118
+ height: Optional[float] = None,
119
+ scale_type: Optional[str] = None,
120
+ background_color: Optional[str] = None,
121
+ key: Optional[str] = None,
122
+ ) -> Element:
123
+ """Display an image from a resource path or URL."""
124
+ props = _filter_none(
125
+ source=source or None,
126
+ width=width,
127
+ height=height,
128
+ scale_type=scale_type,
129
+ background_color=background_color,
130
+ )
131
+ return Element("Image", props, [], key=key)
132
+
133
+
134
+ def Switch(
135
+ *,
136
+ value: bool = False,
137
+ on_change: Optional[Callable[[bool], None]] = None,
138
+ key: Optional[str] = None,
139
+ ) -> Element:
140
+ """Create a toggle switch."""
141
+ props: Dict[str, Any] = {"value": value}
142
+ if on_change is not None:
143
+ props["on_change"] = on_change
144
+ return Element("Switch", props, [], key=key)
145
+
146
+
147
+ def ProgressBar(
148
+ *,
149
+ value: float = 0.0,
150
+ background_color: Optional[str] = None,
151
+ key: Optional[str] = None,
152
+ ) -> Element:
153
+ """Show determinate progress (0.0 – 1.0)."""
154
+ props = _filter_none(value=value, background_color=background_color)
155
+ return Element("ProgressBar", props, [], key=key)
156
+
157
+
158
+ def ActivityIndicator(
159
+ *,
160
+ animating: bool = True,
161
+ key: Optional[str] = None,
162
+ ) -> Element:
163
+ """Show an indeterminate loading spinner."""
164
+ return Element("ActivityIndicator", {"animating": animating}, [], key=key)
165
+
166
+
167
+ def WebView(
168
+ *,
169
+ url: str = "",
170
+ key: Optional[str] = None,
171
+ ) -> Element:
172
+ """Embed web content."""
173
+ props: Dict[str, Any] = {}
174
+ if url:
175
+ props["url"] = url
176
+ return Element("WebView", props, [], key=key)
177
+
178
+
179
+ def Spacer(
180
+ *,
181
+ size: Optional[float] = None,
182
+ key: Optional[str] = None,
183
+ ) -> Element:
184
+ """Insert empty space with an optional fixed size."""
185
+ props = _filter_none(size=size)
186
+ return Element("Spacer", props, [], key=key)
187
+
188
+
189
+ # ---------------------------------------------------------------------------
190
+ # Container components
191
+ # ---------------------------------------------------------------------------
192
+
193
+ PaddingValue = Union[int, float, Dict[str, Union[int, float]]]
194
+
195
+
196
+ def Column(
197
+ *children: Element,
198
+ spacing: float = 0,
199
+ padding: Optional[PaddingValue] = None,
200
+ alignment: Optional[str] = None,
201
+ background_color: Optional[str] = None,
202
+ key: Optional[str] = None,
203
+ ) -> Element:
204
+ """Arrange children vertically."""
205
+ props = _filter_none(
206
+ spacing=spacing or None,
207
+ padding=padding,
208
+ alignment=alignment,
209
+ background_color=background_color,
210
+ )
211
+ return Element("Column", props, list(children), key=key)
212
+
213
+
214
+ def Row(
215
+ *children: Element,
216
+ spacing: float = 0,
217
+ padding: Optional[PaddingValue] = None,
218
+ alignment: Optional[str] = None,
219
+ background_color: Optional[str] = None,
220
+ key: Optional[str] = None,
221
+ ) -> Element:
222
+ """Arrange children horizontally."""
223
+ props = _filter_none(
224
+ spacing=spacing or None,
225
+ padding=padding,
226
+ alignment=alignment,
227
+ background_color=background_color,
228
+ )
229
+ return Element("Row", props, list(children), key=key)
230
+
231
+
232
+ def ScrollView(
233
+ child: Optional[Element] = None,
234
+ *,
235
+ background_color: Optional[str] = None,
236
+ key: Optional[str] = None,
237
+ ) -> Element:
238
+ """Wrap a single child in a scrollable container."""
239
+ children = [child] if child is not None else []
240
+ props = _filter_none(background_color=background_color)
241
+ return Element("ScrollView", props, children, key=key)
@@ -0,0 +1,47 @@
1
+ """Lightweight element descriptors for the virtual view tree.
2
+
3
+ An Element is an immutable description of a UI node — analogous to a React
4
+ element. It captures a type name, a props dictionary, and an ordered list
5
+ of children without creating any native platform objects. The reconciler
6
+ consumes these trees to determine what native views must be created,
7
+ updated, or removed.
8
+ """
9
+
10
+ from typing import Any, Dict, List, Optional
11
+
12
+
13
+ class Element:
14
+ """Immutable description of a single UI node."""
15
+
16
+ __slots__ = ("type", "props", "children", "key")
17
+
18
+ def __init__(
19
+ self,
20
+ type_name: str,
21
+ props: Dict[str, Any],
22
+ children: List["Element"],
23
+ key: Optional[str] = None,
24
+ ) -> None:
25
+ self.type = type_name
26
+ self.props = props
27
+ self.children = children
28
+ self.key = key
29
+
30
+ def __repr__(self) -> str:
31
+ return f"Element({self.type!r}, props={set(self.props)}, children={len(self.children)})"
32
+
33
+ def __eq__(self, other: object) -> bool:
34
+ if not isinstance(other, Element):
35
+ return NotImplemented
36
+ return (
37
+ self.type == other.type
38
+ and self.props == other.props
39
+ and self.children == other.children
40
+ and self.key == other.key
41
+ )
42
+
43
+ def __ne__(self, other: object) -> bool:
44
+ result = self.__eq__(other)
45
+ if result is NotImplemented:
46
+ return result
47
+ return not result