pythonnative 0.3.0__py3-none-any.whl → 0.5.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 (44) hide show
  1. pythonnative/__init__.py +45 -65
  2. pythonnative/cli/pn.py +16 -10
  3. pythonnative/components.py +241 -0
  4. pythonnative/element.py +47 -0
  5. pythonnative/native_views.py +800 -0
  6. pythonnative/page.py +321 -249
  7. pythonnative/reconciler.py +129 -0
  8. pythonnative/templates/android_template/app/build.gradle +2 -2
  9. pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PageFragment.kt +2 -1
  10. pythonnative/templates/android_template/app/src/main/res/navigation/nav_graph.xml +1 -1
  11. pythonnative/templates/android_template/build.gradle +3 -3
  12. pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.properties +1 -1
  13. pythonnative/utils.py +21 -29
  14. pythonnative-0.5.0.dist-info/METADATA +161 -0
  15. {pythonnative-0.3.0.dist-info → pythonnative-0.5.0.dist-info}/RECORD +19 -39
  16. {pythonnative-0.3.0.dist-info → pythonnative-0.5.0.dist-info}/WHEEL +1 -1
  17. {pythonnative-0.3.0.dist-info → pythonnative-0.5.0.dist-info}/licenses/LICENSE +1 -1
  18. pythonnative/activity_indicator_view.py +0 -71
  19. pythonnative/button.py +0 -109
  20. pythonnative/date_picker.py +0 -72
  21. pythonnative/image_view.py +0 -76
  22. pythonnative/label.py +0 -66
  23. pythonnative/list_view.py +0 -73
  24. pythonnative/material_activity_indicator_view.py +0 -69
  25. pythonnative/material_button.py +0 -65
  26. pythonnative/material_date_picker.py +0 -85
  27. pythonnative/material_progress_view.py +0 -66
  28. pythonnative/material_search_bar.py +0 -65
  29. pythonnative/material_switch.py +0 -65
  30. pythonnative/material_time_picker.py +0 -72
  31. pythonnative/picker_view.py +0 -65
  32. pythonnative/progress_view.py +0 -68
  33. pythonnative/scroll_view.py +0 -63
  34. pythonnative/search_bar.py +0 -65
  35. pythonnative/stack_view.py +0 -60
  36. pythonnative/switch.py +0 -66
  37. pythonnative/text_field.py +0 -67
  38. pythonnative/text_view.py +0 -70
  39. pythonnative/time_picker.py +0 -73
  40. pythonnative/view.py +0 -25
  41. pythonnative/web_view.py +0 -58
  42. pythonnative-0.3.0.dist-info/METADATA +0 -137
  43. {pythonnative-0.3.0.dist-info → pythonnative-0.5.0.dist-info}/entry_points.txt +0 -0
  44. {pythonnative-0.3.0.dist-info → pythonnative-0.5.0.dist-info}/top_level.txt +0 -0
