pythonnative 0.1.0__tar.gz → 0.3.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 (110) hide show
  1. {pythonnative-0.1.0 → pythonnative-0.3.0}/LICENSE +2 -2
  2. pythonnative-0.3.0/PKG-INFO +137 -0
  3. pythonnative-0.3.0/README.md +74 -0
  4. pythonnative-0.3.0/pyproject.toml +90 -0
  5. pythonnative-0.3.0/src/pythonnative/__init__.py +74 -0
  6. pythonnative-0.3.0/src/pythonnative/activity_indicator_view.py +71 -0
  7. pythonnative-0.3.0/src/pythonnative/button.py +109 -0
  8. pythonnative-0.3.0/src/pythonnative/cli/pn.py +609 -0
  9. pythonnative-0.3.0/src/pythonnative/date_picker.py +72 -0
  10. pythonnative-0.3.0/src/pythonnative/image_view.py +76 -0
  11. pythonnative-0.3.0/src/pythonnative/label.py +66 -0
  12. pythonnative-0.3.0/src/pythonnative/list_view.py +73 -0
  13. pythonnative-0.3.0/src/pythonnative/material_activity_indicator_view.py +69 -0
  14. pythonnative-0.3.0/src/pythonnative/material_button.py +65 -0
  15. pythonnative-0.3.0/src/pythonnative/material_date_picker.py +85 -0
  16. pythonnative-0.3.0/src/pythonnative/material_progress_view.py +66 -0
  17. pythonnative-0.3.0/src/pythonnative/material_search_bar.py +65 -0
  18. pythonnative-0.3.0/src/pythonnative/material_switch.py +65 -0
  19. pythonnative-0.3.0/src/pythonnative/material_time_picker.py +72 -0
  20. pythonnative-0.3.0/src/pythonnative/material_toolbar.py +0 -0
  21. pythonnative-0.3.0/src/pythonnative/page.py +396 -0
  22. pythonnative-0.3.0/src/pythonnative/picker_view.py +65 -0
  23. pythonnative-0.3.0/src/pythonnative/progress_view.py +68 -0
  24. pythonnative-0.3.0/src/pythonnative/scroll_view.py +63 -0
  25. pythonnative-0.3.0/src/pythonnative/search_bar.py +65 -0
  26. pythonnative-0.3.0/src/pythonnative/stack_view.py +60 -0
  27. pythonnative-0.3.0/src/pythonnative/switch.py +66 -0
  28. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/build.gradle +62 -0
  29. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/proguard-rules.pro +21 -0
  30. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/androidTest/java/com/pythonnative/android_template/ExampleInstrumentedTest.kt +24 -0
  31. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/AndroidManifest.xml +26 -0
  32. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/MainActivity.kt +35 -0
  33. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/Navigator.kt +26 -0
  34. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PageFragment.kt +111 -0
  35. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
  36. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +30 -0
  37. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/layout/activity_main.xml +10 -0
  38. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
  39. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
  40. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
  41. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
  42. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
  43. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
  44. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
  45. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
  46. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
  47. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
  48. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
  49. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
  50. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/navigation/nav_graph.xml +22 -0
  51. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/values/colors.xml +5 -0
  52. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/values/strings.xml +3 -0
  53. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/values/themes.xml +9 -0
  54. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/values-night/themes.xml +7 -0
  55. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/xml/backup_rules.xml +13 -0
  56. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/main/res/xml/data_extraction_rules.xml +19 -0
  57. pythonnative-0.3.0/src/pythonnative/templates/android_template/app/src/test/java/com/pythonnative/android_template/ExampleUnitTest.kt +17 -0
  58. pythonnative-0.3.0/src/pythonnative/templates/android_template/build.gradle +7 -0
  59. pythonnative-0.3.0/src/pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.jar +0 -0
  60. pythonnative-0.3.0/src/pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.properties +6 -0
  61. pythonnative-0.3.0/src/pythonnative/templates/android_template/gradle.properties +23 -0
  62. pythonnative-0.3.0/src/pythonnative/templates/android_template/gradlew +185 -0
  63. pythonnative-0.3.0/src/pythonnative/templates/android_template/gradlew.bat +89 -0
  64. pythonnative-0.3.0/src/pythonnative/templates/android_template/settings.gradle +16 -0
  65. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/AppDelegate.swift +36 -0
  66. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  67. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/AppIcon.appiconset/Contents.json +13 -0
  68. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/Contents.json +6 -0
  69. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/Base.lproj/LaunchScreen.storyboard +25 -0
  70. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/Base.lproj/Main.storyboard +24 -0
  71. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/Info.plist +25 -0
  72. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/SceneDelegate.swift +55 -0
  73. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template/ViewController.swift +218 -0
  74. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template.xcodeproj/project.pbxproj +648 -0
  75. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_template.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  76. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_templateTests/ios_templateTests.swift +36 -0
  77. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITests.swift +41 -0
  78. pythonnative-0.3.0/src/pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITestsLaunchTests.swift +32 -0
  79. pythonnative-0.3.0/src/pythonnative/text_field.py +67 -0
  80. pythonnative-0.3.0/src/pythonnative/text_view.py +70 -0
  81. pythonnative-0.3.0/src/pythonnative/time_picker.py +73 -0
  82. pythonnative-0.3.0/src/pythonnative/utils.py +91 -0
  83. pythonnative-0.3.0/src/pythonnative/view.py +25 -0
  84. pythonnative-0.3.0/src/pythonnative/web_view.py +58 -0
  85. pythonnative-0.3.0/src/pythonnative.egg-info/PKG-INFO +137 -0
  86. pythonnative-0.3.0/src/pythonnative.egg-info/SOURCES.txt +94 -0
  87. pythonnative-0.3.0/src/pythonnative.egg-info/entry_points.txt +2 -0
  88. pythonnative-0.3.0/src/pythonnative.egg-info/requires.txt +21 -0
  89. {pythonnative-0.1.0 → pythonnative-0.3.0/src}/pythonnative.egg-info/top_level.txt +0 -2
  90. pythonnative-0.3.0/tests/test_cli.py +84 -0
  91. pythonnative-0.3.0/tests/test_smoke.py +2 -0
  92. pythonnative-0.1.0/PKG-INFO +0 -47
  93. pythonnative-0.1.0/README.md +0 -33
  94. pythonnative-0.1.0/cli/pn.py +0 -113
  95. pythonnative-0.1.0/pythonnative/__init__.py +0 -7
  96. pythonnative-0.1.0/pythonnative/button.py +0 -36
  97. pythonnative-0.1.0/pythonnative/label.py +0 -36
  98. pythonnative-0.1.0/pythonnative/linear_layout.py +0 -36
  99. pythonnative-0.1.0/pythonnative/screen.py +0 -50
  100. pythonnative-0.1.0/pythonnative/view.py +0 -13
  101. pythonnative-0.1.0/pythonnative.egg-info/PKG-INFO +0 -47
  102. pythonnative-0.1.0/pythonnative.egg-info/SOURCES.txt +0 -19
  103. pythonnative-0.1.0/pythonnative.egg-info/entry_points.txt +0 -2
  104. pythonnative-0.1.0/pythonnative.egg-info/requires.txt +0 -1
  105. pythonnative-0.1.0/setup.py +0 -28
  106. {pythonnative-0.1.0 → pythonnative-0.3.0}/setup.cfg +0 -0
  107. {pythonnative-0.1.0 → pythonnative-0.3.0/src/pythonnative}/cli/__init__.py +0 -0
  108. /pythonnative-0.1.0/tests/__init__.py → /pythonnative-0.3.0/src/pythonnative/collection_view.py +0 -0
  109. /pythonnative-0.1.0/tests/test_pythonnative.py → /pythonnative-0.3.0/src/pythonnative/material_bottom_navigation_view.py +0 -0
  110. {pythonnative-0.1.0 → pythonnative-0.3.0/src}/pythonnative.egg-info/dependency_links.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 PythonNative
