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.
Files changed (33) hide show
  1. pythonnative/__init__.py +28 -3
  2. pythonnative/_ios_log.py +20 -22
  3. pythonnative/cli/__init__.py +7 -0
  4. pythonnative/cli/pn.py +360 -56
  5. pythonnative/components.py +330 -82
  6. pythonnative/element.py +32 -8
  7. pythonnative/hooks.py +322 -56
  8. pythonnative/hot_reload.py +219 -33
  9. pythonnative/layout.py +949 -0
  10. pythonnative/native_modules/__init__.py +12 -6
  11. pythonnative/native_modules/camera.py +32 -16
  12. pythonnative/native_modules/file_system.py +125 -15
  13. pythonnative/native_modules/location.py +32 -9
  14. pythonnative/native_modules/notifications.py +51 -18
  15. pythonnative/native_views/__init__.py +134 -13
  16. pythonnative/native_views/android.py +184 -222
  17. pythonnative/native_views/base.py +150 -48
  18. pythonnative/native_views/ios.py +255 -183
  19. pythonnative/navigation.py +288 -63
  20. pythonnative/page.py +687 -76
  21. pythonnative/platform_metrics.py +139 -0
  22. pythonnative/reconciler.py +488 -31
  23. pythonnative/style.py +79 -18
  24. pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/MainActivity.kt +4 -0
  25. pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PageFragment.kt +23 -0
  26. pythonnative/templates/ios_template/ios_template/ViewController.swift +58 -4
  27. pythonnative/utils.py +77 -15
  28. {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/METADATA +4 -1
  29. {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/RECORD +33 -31
  30. {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/WHEEL +0 -0
  31. {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/entry_points.txt +0 -0
  32. {pythonnative-0.9.0.dist-info → pythonnative-0.11.0.dist-info}/licenses/LICENSE +0 -0
  33. {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 declarative native UI for Android and iOS.
1
+ """PythonNative: declarative native UI for Android and iOS.
2
2
 
3
- Public API::
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.9.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 ``sys.stdout``/``sys.stderr`` through fd 2 on iOS.
2
-
3
- Why
4
- ---
5
- When an app is launched via ``xcrun simctl launch --console-pty`` (what
6
- ``pn run ios`` does), the simulator attaches the caller's terminal to
7
- the app's stderr, which is the same channel ``NSLog`` / ``os_log``
8
- writes to. Python ``print()`` calls, however, go to ``sys.stdout``
9
- (fd 1), and for reasons specific to how CPython's embedded framework
10
- is started on the iOS Simulator that descriptor does not reach the
11
- attached console. As a result users see Swift-side ``NSLog`` output
12
- but never their own ``print()`` output.
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
- ``simctl`` (that's exactly how ``NSLog`` reaches the terminal), so
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: no rubicon-objc or
20
- platform-specific C bindings required, so it's safe to import early
21
- during ``pythonnative`` package initialization.
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
- It's write-through (no buffering) so a ``print()`` call appears in
37
- the terminal immediately, which matches user expectations for an
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 ``sys.stdout`` / ``sys.stderr`` for fd-2 writers.
83
+ """Swap `sys.stdout` and `sys.stderr` for fd-2 writers.
86
84
 
87
- Safe to call multiple times; only the first call has effect.
85
+ Idempotent: only the first call has effect.
88
86
  """
89
87
  global _installed
90
88
  if _installed:
@@ -0,0 +1,7 @@
1
+ """Command-line interface package for the `pn` script.
2
+
3
+ The CLI entry point lives in
4
+ [`pythonnative.cli.pn`][pythonnative.cli.pn] and is exposed as the
5
+ `pn` console script (configured in `pyproject.toml`'s
6
+ `[project.scripts]`).
7
+ """