pythonnative 0.9.0__py3-none-any.whl → 0.11.0__py3-none-any.whl
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/__init__.py +28 -3
- pythonnative/_ios_log.py +20 -22
- pythonnative/cli/__init__.py +7 -0
- pythonnative/cli/pn.py +360 -56
- pythonnative/components.py +330 -82
- pythonnative/element.py +32 -8
- pythonnative/hooks.py +322 -56
- pythonnative/hot_reload.py +219 -33
- pythonnative/layout.py +949 -0
- pythonnative/native_modules/__init__.py +12 -6
- pythonnative/native_modules/camera.py +32 -16
- pythonnative/native_modules/file_system.py +125 -15
- pythonnative/native_modules/location.py +32 -9
- pythonnative/native_modules/notifications.py +51 -18
- pythonnative/native_views/__init__.py +134 -13
- pythonnative/native_views/android.py +184 -222
- pythonnative/native_views/base.py +150 -48
- pythonnative/native_views/ios.py +255 -183
- pythonnative/navigation.py +288 -63
- pythonnative/page.py +687 -76
- pythonnative/platform_metrics.py +139 -0
- pythonnative/reconciler.py +488 -31
- pythonnative/style.py +79 -18
- pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/MainActivity.kt +4 -0
- pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PageFragment.kt +23 -0
- pythonnative/templates/ios_template/ios_template/ViewController.swift +58 -4
- pythonnative/utils.py +77 -15
- {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/METADATA +4 -1
- {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/RECORD +33 -31
- {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/WHEEL +0 -0
- {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/entry_points.txt +0 -0
- {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/licenses/LICENSE +0 -0
- {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/top_level.txt +0 -0
pythonnative/__init__.py
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
"""PythonNative
|
|
1
|
+
"""PythonNative: declarative native UI for Android and iOS.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
PythonNative is a cross-platform toolkit that turns Python ``@component``
|
|
4
|
+
functions into real, native Android and iOS views. The component model
|
|
5
|
+
is React-like (function components plus hooks), but rendering happens
|
|
6
|
+
through direct platform bindings: Chaquopy on Android (Java) and
|
|
7
|
+
rubicon-objc on iOS (Objective-C). There is no JavaScript bridge.
|
|
4
8
|
|
|
9
|
+
Key building blocks:
|
|
10
|
+
|
|
11
|
+
- **Element factories** ([`Text`][pythonnative.Text],
|
|
12
|
+
[`Button`][pythonnative.Button], [`Column`][pythonnative.Column], etc.)
|
|
13
|
+
return immutable [`Element`][pythonnative.Element] descriptors.
|
|
14
|
+
- **Hooks** ([`use_state`][pythonnative.use_state],
|
|
15
|
+
[`use_effect`][pythonnative.use_effect],
|
|
16
|
+
[`use_reducer`][pythonnative.use_reducer], etc.) manage state, side
|
|
17
|
+
effects, and context inside `@component` functions.
|
|
18
|
+
- **Navigation** is built from
|
|
19
|
+
[`NavigationContainer`][pythonnative.NavigationContainer] plus one of
|
|
20
|
+
the [`create_stack_navigator`][pythonnative.create_stack_navigator],
|
|
21
|
+
[`create_tab_navigator`][pythonnative.create_tab_navigator], or
|
|
22
|
+
[`create_drawer_navigator`][pythonnative.create_drawer_navigator]
|
|
23
|
+
factories.
|
|
24
|
+
- **Styling** uses a single ``style`` dict per element (or a list of
|
|
25
|
+
dicts), composable via [`StyleSheet`][pythonnative.StyleSheet].
|
|
26
|
+
|
|
27
|
+
Example:
|
|
28
|
+
```python
|
|
5
29
|
import pythonnative as pn
|
|
6
30
|
|
|
7
31
|
@pn.component
|
|
@@ -12,9 +36,10 @@ Public API::
|
|
|
12
36
|
pn.Button("+", on_click=lambda: set_count(count + 1)),
|
|
13
37
|
style={"spacing": 12},
|
|
14
38
|
)
|
|
39
|
+
```
|
|
15
40
|
"""
|
|
16
41
|
|
|
17
|
-
__version__ = "0.
|
|
42
|
+
__version__ = "0.11.0"
|
|
18
43
|
|
|
19
44
|
from .components import (
|
|
20
45
|
ActivityIndicator,
|
pythonnative/_ios_log.py
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
"""Route Python
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Redirecting ``sys.stdout`` / ``sys.stderr`` at a Python level to write
|
|
1
|
+
"""Route Python `sys.stdout`/`sys.stderr` through fd 2 on iOS.
|
|
2
|
+
|
|
3
|
+
When an app is launched via `xcrun simctl launch --console-pty`
|
|
4
|
+
(what `pn run ios` does), the simulator attaches the caller's
|
|
5
|
+
terminal to the app's stderr, which is the same channel `NSLog` and
|
|
6
|
+
`os_log` write to. Python `print()` calls, however, go to
|
|
7
|
+
`sys.stdout` (fd 1), and for reasons specific to how CPython's
|
|
8
|
+
embedded framework is started on the iOS Simulator that descriptor
|
|
9
|
+
does not reach the attached console. As a result, users see
|
|
10
|
+
Swift-side `NSLog` output but never their own `print()` output.
|
|
11
|
+
|
|
12
|
+
Redirecting `sys.stdout` and `sys.stderr` at a Python level to write
|
|
15
13
|
straight to fd 2 is a small, reliable fix: fd 2 *is* visible to
|
|
16
|
-
|
|
14
|
+
`simctl` (that is exactly how `NSLog` reaches the terminal), so
|
|
17
15
|
Python output lands next to the Swift logs with correct ordering.
|
|
18
16
|
|
|
19
|
-
This module is intentionally self-contained
|
|
20
|
-
platform-specific C bindings required, so it
|
|
21
|
-
during
|
|
17
|
+
This module is intentionally self-contained (no rubicon-objc or
|
|
18
|
+
platform-specific C bindings required), so it is safe to import
|
|
19
|
+
early during `pythonnative` package initialization.
|
|
22
20
|
"""
|
|
23
21
|
|
|
24
22
|
from __future__ import annotations
|
|
@@ -33,8 +31,8 @@ _STDERR_FD = 2
|
|
|
33
31
|
class _StderrStream:
|
|
34
32
|
"""Minimal text-mode file-like that writes UTF-8 bytes to fd 2.
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
Write-through (no buffering), so a `print()` call appears in the
|
|
35
|
+
terminal immediately. That matches user expectations for an
|
|
38
36
|
interactive "run on simulator" log stream.
|
|
39
37
|
"""
|
|
40
38
|
|
|
@@ -82,9 +80,9 @@ _installed = False
|
|
|
82
80
|
|
|
83
81
|
|
|
84
82
|
def install() -> None:
|
|
85
|
-
"""Swap
|
|
83
|
+
"""Swap `sys.stdout` and `sys.stderr` for fd-2 writers.
|
|
86
84
|
|
|
87
|
-
|
|
85
|
+
Idempotent: only the first call has effect.
|
|
88
86
|
"""
|
|
89
87
|
global _installed
|
|
90
88
|
if _installed:
|
pythonnative/cli/__init__.py
CHANGED