pythonnative 0.23.0__py3-none-any.whl → 0.24.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.
@@ -8,6 +8,7 @@ import android.view.LayoutInflater
8
8
  import android.view.View
9
9
  import android.view.ViewGroup
10
10
  import android.widget.FrameLayout
11
+ import androidx.activity.OnBackPressedCallback
11
12
  import androidx.core.os.bundleOf
12
13
  import androidx.fragment.app.Fragment
13
14
  import com.chaquo.python.PyObject
@@ -54,6 +55,27 @@ class ScreenFragment : Fragment() {
54
55
  } catch (e: Exception) {
55
56
  Log.e(TAG, "Failed to instantiate screen", e)
56
57
  }
58
+
59
+ // Offer the system back action to Python (`use_back_handler`)
60
+ // before running the default pop/finish behavior.
61
+ requireActivity().onBackPressedDispatcher.addCallback(
62
+ this,
63
+ object : OnBackPressedCallback(true) {
64
+ override fun handleOnBackPressed() {
65
+ val consumed = try {
66
+ screen?.callAttr("on_back_pressed")?.toBoolean() ?: false
67
+ } catch (e: Exception) {
68
+ Log.w(TAG, "on_back_pressed failed", e)
69
+ false
70
+ }
71
+ if (!consumed) {
72
+ isEnabled = false
73
+ requireActivity().onBackPressedDispatcher.onBackPressed()
74
+ isEnabled = true
75
+ }
76
+ }
77
+ }
78
+ )
57
79
  }
58
80
 
59
81
  override fun onCreateView(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonnative
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: Cross-platform native UI toolkit for Android and iOS
5
5
  Author: Owen Carey
6
6
  License: MIT License
@@ -104,7 +104,8 @@ PythonNative is a cross-platform toolkit for building native Android and iOS app
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
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
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
- - **Hooks and function components:** Manage state with `use_state`, side effects with `use_effect`, and navigation with `use_navigation`, all through one consistent pattern.
107
+ - **Hooks and function components:** Manage state with `use_state`, side effects with `use_effect` / `use_layout_effect`, refs and imperative handles with `use_ref` / `use_imperative_handle`, and navigation with `use_navigation`, all through one consistent pattern. Components can return a single element, a list of siblings, or `None`, and `Fragment`, `Portal`, and reactive `Provider` context work the way they do in React.
108
+ - **Developer feedback that finds your bugs:** In dev mode (`pn preview`, hot reload, or `PN_DEV=1`), uncaught errors from renders, effects, and event handlers show a full-screen RedBox with the traceback; unknown style keys and duplicate list keys print "did you mean" warnings; and conditional hooks raise a `HookOrderError` at the source instead of silently cross-wiring state.
108
109
  - **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
110
  - **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
111
  - **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.
@@ -115,7 +116,7 @@ PythonNative is a cross-platform toolkit for building native Android and iOS app
115
116
  - **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
117
  - **CLI scaffolding:** `pn init` creates a ready-to-run project; `pn run android` and `pn run ios` build and launch your app.
117
118
  - **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
- - **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
+ - **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; `use_back_handler` intercepts the back action when a screen needs to.
119
120
  - **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
121
  - **Bundled templates:** Android Gradle and iOS Xcode templates are included, so scaffolding requires no network access.
121
122
 
@@ -140,7 +141,7 @@ def App():
140
141
  pn.Text(f"Count: {count}", style=pn.style(font_size=24, bold=True)),
141
142
  pn.Button(
142
143
  "Tap me",
143
- on_click=lambda: set_count(count + 1),
144
+ on_press=lambda: set_count(count + 1),
144
145
  ),
145
146
  style=pn.style(spacing=12, padding=16),
146
147
  )
@@ -1,31 +1,32 @@
1
- pythonnative/__init__.py,sha256=vDBibKua43iWhsjL-R5bptS2tJKdkf69RqYs2o61NAw,8861
1
+ pythonnative/__init__.py,sha256=HcUCPSMZBt7N1-AFt4u6doqhgt_VOgImWEASJk5Tj6A,8394
2
2
  pythonnative/_ios_log.py,sha256=Oi7V28VxcVoZyrpAirvLeEmUW18McqnU87V4d37Zzlw,2582
3
3
  pythonnative/alerts.py,sha256=mIANysFlaHwL5EqKnvNcyiJN9rGiZi9XDrD9Jpz1RFM,9340