3
+ Copyright (c) 2025 PythonNative
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
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
21
+ THE SOFTWARE.
@@ -0,0 +1,137 @@
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/).
@@ -0,0 +1,74 @@
1
+ # PythonNative
2
+
3
+ **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.
4
+
5
+ ## Features
6
+
7
+ - **Native UI Components**: Create and manage native buttons, labels, lists, and more, all from Python.
8
+ - **Cross-Platform**: Write once, run on both Android and iOS.
9
+ - **Lifecycle Management**: Handle app lifecycle events with ease.
10
+ - **Native API Access**: Access device features like Camera, Geolocation, and Notifications.
11
+ - **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.
12
+
13
+ ## Quick Start
14
+
15
+ ### Installation
16
+
17
+ First, install PythonNative via pip:
18
+
19
+ ```bash
20
+ pip install pythonnative
21
+ ```
22
+
23
+ ### Create Your First App
24
+
25
+ Initialize a new PythonNative app:
26
+
27
+ ```bash
28
+ pn init my_app
29
+ ```
30
+
31
+ Your app directory will look like this:
32
+
33
+ ```text
34
+ my_app/
35
+ ├── README.md
36
+ ├── app
37
+ │ ├── __init__.py
38
+ │ ├── main_page.py
39
+ │ └── resources
40
+ ├── pythonnative.json
41
+ ├── requirements.txt
42
+ └── tests
43
+ ```
44
+
45
+ ### Writing Views
46
+
47
+ In PythonNative, everything is a view. Here's a simple example of how to create a main page with a list view:
48
+
49
+ ```python
50
+ import pythonnative as pn
51
+
52
+ class MainPage(pn.Page):
53
+ def __init__(self, native_instance):
54
+ super().__init__(native_instance)
55
+
56
+ def on_create(self):
57
+ super().on_create()
58
+ stack_view = pn.StackView(self.native_instance)
59
+ list_data = ["item_{}".format(i) for i in range(100)]
60
+ list_view = pn.ListView(self.native_instance, list_data)
61
+ stack_view.add_view(list_view)
62
+ self.set_root_view(stack_view)
63
+ ```
64
+
65
+ ### Run the app
66
+
67
+ ```bash
68
+ pn run android
69
+ pn run ios
70
+ ```
71
+
72
+ ## Documentation
73
+
74
+ For detailed guides and API references, visit the [PythonNative documentation](https://docs.pythonnative.com/).
@@ -0,0 +1,90 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pythonnative"
7
+ version = "0.3.0"
8
+ description = "Cross-platform native UI toolkit for Android and iOS"
9
+ authors = [
10
+ { name = "Owen Carey" }
11
+ ]
12
+ readme = "README.md"
13
+ requires-python = ">=3.9"
14
+ license = { file = "LICENSE" }
15
+ classifiers = [
16
+ "Development Status :: 2 - Pre-Alpha",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Software Development :: User Interfaces",
26
+ ]
27
+ dependencies = [
28
+ "requests>=2.31.0",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ ios = [
33
+ "rubicon-objc>=0.4.6,<0.5.0",
34
+ ]
35
+ docs = [
36
+ "mkdocs>=1.5",
37
+ "mkdocs-material[imaging]>=9.5",
38
+ "mkdocstrings[python]>=0.24",
39
+ ]
40
+ dev = [
41
+ "black>=24.0",
42
+ "ruff>=0.5",
43
+ "mypy>=1.10",
44
+ "pytest>=8.0",
45
+ ]
46
+ ci = [
47
+ "black>=24.0",
48
+ "ruff>=0.5",
49
+ "mypy>=1.10",
50
+ "pytest>=8.0",
51
+ ]
52
+
53
+ [project.scripts]
54
+ pn = "pythonnative.cli.pn:main"
55
+
56
+ [project.urls]
57
+ Homepage = "https://github.com/pythonnative/pythonnative"
58
+ Repository = "https://github.com/pythonnative/pythonnative"
59
+ Issues = "https://github.com/pythonnative/pythonnative/issues"
60
+ Documentation = "https://docs.pythonnative.com/"
61
+
62
+ [tool.setuptools.packages.find]
63
+ where = ["src"]
64
+
65
+ [tool.setuptools]
66
+ license-files = ["LICENSE*"]
67
+
68
+ # Include template directories inside the package so importlib.resources can find them
69
+ [tool.setuptools.package-data]
70
+ pythonnative = [
71
+ "templates/**",
72
+ ]
73
+
74
+ [tool.ruff]
75
+ target-version = "py39"
76
+ line-length = 120
77
+ extend-exclude = [
78
+ "experiments",
79
+ "apps",
80
+ "templates",
81
+ "docs",
82
+ ]
83
+
84
+ [tool.ruff.lint]
85
+ select = ["E", "F", "I"]
86
+ ignore = []
87
+
88
+ [tool.black]
89
+ line-length = 120
90
+ target-version = ['py39']
@@ -0,0 +1,74 @@
1
+ from importlib import import_module
2
+ from typing import Any, Dict
3
+
4
+ __version__ = "0.3.0"
5
+
6
+ __all__ = [
7
+ "ActivityIndicatorView",
8
+ "Button",
9
+ "DatePicker",
10
+ "ImageView",
11
+ "Label",
12
+ "ListView",
13
+ "MaterialActivityIndicatorView",
14
+ "MaterialButton",
15
+ "MaterialDatePicker",
16
+ "MaterialProgressView",
17
+ "MaterialSearchBar",
18
+ "MaterialSwitch",
19
+ "MaterialTimePicker",
20
+ "MaterialBottomNavigationView",
21
+ "MaterialToolbar",
22
+ "Page",
23
+ "PickerView",
24
+ "ProgressView",
25
+ "ScrollView",
26
+ "SearchBar",
27
+ "StackView",
28
+ "Switch",
29
+ "TextField",
30
+ "TextView",
31
+ "TimePicker",
32
+ "WebView",
33
+ ]
34
+
35
+ _NAME_TO_MODULE: Dict[str, str] = {
36
+ "ActivityIndicatorView": ".activity_indicator_view",
37
+ "Button": ".button",
38
+ "DatePicker": ".date_picker",
39
+ "ImageView": ".image_view",
40
+ "Label": ".label",
41
+ "ListView": ".list_view",
42
+ "MaterialActivityIndicatorView": ".material_activity_indicator_view",
43
+ "MaterialButton": ".material_button",
44
+ "MaterialDatePicker": ".material_date_picker",
45
+ "MaterialProgressView": ".material_progress_view",
46
+ "MaterialSearchBar": ".material_search_bar",
47
+ "MaterialSwitch": ".material_switch",
48
+ "MaterialTimePicker": ".material_time_picker",
49
+ "MaterialBottomNavigationView": ".material_bottom_navigation_view",
50
+ "MaterialToolbar": ".material_toolbar",
51
+ "Page": ".page",
52
+ "PickerView": ".picker_view",
53
+ "ProgressView": ".progress_view",
54
+ "ScrollView": ".scroll_view",
55
+ "SearchBar": ".search_bar",
56
+ "StackView": ".stack_view",
57
+ "Switch": ".switch",
58
+ "TextField": ".text_field",
59
+ "TextView": ".text_view",
60
+ "TimePicker": ".time_picker",
61
+ "WebView": ".web_view",
62
+ }
63
+
64
+
65
+ def __getattr__(name: str) -> Any:
66
+ module_path = _NAME_TO_MODULE.get(name)
67
+ if not module_path:
68
+ raise AttributeError(f"module 'pythonnative' has no attribute {name!r}")
69
+ module = import_module(module_path, package=__name__)
70
+ return getattr(module, name)
71
+
72
+
73
+ def __dir__() -> Any:
74
+ return sorted(list(globals().keys()) + __all__)
@@ -0,0 +1,71 @@
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 ActivityIndicatorViewBase(ABC):
12
+ @abstractmethod
13
+ def __init__(self) -> None:
14
+ super().__init__()
15
+
16
+ @abstractmethod
17
+ def start_animating(self) -> None:
18
+ pass
19
+
20
+ @abstractmethod
21
+ def stop_animating(self) -> None:
22
+ pass
23
+
24
+
25
+ if IS_ANDROID:
26
+ # ========================================
27
+ # Android class
28
+ # https://developer.android.com/reference/android/widget/ProgressBar
29
+ # ========================================
30
+
31
+ from java import jclass
32
+
33
+ class ActivityIndicatorView(ActivityIndicatorViewBase, ViewBase):
34
+ def __init__(self) -> None:
35
+ super().__init__()
36
+ self.native_class = jclass("android.widget.ProgressBar")
37
+ # self.native_instance = self.native_class(context, None, android.R.attr.progressBarStyleLarge)
38
+ context = get_android_context()
39
+ self.native_instance = self.native_class(context)
40
+ self.native_instance.setIndeterminate(True)
41
+
42
+ def start_animating(self) -> None:
43
+ # self.native_instance.setVisibility(android.view.View.VISIBLE)
44
+ return
45
+
46
+ def stop_animating(self) -> None:
47
+ # self.native_instance.setVisibility(android.view.View.GONE)
48
+ return
49
+
50
+ else:
51
+ # ========================================
52
+ # iOS class
53
+ # https://developer.apple.com/documentation/uikit/uiactivityindicatorview
54
+ # ========================================
55
+
56
+ from rubicon.objc import ObjCClass
57
+
58
+ class ActivityIndicatorView(ActivityIndicatorViewBase, ViewBase):
59
+ def __init__(self) -> None:
60
+ super().__init__()
61
+ self.native_class = ObjCClass("UIActivityIndicatorView")
62
+ self.native_instance = self.native_class.alloc().initWithActivityIndicatorStyle_(
63
+ 0
64
+ ) # 0: UIActivityIndicatorViewStyleLarge
65
+ self.native_instance.hidesWhenStopped = True
66
+
67
+ def start_animating(self) -> None:
68
+ self.native_instance.startAnimating()
69
+
70
+ def stop_animating(self) -> None:
71
+ self.native_instance.stopAnimating()
@@ -0,0 +1,109 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Callable, Optional
3
+
4
+ from .utils import IS_ANDROID, get_android_context
5
+ from .view import ViewBase
6
+
7
+ # ========================================
8
+ # Base class
9
+ # ========================================
10
+
11
+
12
+ class ButtonBase(ABC):
13
+ @abstractmethod
14
+ def __init__(self) -> None:
15
+ super().__init__()
16
+
17
+ @abstractmethod
18
+ def set_title(self, title: str) -> None:
19
+ pass
20
+
21
+ @abstractmethod
22
+ def get_title(self) -> str:
23
+ pass
24
+
25
+ @abstractmethod
26
+ def set_on_click(self, callback: Callable[[], None]) -> None:
27
+ pass
28
+
29
+
30
+ if IS_ANDROID:
31
+ # ========================================
32
+ # Android class
33
+ # https://developer.android.com/reference/android/widget/Button
34
+ # ========================================
35
+
36
+ from java import dynamic_proxy, jclass
37
+
38
+ class Button(ButtonBase, ViewBase):
39
+ def __init__(self, title: str = "") -> None:
40
+ super().__init__()
41
+ self.native_class = jclass("android.widget.Button")
42
+ context = get_android_context()
43
+ self.native_instance = self.native_class(context)
44
+ self.set_title(title)
45
+
46
+ def set_title(self, title: str) -> None:
47
+ self.native_instance.setText(title)
48
+
49
+ def get_title(self) -> str:
50
+ return self.native_instance.getText().toString()
51
+
52
+ def set_on_click(self, callback: Callable[[], None]) -> None:
53
+ class OnClickListener(dynamic_proxy(jclass("android.view.View").OnClickListener)):
54
+ def __init__(self, callback):
55
+ super().__init__()
56
+ self.callback = callback
57
+
58
+ def onClick(self, view):
59
+ self.callback()
60
+
61
+ listener = OnClickListener(callback)
62
+ self.native_instance.setOnClickListener(listener)
63
+
64
+ else:
65
+ # ========================================
66
+ # iOS class
67
+ # https://developer.apple.com/documentation/uikit/uibutton
68
+ # ========================================
69
+
70
+ from rubicon.objc import SEL, ObjCClass, objc_method
71
+
72
+ NSObject = ObjCClass("NSObject")
73
+
74
+ # Mypy cannot understand Rubicon's dynamic subclassing; ignore the base type here.
75
+ class _PNButtonHandler(NSObject): # type: ignore[valid-type]
76
+ # Set by the Button when wiring up the target/action callback.
77
+ _callback: Optional[Callable[[], None]] = None
78
+
79
+ @objc_method
80
+ def onTap_(self, sender) -> None:
81
+ try:
82
+ callback = self._callback
83
+ if callback is not None:
84
+ callback()
85
+ except Exception:
86
+ # Swallow exceptions to avoid crashing the app; logging is handled at higher levels
87
+ pass
88
+
89
+ class Button(ButtonBase, ViewBase):
90
+ def __init__(self, title: str = "") -> None:
91
+ super().__init__()
92
+ self.native_class = ObjCClass("UIButton")
93
+ self.native_instance = self.native_class.alloc().init()
94
+ self.set_title(title)
95
+
96
+ def set_title(self, title: str) -> None:
97
+ self.native_instance.setTitle_forState_(title, 0)
98
+
99
+ def get_title(self) -> str:
100
+ return self.native_instance.titleForState_(0)
101
+
102
+ def set_on_click(self, callback: Callable[[], None]) -> None:
103
+ # Create a handler object with an Objective-C method `onTap:` and attach the Python callback
104
+ handler = _PNButtonHandler.new()
105
+ # Keep strong references to the handler and callback
106
+ self._click_handler = handler
107
+ handler._callback = callback
108
+ # UIControlEventTouchUpInside = 1 << 6
109
+ self.native_instance.addTarget_action_forControlEvents_(handler, SEL("onTap:"), 1 << 6)