pythonnative/text_view.py DELETED
@@ -1,70 +0,0 @@
1
- from abc import ABC, abstractmethod
2
-
3
- from .utils import IS_ANDROID, get_android_context
4
- from .view import ViewBase
5
-
6
- # ========================================
7
- # Base class
8
- # ========================================
9
-
10
-
11
- class TextViewBase(ABC):
12
- @abstractmethod
13
- def __init__(self) -> None:
14
- super().__init__()
15
-
16
- @abstractmethod
17
- def set_text(self, text: str) -> None:
18
- pass
19
-
20
- @abstractmethod
21
- def get_text(self) -> str:
22
- pass
23
-
24
-
25
- if IS_ANDROID:
26
- # ========================================
27
- # Android class
28
- # https://developer.android.com/reference/android/widget/EditText
29
- # ========================================
30
-
31
- from java import jclass
32
-
33
- class TextView(TextViewBase, ViewBase):
34
- def __init__(self, text: str = "") -> None:
35
- super().__init__()
36
- self.native_class = jclass("android.widget.EditText")
37
- context = get_android_context()
38
- self.native_instance = self.native_class(context)
39
- self.native_instance.setLines(3)
40
- self.native_instance.setMaxLines(5)
41
- self.native_instance.setVerticalScrollBarEnabled(True)
42
- # self.native_instance.movementMethod = ScrollingMovementMethod()
43
- self.set_text(text)
44
-
45
- def set_text(self, text: str) -> None:
46
- self.native_instance.setText(text)
47
-
48
- def get_text(self) -> str:
49
- return self.native_instance.getText().toString()
50
-
51
- else:
52
- # ========================================
53
- # iOS class
54
- # https://developer.apple.com/documentation/uikit/uitextview
55
- # ========================================
56
-
57
- from rubicon.objc import ObjCClass
58
-
59
- class TextView(TextViewBase, ViewBase):
60
- def __init__(self, text: str = "") -> None:
61
- super().__init__()
62
- self.native_class = ObjCClass("UITextView")
63
- self.native_instance = self.native_class.alloc().init()
64
- self.set_text(text)
65
-
66
- def set_text(self, text: str) -> None:
67
- self.native_instance.setText_(text)
68
-
69
- def get_text(self) -> str:
70
- return self.native_instance.text()
@@ -1,73 +0,0 @@
1
- from abc import ABC, abstractmethod
2
-
3
- from .utils import IS_ANDROID
4
- from .view import ViewBase
5
-
6
- # ========================================
7
- # Base class
8
- # ========================================
9
-
10
-
11
- class TimePickerBase(ABC):
12
- @abstractmethod
13
- def __init__(self) -> None:
14
- super().__init__()
15
-
16
- @abstractmethod
17
- def set_time(self, hour: int, minute: int) -> None:
18
- pass
19
-
20
- @abstractmethod
21
- def get_time(self) -> tuple:
22
- pass
23
-
24
-
25
- if IS_ANDROID:
26
- # ========================================
27
- # Android class
28
- # https://developer.android.com/reference/android/widget/TimePicker
29
- # ========================================
30
-
31
- from java import jclass
32
-
33
- class TimePicker(TimePickerBase, ViewBase):
34
- def __init__(self, context, hour: int = 0, minute: int = 0) -> None:
35
- super().__init__()
36
- self.native_class = jclass("android.widget.TimePicker")
37
- self.native_instance = self.native_class(context)
38
- self.set_time(hour, minute)
39
-
40
- def set_time(self, hour: int, minute: int) -> None:
41
- self.native_instance.setHour(hour)
42
- self.native_instance.setMinute(minute)
43
-
44
- def get_time(self) -> tuple:
45
- hour = self.native_instance.getHour()
46
- minute = self.native_instance.getMinute()
47
- return hour, minute
48
-
49
- else:
50
- # ========================================
51
- # iOS class
52
- # https://developer.apple.com/documentation/uikit/uidatepicker
53
- # ========================================
54
-
55
- from datetime import time
56
-
57
- from rubicon.objc import ObjCClass
58
-
59
- class TimePicker(TimePickerBase, ViewBase):
60
- def __init__(self, hour: int = 0, minute: int = 0) -> None:
61
- super().__init__()
62
- self.native_class = ObjCClass("UIDatePicker")
63
- self.native_instance = self.native_class.alloc().init()
64
- self.native_instance.setDatePickerMode_(1) # Setting mode to Time
65
- self.set_time(hour, minute)
66
-
67
- def set_time(self, hour: int, minute: int) -> None:
68
- t = time(hour, minute)
69
- self.native_instance.setTime_(t)
70
-
71
- def get_time(self) -> tuple:
72
- t = self.native_instance.time()
73
- return t.hour, t.minute
pythonnative/view.py DELETED
@@ -1,25 +0,0 @@
1
- from abc import ABC
2
- from typing import Any
3
-
4
- # ========================================
5
- # Base class
6
- # ========================================
7
-
8
-
9
- class ViewBase(ABC):
10
- def __init__(self) -> None:
11
- # Native bridge handles return types dynamically; these attributes are set at runtime.
12
- self.native_instance: Any = None
13
- self.native_class: Any = None
14
-
15
- # @abstractmethod
16
- # def add_view(self, view):
17
- # pass
18
- #
19
- # @abstractmethod
20
- # def set_layout(self, layout):
21
- # pass
22
- #
23
- # @abstractmethod
24
- # def show(self):
25
- # pass
pythonnative/web_view.py DELETED
@@ -1,58 +0,0 @@
1
- from abc import ABC, abstractmethod
2
-
3
- from .utils import IS_ANDROID, get_android_context
4
- from .view import ViewBase
5
-
6
- # ========================================
7
- # Base class
8
- # ========================================
9
-
10
-
11
- class WebViewBase(ABC):
12
- @abstractmethod
13
- def __init__(self) -> None:
14
- super().__init__()
15
-
16
- @abstractmethod
17
- def load_url(self, url: str) -> None:
18
- pass
19
-
20
-
21
- if IS_ANDROID:
22
- # ========================================
23
- # Android class
24
- # https://developer.android.com/reference/android/webkit/WebView
25
- # ========================================
26
-
27
- from java import jclass
28
-
29
- class WebView(WebViewBase, ViewBase):
30
- def __init__(self, url: str = "") -> None:
31
- super().__init__()
32
- self.native_class = jclass("android.webkit.WebView")
33
- context = get_android_context()
34
- self.native_instance = self.native_class(context)
35
- self.load_url(url)
36
-
37
- def load_url(self, url: str) -> None:
38
- self.native_instance.loadUrl(url)
39
-
40
- else:
41
- # ========================================
42
- # iOS class
43
- # https://developer.apple.com/documentation/webkit/wkwebview
44
- # ========================================
45
-
46
- from rubicon.objc import NSURL, NSURLRequest, ObjCClass
47
-
48
- class WebView(WebViewBase, ViewBase):
49
- def __init__(self, url: str = "") -> None:
50
- super().__init__()
51
- self.native_class = ObjCClass("WKWebView")
52
- self.native_instance = self.native_class.alloc().init()
53
- self.load_url(url)
54
-
55
- def load_url(self, url: str) -> None:
56
- ns_url = NSURL.URLWithString_(url)
57
- request = NSURLRequest.requestWithURL_(ns_url)
58
- self.native_instance.loadRequest_(request)
@@ -1,137 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pythonnative
3
- Version: 0.3.0
4
- Summary: Cross-platform native UI toolkit for Android and iOS
5
- Author: Owen Carey
6
- License: MIT License
7
-
8
- Copyright (c) 2025 PythonNative
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
- # PythonNative
65
-
66
- **PythonNative** is a cross-platform toolkit that allows you to create native Android and iOS apps using Python. Inspired by frameworks like React Native and NativeScript, PythonNative provides a Pythonic interface for building native UI elements, handling lifecycle events, and accessing platform-specific APIs.
67
-
68
- ## Features
69
-
70
- - **Native UI Components**: Create and manage native buttons, labels, lists, and more, all from Python.
71
- - **Cross-Platform**: Write once, run on both Android and iOS.
72
- - **Lifecycle Management**: Handle app lifecycle events with ease.
73
- - **Native API Access**: Access device features like Camera, Geolocation, and Notifications.
74
- - **Powered by Proven Tools**: PythonNative integrates seamlessly with [Rubicon](https://beeware.org/project/projects/bridges/rubicon/) for iOS and [Chaquopy](https://chaquo.com/chaquopy/) for Android, ensuring robust native performance.
75
-
76
- ## Quick Start
77
-
78
- ### Installation
79
-
80
- First, install PythonNative via pip:
81
-
82
- ```bash
83
- pip install pythonnative
84
- ```
85
-
86
- ### Create Your First App
87
-
88
- Initialize a new PythonNative app:
89
-
90
- ```bash
91
- pn init my_app
92
- ```
93
-
94
- Your app directory will look like this:
95
-
96
- ```text
97
- my_app/
98
- ├── README.md
99
- ├── app
100
- │ ├── __init__.py
101
- │ ├── main_page.py
102
- │ └── resources
103
- ├── pythonnative.json
104
- ├── requirements.txt
105
- └── tests
106
- ```
107
-
108
- ### Writing Views
109
-
110
- In PythonNative, everything is a view. Here's a simple example of how to create a main page with a list view:
111
-
112
- ```python
113
- import pythonnative as pn
114
-
115
- class MainPage(pn.Page):
116
- def __init__(self, native_instance):
117
- super().__init__(native_instance)
118
-
119
- def on_create(self):
120
- super().on_create()
121
- stack_view = pn.StackView(self.native_instance)
122
- list_data = ["item_{}".format(i) for i in range(100)]
123
- list_view = pn.ListView(self.native_instance, list_data)
124
- stack_view.add_view(list_view)
125
- self.set_root_view(stack_view)
126
- ```
127
-
128
- ### Run the app
129
-
130
- ```bash
131
- pn run android
132
- pn run ios
133
- ```
134
-
135
- ## Documentation
136
-
137
- For detailed guides and API references, visit the [PythonNative documentation](https://docs.pythonnative.com/).