4
- pythonnative/animated.py,sha256=IBokHVfp_Ud5VC8b4drY9DX8A4uG9wqRUjcW3y-EtkI,36233
4
+ pythonnative/animated.py,sha256=2t6thUzmmapccP6ziW-x2tr8A2LCrWQoF8KqoETdSDY,36226
5
5
  pythonnative/appearance.py,sha256=vMkDRIz9ptaprMmlPmiYJLVwrDslfnc1bhwyE27M2ZI,3891
6
- pythonnative/components.py,sha256=zz3SOZDXABRXHE3bmS56Z9v24X0ewebHnbO_y3r5KOc,115170
7
- pythonnative/element.py,sha256=W9varJj0Cl9HpckL8BcsC1u4ryUQOPVMrvetro4ilAE,2725
8
- pythonnative/events.py,sha256=H3XmZW99M16Q1OiRq1NbS6e-Pdopi6piCh6qdkmEu40,7632
6
+ pythonnative/components.py,sha256=61DKYxdcfaw1B4LqS5ho0aUksxjkA2zq4BB1cJiQHzA,106286
7
+ pythonnative/diagnostics.py,sha256=F6Ym163wSZI93j_ScwRWULIuxRxQ39f5lqvXRDP93po,7078
8
+ pythonnative/element.py,sha256=jbCMPiVq4oRgbSAbKdltBJ1BU6Aom1qKoc6-FsbpJ74,2902
9
+ pythonnative/events.py,sha256=EFYz8HxVOTA3soAe0Z9P2gZN9ShLjXhKH7I34DmnNbM,7895
9
10
  pythonnative/gestures.py,sha256=6qe_s3Cv2M5_V-_PgAQ5y9QbYV812B0xVmh8dRDHYMY,29940
10
- pythonnative/hooks.py,sha256=bM0t1WgkRhJ1myovY0AQY_QsHkO66lkeq4hFfRg8d58,40150
11
- pythonnative/hot_reload.py,sha256=g-PKXRw7IXZgLyuGwjQmztH10JjT8ULM-szrWWTKe7U,25024
11
+ pythonnative/hooks.py,sha256=iOngNAtCeQPwdL0zwvgJ1TOKSarObVSG_zIhSAyKhPo,54439
12
+ pythonnative/hot_reload.py,sha256=2HI6u-fc4JRudc35BAe8RXmPIXLWh1imoH4fMVqu_Ks,25502
12
13
  pythonnative/images.py,sha256=JFjBJdZzZoQmAOfQ7QHqi7dYJ75XTs3u2lweQHGbdPc,6466
13
14
  pythonnative/layout.py,sha256=Ck_FCLSk0g4hdOzHo0c50cbvLe8Q8caQAxywXgnFhKM,49077
14
15
  pythonnative/mutations.py,sha256=whmxO6ENWjm-yYH0QteoCV1Gdw_v-fJrhicMQJ5A0rk,3827
15
- pythonnative/navigation.py,sha256=4U57lHqiJJbqRJdTdvveRHKJ58BJhrwvkDOSoFt02I8,35566
16
+ pythonnative/navigation.py,sha256=TCDD6MGCEW9qBDZFCJhymUVEtoeNPhQgvio8IbgL0pU,36552
16
17
  pythonnative/net.py,sha256=8D7EyEC8-JkYxlrtVfTDApOGzzdcA4P4kaCdYBBZI8E,8082
17
18
  pythonnative/platform.py,sha256=WtjxR04CqVhSnjJu-3upk8bwXYaSWr2N0MOVoNov-h0,4994
18
19
  pythonnative/platform_metrics.py,sha256=1r1kMbgS9LcVTbdpP5qRD4oHEvw70te5BXEyd_16Ihc,8961
19
- pythonnative/preview.py,sha256=bzwW_LgdnCFx8lCBiqlEjwMUa1ggFLYPWmHoMWqyKtg,18041
20
- pythonnative/reconciler.py,sha256=QFIFG3KjgoPas8LVDHRWouWEEtunegPz-jl6i5Hwno8,57082
20
+ pythonnative/preview.py,sha256=RoZv1s142GWj9xpg9v5Kh-0YuuhpEfwwb_JdnzboRLw,19355
21
+ pythonnative/reconciler.py,sha256=_3-TZ7cYFvcF9Jeu3_lHa33qwfXy4OkWAVfSaYpRpNY,74426
21
22
  pythonnative/runtime.py,sha256=Ij3xxr_RyWESX7jP7b-RpsYjqjsJi1OpoV3WL3WTBWU,18245
