webview-python 1.1.3__cp314-cp314-win_amd64.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.
@@ -0,0 +1,421 @@
1
+ Metadata-Version: 2.4
2
+ Name: webview_python
3
+ Version: 1.1.3
4
+ Summary: Python bindings for the webview library, which completely follow deno_webview design and principles
5
+ License: MIT License
6
+
7
+ Copyright (c) 2024 Python Webview Contributors
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ Project-URL: Homepage, https://github.com/congzhangzh/webview_python
28
+ Project-URL: Repository, https://github.com/congzhangzh/webview_python.git
29
+ Project-URL: Bug Tracker, https://github.com/congzhangzh/webview_python/issues
30
+ Keywords: webview,gui,desktop,application,html,web
31
+ Classifier: Development Status :: 3 - Alpha
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Programming Language :: Python
36
+ Classifier: Programming Language :: Python :: 3.10
37
+ Classifier: Programming Language :: Python :: 3.11
38
+ Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Programming Language :: Python :: 3.13
40
+ Classifier: Programming Language :: Python :: 3.14
41
+ Classifier: Programming Language :: Python :: Implementation :: CPython
42
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
43
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
44
+ Classifier: Topic :: Software Development :: User Interfaces
45
+ Requires-Python: >=3.10
46
+ Description-Content-Type: text/markdown
47
+ License-File: LICENSE
48
+ Dynamic: license-file
49
+
50
+ # Webview Python
51
+
52
+ [![Test - Windows](https://github.com/congzhangzh/webview_python/actions/workflows/test.yml/badge.svg?branch=main&event=push&label=Windows)](https://github.com/congzhangzh/webview_python/actions/workflows/test.yml)
53
+ [![Test - Linux](https://github.com/congzhangzh/webview_python/actions/workflows/test.yml/badge.svg?branch=main&event=push&label=Linux)](https://github.com/congzhangzh/webview_python/actions/workflows/test.yml)
54
+ [![Test - macOS](https://github.com/congzhangzh/webview_python/actions/workflows/test.yml/badge.svg?branch=main&event=push&label=macOS)](https://github.com/congzhangzh/webview_python/actions/workflows/test.yml)
55
+ [![PyPI version](https://badge.fury.io/py/webview_python.svg)](https://badge.fury.io/py/webview_python)
56
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
57
+ [![Python Version](https://img.shields.io/pypi/pyversions/webview_python.svg)](https://pypi.org/project/webview_python/)
58
+
59
+ Python bindings for the webview library, allowing you to create desktop applications with web technologies.
60
+
61
+ ## Production-Ready Applications
62
+
63
+ For enterprise-grade desktop applications, see the complete template: [python_desktop_app_with_vue_template](https://github.com/congzhangzh/python_desktop_app_with_vue_template). This project provides a full solution for frontend-backend integration, development workflow, debugging, and deployment.
64
+
65
+ ## Alternative: WebUI
66
+
67
+ While developing the production template, I discovered [WebUI](https://webui.me/), which appears to be an earlier project than webview/webview (though I haven't verified this claim). WebUI might be worth investigating as an alternative, but I haven't had time to do a thorough comparison. If anyone has insights or experience with WebUI vs webview, I'd appreciate hearing from you.
68
+
69
+ ## Installation
70
+
71
+ ```bash
72
+ pip install webview_python
73
+ ```
74
+
75
+ ## Environment Variables
76
+
77
+ Webview Python supports the following environment variables:
78
+
79
+ - `WEBVIEW_VERSION`: Specify the version of the webview library to use (default: "0.9.0")
80
+ - `WEBVIEW_DOWNLOAD_BASE`: Specify the base URL or file path for downloading webview libraries (default: GitHub releases)
81
+ - Can be a web URL: `https://internal-server.com/webview-libs`
82
+ - Network share: `\\server\share\webview-libs` or `/mnt/server/webview-libs`
83
+ - Local path: `/path/to/libs` or `C:\path\to\libs`
84
+
85
+ Example usage:
86
+ ```bash
87
+ # Using an internal HTTP server
88
+ export WEBVIEW_DOWNLOAD_BASE="http://internal-server.com/webview-libs"
89
+
90
+ # Using a network share on Windows
91
+ set WEBVIEW_DOWNLOAD_BASE=\\\\server\\share\\webview-libs
92
+
93
+ # Using a mounted path on Linux
94
+ export WEBVIEW_DOWNLOAD_BASE="/mnt/server/webview-libs"
95
+ ```
96
+
97
+ Note: When using a custom download location, you must organize the libraries in the same structure as the GitHub releases:
98
+ ```
99
+ WEBVIEW_DOWNLOAD_BASE/
100
+ ├── 0.9.0/
101
+ │ ├── webview.dll # Windows x64
102
+ │ ├── WebView2Loader.dll # Windows x64
103
+ │ ├── libwebview.x86_64.so # Linux x64
104
+ │ ├── libwebview.aarch64.so # Linux ARM64
105
+ │ ├── libwebview.x86_64.dylib # macOS x64
106
+ │ └── libwebview.aarch64.dylib # macOS ARM64
107
+ └── other-versions/...
108
+ ```
109
+
110
+ ## Usage
111
+
112
+ ### Display Inline HTML:
113
+
114
+ ```python
115
+ from webview.webview import Webview
116
+ from urllib.parse import quote
117
+
118
+ html = """
119
+ <html>
120
+ <body>
121
+ <h1>Hello from Python Webview!</h1>
122
+ </body>
123
+ </html>
124
+ """
125
+ webview = Webview()
126
+ webview.navigate(f"data:text/html,{quote(html)}")
127
+ webview.run()
128
+ ```
129
+
130
+ ### Load Local HTML File:
131
+
132
+ ```python
133
+ from webview.webview import Webview
134
+ import os
135
+
136
+ webview = Webview()
137
+ current_dir = os.path.dirname(os.path.abspath(__file__))
138
+ html_path = os.path.join(current_dir, 'local.html')
139
+ webview.navigate(f"file://{html_path}")
140
+ webview.run()
141
+ ```
142
+
143
+ ### Load Remote URL:
144
+
145
+ ```python
146
+ from webview.webview import Webview
147
+ webview = Webview()
148
+ webview.navigate("https://www.python.org")
149
+ webview.run()
150
+ ```
151
+
152
+ ### Python-JavaScript Bindings:
153
+
154
+ ```python
155
+ from webview.webview import Webview, Size, SizeHint
156
+ from urllib.parse import quote
157
+
158
+ webview = Webview(debug=True)
159
+
160
+ # Python functions that can be called from JavaScript
161
+ def hello():
162
+ webview.eval("updateFromPython('Hello from Python!')")
163
+ return "Hello from Python!"
164
+
165
+ def add(a, b):
166
+ return a + b
167
+
168
+ # Bind Python functions
169
+ webview.bind("hello", hello)
170
+ webview.bind("add", add)
171
+
172
+ # Configure window
173
+ webview.title = "Python-JavaScript Binding Demo"
174
+ webview.size = Size(640, 480, SizeHint.FIXED)
175
+
176
+ # Load HTML with JavaScript
177
+ html = """
178
+ <html>
179
+ <head>
180
+ <title>Python-JavaScript Binding Demo</title>
181
+ <script>
182
+ async function callPython() {
183
+ const result = await hello();
184
+ document.getElementById('result').innerHTML = result;
185
+ }
186
+
187
+ async function callPythonWithArgs() {
188
+ const result = await add(40, 2);
189
+ document.getElementById('result').innerHTML = `Result: ${result}`;
190
+ }
191
+
192
+ function updateFromPython(message) {
193
+ document.getElementById('result').innerHTML = `Python says: ${message}`;
194
+ }
195
+ </script>
196
+ </head>
197
+ <body>
198
+ <h1>Python-JavaScript Binding Demo</h1>
199
+ <button onclick="callPython()">Call Python</button>
200
+ <button onclick="callPythonWithArgs()">Call Python with Args</button>
201
+ <div id="result"></div>
202
+ </body>
203
+ </html>
204
+ """
205
+
206
+ webview.navigate(f"data:text/html,{quote(html)}")
207
+ webview.run()
208
+ ```
209
+
210
+ ### Async Python Functions with JavaScript:
211
+
212
+ Webview Python supports binding asynchronous Python functions that can be called from JavaScript. This is useful for time-consuming operations that should not block the main thread.
213
+
214
+ Demo: [bind_in_local_async_by_asyncio_guest_win32_wip.py](examples/async_with_asyncio_guest_run/bind_in_local_async_by_asyncio_guest_win32_wip.py), [bind_in_local_async.html](examples/async_with_asyncio_guest_run/bind_in_local_async.html)
215
+
216
+ ```python
217
+ import asyncio
218
+ from webview.webview import Webview, Size, SizeHint
219
+
220
+ webview = Webview(debug=True)
221
+
222
+ # Async Python function that can be called from JavaScript
223
+ async def delayed_message(message, delay=1):
224
+ # Simulating a time-consuming operation
225
+ await asyncio.sleep(delay)
226
+ return f"Async response after {delay}s: {message}"
227
+
228
+ # Async function with progress reporting
229
+ async def process_with_progress(steps=5, step_time=1):
230
+ results = []
231
+ for i in range(1, steps + 1):
232
+ await asyncio.sleep(step_time)
233
+ # Report progress to JavaScript
234
+ progress = (i / steps) * 100
235
+ webview.eval(f"updateProgress({progress}, 'Processing: Step {i}/{steps}')")
236
+ results.append(f"Step {i} completed")
237
+
238
+ return {
239
+ "status": "complete",
240
+ "steps": steps,
241
+ "results": results
242
+ }
243
+
244
+ # Bind async Python functions
245
+ webview.bind("delayedMessage", delayed_message)
246
+ webview.bind("processWithProgress", process_with_progress)
247
+
248
+ # HTML/JavaScript
249
+ html = """
250
+ <html>
251
+ <head>
252
+ <script>
253
+ async function callAsyncPython() {
254
+ try {
255
+ document.getElementById('result').innerHTML = "Waiting for async response...";
256
+ const result = await delayedMessage("Hello from async world!", 2);
257
+ document.getElementById('result').innerHTML = result;
258
+ } catch (err) {
259
+ document.getElementById('result').innerHTML = `Error: ${err}`;
260
+ }
261
+ }
262
+
263
+ function updateProgress(percent, message) {
264
+ document.getElementById('progress').style.width = percent + '%';
265
+ document.getElementById('progress-text').textContent = message;
266
+ }
267
+ </script>
268
+ </head>
269
+ <body>
270
+ <button onclick="callAsyncPython()">Call Async Python</button>
271
+ <div id="result"></div>
272
+ <div id="progress" style="background-color: #ddd; width: 100%">
273
+ <div id="progress-bar" style="height: 20px; background-color: #4CAF50; width: 0%"></div>
274
+ </div>
275
+ <div id="progress-text"></div>
276
+ </body>
277
+ </html>
278
+ """
279
+
280
+ webview.navigate(f"data:text/html,{quote(html)}")
281
+ webview.run()
282
+ ```
283
+
284
+ For a more complete example, see [bind_in_local_async.py](examples/bind_in_local_async.py) and [bind_in_local_async.html](examples/bind_in_local_async.html) in the examples directory.
285
+
286
+ ## Features
287
+
288
+ - Create desktop applications using HTML, CSS, and JavaScript
289
+ - Load local HTML files or remote URLs
290
+ - Bidirectional Python-JavaScript communication
291
+ - Support for async Python functions with JavaScript promises
292
+ - Progress reporting for long-running tasks
293
+ - Window size and title customization
294
+ - Debug mode for development
295
+ - Cross-platform support (Windows, macOS, Linux)
296
+
297
+ ## Development
298
+
299
+ ### Setup Development Environment
300
+
301
+ ```bash
302
+ # Install Python build tools
303
+ pip install --upgrade pip build twine
304
+
305
+ # Install GitHub CLI (choose one based on your OS):
306
+ # macOS
307
+ brew install gh
308
+
309
+ # Windows
310
+ winget install GitHub.cli
311
+ # or
312
+ choco install gh
313
+
314
+ # Linux (Debian/Ubuntu)
315
+ curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
316
+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
317
+ && sudo apt update \
318
+ && sudo apt install gh
319
+ ```
320
+
321
+ ### Running Tests
322
+
323
+ ```bash
324
+ python -m unittest discover tests
325
+ ```
326
+
327
+ ### Project Structure
328
+
329
+ ```
330
+ webview_python/
331
+ ├── src/
332
+ │ ├── webview.py # Main webview implementation
333
+ │ └── ffi.py # Foreign Function Interface
334
+ ├── examples/ # Example applications
335
+ ├── tests/ # Unit tests
336
+ └── README.md # Documentation
337
+ ```
338
+
339
+ ### Release Process
340
+
341
+ For maintainers who want to release a new version:
342
+ 1. **Test**
343
+ ```bash
344
+ # Install dependencies if not installed
345
+ pip install -r requirements.txt
346
+
347
+ # Run tests
348
+ pytest
349
+
350
+ # Build wheels
351
+ python -m build -n -w
352
+ ```
353
+
354
+ 2. **Update Version**
355
+ ```bash
356
+ # Ensure you have the latest code
357
+ git pull origin main
358
+
359
+ # Update version in pyproject.toml
360
+ # Edit version = "x.y.z" to new version number
361
+ ```
362
+
363
+ 3. **Create Release**
364
+ ```bash
365
+ # Commit changes
366
+ old_version=1.1.1
367
+ new_version=1.1.2
368
+ git add pyproject.toml README.md
369
+ git commit -m "Bump version to ${new_version}"
370
+ git push origin main
371
+
372
+ # Create and push tag
373
+ git tag v${new_version}
374
+ git push origin v${new_version}
375
+
376
+ # Create GitHub release
377
+ gh release create v${new_version} --title "${new_version}" \
378
+ --notes "Full Changelog: https://github.com/congzhangzh/webview_python/compare/v${old_version}...v${new_version}"
379
+ ```
380
+
381
+ 4. **Monitor Release**
382
+ - Check GitHub Actions progress in the Actions tab
383
+ - Verify package on PyPI after workflow completion
384
+
385
+ ### First-time Release Setup
386
+
387
+ 1. **PyPI Setup**
388
+ - Create account: https://pypi.org/account/register/
389
+ - Generate API token: https://pypi.org/manage/account/token/
390
+
391
+ 2. **GitHub Setup**
392
+ - Repository Settings → Secrets and variables → Actions
393
+ - Add new secret: `PYPI_API_TOKEN` with PyPI token value
394
+
395
+ ## Roadmap
396
+
397
+ - [x] Publish to PyPI
398
+ - [x] Setup GitHub Actions for CI/CD
399
+ - [x] Add async function support
400
+ - [x] Add preact example
401
+ - [ ] Add three.js example
402
+ - [ ] Add three.js fiber example
403
+ - [ ] Add screen saver 4 window example
404
+ - [ ] Add MRI principle demo example by three.js fiber
405
+ - [ ] Add screen saver 4 windows with MRI principle demo example by three.js fiber
406
+
407
+ ## TBD
408
+ - [x] CTRL-C support
409
+
410
+ ## References
411
+
412
+ - [Webview](https://github.com/webview/webview)
413
+ - [webview C API IMPL](https://github.com/webview/webview/blob/master/core/include/webview/c_api_impl.hh)
414
+ - [Webview C API](https://github.com/webview/webview/blob/master/src/webview.h)
415
+ - [webview_deno](https://github.com/eliassjogreen/webview_deno)
416
+ - [asyncio-guest](https://github.com/congzhangzh/asyncio-guest)
417
+ - [asyncio-guest win32](https://github.com/congzhangzh/asyncio-guest/blob/master/asyncio_guest/asyncio_guest_win32.py)
418
+
419
+ # License
420
+
421
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,10 @@
1
+ webview/__init__.py,sha256=JuNAt_hPXKYzZnm2GNxwcjuJnHOENC3_iuqI74iDVqY,46
2
+ webview/_dummy_holder.c,sha256=tNfuKbqPQTnCB0e2dpRlc7-FATDmyYks8s2skwXSH4c,188177
3
+ webview/_dummy_holder.cp314-win_amd64.pyd,sha256=qb7uAZMZvw26EtauAUDzRchTWnI2sLmoKLZC14NwhNM,16384
4
+ webview/_webview_ffi.py,sha256=R5WvyBGQ0672WppsHe_3ZVL_z2AIVUIqORIz7aIErm0,6963
5
+ webview/webview.py,sha256=UzNHRXuDkpNaOVb7A4br3jRofuPYX6fNvAD-OONKsNc,3746
6
+ webview_python-1.1.3.dist-info/licenses/LICENSE,sha256=4za-tnz_zaV1oY5vxbtLpVy2TvyOcRkT0nsku5qobSg,1105
7
+ webview_python-1.1.3.dist-info/METADATA,sha256=SYtyz_H11lcONeBt2onQF4qei5NKBr2tf0M_fL2BYX8,15030
8
+ webview_python-1.1.3.dist-info/WHEEL,sha256=MRIqJmWGXGbCDxvKAKUMbTPbbQhv9CNuiiNgFEELfOM,101
9
+ webview_python-1.1.3.dist-info/top_level.txt,sha256=d5SpaV1yBkWk3tar-VrEOX-bBM9jXPlVdVNpN5FQrxA,8
10
+ webview_python-1.1.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314-win_amd64
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Python Webview Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ webview