22
- pythonnative/screen.py,sha256=AtoQP37HIWrIReecAvQXWHVx9MfW8tTO6AaBWlvroZI,68876
23
- pythonnative/storage.py,sha256=pp2mqlAy7wPr8vNwtcmalxc2658lD6z7PU4ilbnxAwE,12001
24
- pythonnative/style.py,sha256=kB3tkxJ7LfRr52fodbA2n_OpvSeQAtgMhIVC6oMQISw,17290
23
+ pythonnative/screen.py,sha256=_ylaGFviZGwllEd1akQRNJIuXIsEQf_81QkFkjblu7k,80851
24
+ pythonnative/storage.py,sha256=3brJoo0X6YuxXiAv67fHwDotPRazVP3l8dxiRiEnNEo,11995
25
+ pythonnative/style.py,sha256=-XP1vbqiTEkQraFF0JknZLHIzVsou-GUhrKz5zQ7vVk,20030
25
26
  pythonnative/utils.py,sha256=-hwe_YS19ebpjeygdl3dGeVsYzO4G74rYD53svSi0rI,7593
26
27
  pythonnative/virtual_rows.py,sha256=4YK3CeZobW-6F6GCXzGNFfmOaAiigmH4HXtqjYDRbyU,5056
27
28
  pythonnative/cli/__init__.py,sha256=NM1psvKe8jT0vzp8Ak4MMoygZz4P_msk5g-YEsY8xLk,232
28
- pythonnative/cli/pn.py,sha256=a0DXYHvcDZtfsmC91mIKgCFTO1Y8T-kkS68RH8_7kaY,28191
29
+ pythonnative/cli/pn.py,sha256=jReGw7kQY8dlrPodtBo5Aez7j9CfGUu4kMMMeUWCdPM,28191
29
30
  pythonnative/native_modules/__init__.py,sha256=pgigpHuzT-rqwcjlwJvu93_4L8Nozal1HJid0S_JlmM,2636
30
31
  pythonnative/native_modules/app_state.py,sha256=EnfChi_YWEgUpZosUiBQh0CmblBZFw8ZGaW1NKIJ4WM,2666
31
32
  pythonnative/native_modules/battery.py,sha256=gOU9aN5fCmWfHgTXPD-BgvatdQnyUjfVfsJM7PQ_ARA,4317
@@ -42,10 +43,10 @@ pythonnative/native_modules/permissions.py,sha256=ABIWiCuLIiZJmfA-B7dnw56_Iz7ApG
42
43
  pythonnative/native_modules/secure_store.py,sha256=PsnUwHzUPt-CzCAwM6BhidOBi9yofRD2uNtQIqAGofU,5953
43
44
  pythonnative/native_modules/share.py,sha256=B9ovknmnjeQvGQ8MQ14Hmq6E1x-JA469APMburJ0KUg,4727
44
45
  pythonnative/native_views/__init__.py,sha256=93v7pt0_7f8BWqOiwSvlq20F1oJLfCnmQBvLlCDA-Xk,15340
45
- pythonnative/native_views/android.py,sha256=2pgsv569rC2eWdHGoIrr1kmI-qB4ZklrMV2G9AO6OpQ,130838
46
+ pythonnative/native_views/android.py,sha256=YKokykZUkMT7N2f2Ug0uShquCdwI5joYmdVp5DzATFA,133786
46
47
  pythonnative/native_views/base.py,sha256=NFDlEIoKCINzcVkf2uobT9TgujPb1RClLS3TzwH72MY,9668
47
- pythonnative/native_views/desktop.py,sha256=GnZEchJLUcH74jG_21CCzjdYcEmm-5etUX2D0-_WNtQ,59735
48
- pythonnative/native_views/ios.py,sha256=fgskhuENQO-aiw527xOrveeRClX8uFt5UdqKSCsBT_8,169080
48
+ pythonnative/native_views/desktop.py,sha256=ZZZ1aw9iRswAfkVoYMUsFz2ztppRgFpMxxwrBkNS7lw,61192
49
+ pythonnative/native_views/ios.py,sha256=zLyaCGFSpcwgtpZd2daCv7TPjCBNPL-F23byLOflnYA,178536
49
50
  pythonnative/project/__init__.py,sha256=kAhWLONs53H1L7xVtczLmzYcQSOOkdRZTAJnIMhpBts,2064
50
51
  pythonnative/project/android.py,sha256=SX0uu4-tz4WdYAf9sbycQPSmoQ8fbtAADeUWk9G8ybM,19127
51
52
  pythonnative/project/builder.py,sha256=DokY-YidsDeWYgaixrpD3Kzp7_XudibltI8X_WdBIcE,19096
@@ -71,7 +72,7 @@ pythonnative/templates/android_template/app/src/main/java/com/pythonnative/andro
71
72
  pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PNAccessibilityDelegate.kt,sha256=R2PC6BA3VCaKET0XV33tXTFf4Ht9udvvLu9TT_RfWp4,1819
72
73
  pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PNBorderDrawable.kt,sha256=ejdFhpzn0-2TZa0nvG41r2m0xoejU2fXXuJSmO6tnBU,2205
73
74
  pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PNVirtualListView.java,sha256=1ve74nvOFqsduyaLOGPb8Sd9Jrwz-sELRB9y1NMN1AI,6072
74
- pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/ScreenFragment.kt,sha256=lSxWYH6cGDpGalo0kDzTAT5H3NuhJVLT7BQYcfCydOc,5138
75
+ pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/ScreenFragment.kt,sha256=pMxpHiguY8MToTZaMKwEF88xaGh-zLqcfYy1g5DV6eI,6051
75
76
  pythonnative/templates/android_template/app/src/main/res/drawable/ic_launcher_background.xml,sha256=7UI8c6b0Ck0pCfCQHmBSezqAfNWeG1WTvKrhgIscYyE,5606
76
77
  pythonnative/templates/android_template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml,sha256=AdGmpsEjTrf-Jw0JfrKD1yucla5RGIhvG2VzqtKA8fc,1702
77
78
  pythonnative/templates/android_template/app/src/main/res/layout/activity_main.xml,sha256=HIgdCNktb3YoJC8QOTIv-0qZRtMRoPdARK59nyYFO6g,461
@@ -111,9 +112,9 @@ pythonnative/templates/ios_template/ios_template.xcodeproj/project.xcworkspace/x
111
112
  pythonnative/templates/ios_template/ios_templateTests/ios_templateTests.swift,sha256=YnwzZx7yXB13xKAXEGNgz17VuhWeqkHTRTtBJ2Vu3_E,1238
112
113
  pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITests.swift,sha256=HLRr3cmouRqQeXG13WrZ2XSAmgMgCsNXfZpbwkxeFcs,1385
113
114
  pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITestsLaunchTests.swift,sha256=f5JrG0uVtLMeJQy26Yyz7Om-JUkT220osqcbeIVkj2g,815
114
- pythonnative-0.23.0.dist-info/licenses/LICENSE,sha256=A69iG7TIAe6KkGQf6xoVHkc5JSZtOr5eRSvC5iuivnI,1067
115
- pythonnative-0.23.0.dist-info/METADATA,sha256=t0952y_u74dbBtuyPdG1VHdQO3E8M8Iqi_EAxtmPGH4,10347
116
- pythonnative-0.23.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
117
- pythonnative-0.23.0.dist-info/entry_points.txt,sha256=iUtDawWSAJAEyWTycpZxDuYz73ol31butpzDIEAgPO0,48
118
- pythonnative-0.23.0.dist-info/top_level.txt,sha256=kT4SEATY2ywzrZ2Pgea6_zxyym44Q_PbOsUoOYjJLFE,13
119
- pythonnative-0.23.0.dist-info/RECORD,,
115
+ pythonnative-0.24.0.dist-info/licenses/LICENSE,sha256=A69iG7TIAe6KkGQf6xoVHkc5JSZtOr5eRSvC5iuivnI,1067
116
+ pythonnative-0.24.0.dist-info/METADATA,sha256=ad8csbo8lKOGtl9VfjTwTv4k5rx8E8UoKVHKbgPpmGE,11050
117
+ pythonnative-0.24.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
118
+ pythonnative-0.24.0.dist-info/entry_points.txt,sha256=iUtDawWSAJAEyWTycpZxDuYz73ol31butpzDIEAgPO0,48
119
+ pythonnative-0.24.0.dist-info/top_level.txt,sha256=kT4SEATY2ywzrZ2Pgea6_zxyym44Q_PbOsUoOYjJLFE,13
120
+ pythonnative-0.24.0.dist-info/RECORD,,